├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── chap1-code
└── chap1-os-services.txt
├── chap10-code
├── base-infra.yml
├── base-nagios.yml
├── base-nconf.yml
├── base.yml
├── group_vars
│ ├── all_containers
│ ├── hosts
│ └── nagios-server
├── hosts
├── post-nagios-install.yml
├── post-nconf-install.yml
└── roles
│ ├── create-nagios-user
│ ├── files
│ │ └── nagios-key
│ └── tasks
│ │ └── main.yml
│ ├── infra-plugin-config
│ ├── files
│ │ ├── check_http
│ │ ├── check_port.pl
│ │ ├── check_snmp_process.pl
│ │ ├── show_users
│ │ ├── utils.pm
│ │ └── utils.sh
│ └── tasks
│ │ └── main.yml
│ ├── install-nagios
│ ├── files
│ │ ├── id_dsa
│ │ ├── id_dsa.pub
│ │ └── nagios-ubuntu-logo.tar
│ └── tasks
│ │ └── main.yml
│ ├── install-nconf
│ ├── tasks
│ │ └── main.yml
│ └── templates
│ │ └── create-nconf-db.sql
│ ├── nagios-plugins
│ ├── files
│ │ ├── NagiosConfig.zip
│ │ └── nagios-plugins.tar
│ └── tasks
│ │ └── main.yml
│ ├── nagios-post-install
│ ├── files
│ │ ├── deploy_local.sh
│ │ └── nagios.txt
│ └── tasks
│ │ └── main.yml
│ ├── nconf-post-install
│ └── tasks
│ │ └── main.yml
│ └── snmp-config
│ ├── tasks
│ └── main.yml
│ └── templates
│ └── snmpd.conf
├── chap2-code
└── chap2-ansible.txt
├── chap3-code
├── base.yml
├── create-users-env
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── group_vars
│ └── util_container
└── hosts
├── chap4-code
├── adjust-quotas
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── group_vars
│ └── util_container
├── hosts
└── quota-update.yml
├── chap5-code
├── create-snapshot
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── group_vars
│ └── util_container
├── hosts
└── snapshot-tenant.yml
├── chap6-code
├── group_vars
│ └── util_container
├── hosts
├── instance-migrate
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
└── migrate.yml
├── chap7-code
└── ansible-coreos
│ ├── base.yml
│ ├── hosts
│ └── roles
│ └── defunctzombie.coreos-bootstrap
│ ├── .editorconfig
│ ├── .travis.yml
│ ├── LICENSE
│ ├── README.md
│ ├── files
│ ├── bootstrap.sh
│ ├── get-pip.py
│ └── runner
│ ├── meta
│ ├── .galaxy_install_info
│ └── main.yml
│ ├── tasks
│ └── main.yml
│ └── tests
│ └── test.yml
├── chap8-code
├── config-admin-region
│ ├── tasks
│ │ └── main.yml
│ └── vars
│ │ └── main.yml
├── config-admin.yml
├── configure-region-authentication.txt
├── group_vars
│ └── util_container
├── hosts
├── register-endpoints.yml
└── register-endpoints
│ ├── tasks
│ └── main.yml
│ └── vars
│ └── main.yml
└── chap9-code
└── cloud-inventory
├── group_vars
├── galera_container
└── util_container
├── hosts
├── inventory.yml
└── roles
├── cloud-inventory
├── files
│ └── cloud_report.sql
└── tasks
│ └── main.yml
├── cloud-usage
└── tasks
│ └── main.yml
├── network-inventory
├── files
│ └── network_report.sql
└── tasks
│ └── main.yml
├── project-inventory
├── files
│ └── project_report.sql
└── tasks
│ └── main.yml
├── user-inventory
├── files
│ └── user_report.sql
└── tasks
│ └── main.yml
└── volume-inventory
├── files
└── volume_report.sql
└── tasks
└── main.yml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # OpenStack Administration with Ansible 2
5 | This is the code repository for [OpenStack Administration with Ansible 2](https://www.packtpub.com/virtualization-and-cloud/openstack-administration-ansible-2-second-edition?utm_source=github&utm_medium=repository&utm_content=9781787121638), published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.
6 | ## Instructions and Navigations
7 | All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, chap2-code
8 |
9 | The code will look like the following:
10 |
11 | - name: User password assignment
12 | debug: msg="User {{ item.0 }} was added to {{ item.2 }} project, with the assigned password of {{ item.1 }}"
13 | with_together:
14 | - userid
15 | - passwdss.stdout_lines
16 | - tenantid
17 |
18 | ### Software requirements:
19 |
20 | * Linux based OS, OS X and/or any of the BSD’s
21 |
22 | * openstack-ansible (OSA): https://github.com/openstack/openstack-ansible
23 | * Ansible 2.0 or better : http://docs.ansible.com/ansible/intro_installation.html
24 | * Ansible Container : https://docs.ansible.com/ansible-container/installation.html
25 | * Kargo : https://github.com/kubernetes-incubator/kargo
26 | * Nagios : https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart.html
27 | * Nconf : http://www.nconf.org/dokuwiki/doku.php?id=nconf:help:documentation:start:installation
28 |
29 | ## Related Products:
30 |
31 | * [OpenStack Cloud Computing Cookbook - Third Edition]( https://www.packtpub.com/virtualization-and-cloud/openstack-cloud-computing-cookbook-third-edition?utm_source=github&utm_medium=repository&utm_content=9781782174783 )
32 |
33 | * [OpenStack: Building a Cloud Environment]( https://www.packtpub.com/virtualization-and-cloud/openstack-building-cloud-environment?utm_source=github&utm_medium=repository&utm_content=9781787123182 )
34 |
35 | * [Ansible 2 for Beginners [Video]]( https://www.packtpub.com/networking-and-servers/ansible-2-beginners-video?utm_source=github&utm_medium=repository&utm_content=9781786465719 )
36 |
37 | ###Suggestions and Feedback
38 | [Click here] ( https://docs.google.com/forms/d/e/1FAIpQLSe5qwunkGf6PUvzPirPDtuy1Du5Rlzew23UBp2S-P3wB-GcwQ/viewform ) if you have any feedback or suggestions.
39 | ### Download a free PDF
40 |
41 | If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.
42 |
https://packt.link/free-ebook/9781785884610
-------------------------------------------------------------------------------- /chap1-code/chap1-os-services.txt: -------------------------------------------------------------------------------- 1 | ## List OpenStack Services 2 | 3 | ### Via API 4 | $ curl -d @credentials.json –X POST -H "Content-Type: application/json" http://127.0.0.1:5000/v3/auth/tokens | python -mjson.tool 5 | 6 | #### Authorization string 7 | { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "admin", "domain": { "id": "default" }, "password": "passwd" } } } } } 8 | 9 | #### HTTP Header Output 10 | HTTP/1.1 201 Created Date: Tue, 20 Sep 2016 21:20:02 GMT Server: Apache X-Subject-Token: gAAAAABX4agC32nymQSbku39x1QPooKDpU2T9oPYapF6ZeY4QSA9EOqQZ8PcKqMT2j5m9uvOtC9c8d9szObciFr06stGo19tNueHDfvHbgRLFmjTg2k8Scu1Q4esvjbwth8aQ-qMSe4NRTWmD642i6pDfk_AIIQCNA Vary: X-Auth-Token x-openstack-request-id: req-8de6fa59-8256-4a07-b040-c21c4aee6064 Content-Length: 283 Content-Type: application/json 11 | #### API Request 12 | $ curl -X GET http://127.0.0.1:35357/v3/services -H "Accept: application/json" -H "X-Auth-Token: 907ca229af164a09918a661ffa224747" | python -mjson.tool 13 | 14 | #### JSON Output 15 | { "links": { "next": null, "previous": null, "self": "http://example.com/identity/v3/services" }, "services": [ { "description": "Nova Compute Service", "enabled": true, "id": "1999c3a858c7408fb586817620695098", "links": { "... }, "name": "nova", "type": "compute" }, { "description": "Cinder Volume Service V2", "enabled": true, "id": "39216610e75547f1883037e11976fc0f", "links": { "... }, "name": "cinderv2", "type": "volumev2" }, ... 16 | ### Via CLI 17 | 18 | #### OpenRC v2.0 file example 19 | # To use an OpenStack cloud you need to authenticate against keystone. 20 | export OS_ENDPOINT_TYPE=internalURL 21 | export OS_USERNAME=admin 22 | export OS_TENANT_NAME=admin 23 | export OS_AUTH_URL=http://127.0.0.1:5000/v2.0 24 | 25 | # With Keystone you pass the keystone password. 26 | echo "Please enter your OpenStack Password: " 27 | read -sr OS_PASSWORD_INPUT 28 | export OS_PASSWORD=$OS_PASSWORD_INPUT 29 | 30 | 31 | #### OpenRC v3.0 file example 32 | # *NOTE*: Using the 3 *Identity API* does not necessarily mean any other # OpenStack API is version 3. For example, your cloud provider may implement # Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is # only for the Identity API served through keystone. export OS_AUTH_URL=http://172.29.238.2:5000/v3 # With the addition of Keystone we have standardized on the term **project** # as the entity that owns the resources. export OS_PROJECT_ID=5408dd3366e943b694cae90a04d71c88 export OS_PROJECT_NAME="admin" export OS_USER_DOMAIN_NAME="Default" if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi # unset v2.0 items in case set unset OS_TENANT_ID unset OS_TENANT_NAME # In addition to the owning entity (tenant), OpenStack stores the entity # performing the action as the **user**. export OS_USERNAME="admin" # With Keystone you pass the keystone password. echo "Please enter your OpenStack Password: " read -sr OS_PASSWORD_INPUT export OS_PASSWORD=$OS_PASSWORD_INPUT # If your configuration has multiple regions, we set that information here. # OS_REGION_NAME is optional and only valid in certain environments. export OS_REGION_NAME="RegionOne" # Don't leave a blank variable, unset it if it was empty if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi 33 | 34 | 35 | #### CLI commands 36 | $ source openrc 37 | $ keystone service-list 38 | OR 39 | $ openstack service list 40 | 41 | -------------------------------------------------------------------------------- /chap10-code/base-infra.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for the Infrastructure hosts. 3 | 4 | - hosts: hosts 5 | remote_user: root 6 | become: true 7 | roles: 8 | - create-nagios-user 9 | - infra-plugin-config -------------------------------------------------------------------------------- /chap10-code/base-nagios.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for Nagios. 3 | 4 | - hosts: nagios-server 5 | remote_user: root 6 | become: true 7 | roles: 8 | - install-nagios 9 | - nagios-plugins -------------------------------------------------------------------------------- /chap10-code/base-nconf.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for NConf. 3 | 4 | - hosts: nagios-server 5 | remote_user: root 6 | become: true 7 | roles: 8 | - install-nconf -------------------------------------------------------------------------------- /chap10-code/base.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for Infrastructure hosts and containers. 3 | 4 | - hosts: all_containers 5 | remote_user: root 6 | become: true 7 | roles: 8 | - snmp-config 9 | 10 | - hosts: hosts 11 | remote_user: root 12 | become: true 13 | roles: 14 | - snmp-config -------------------------------------------------------------------------------- /chap10-code/group_vars/all_containers: -------------------------------------------------------------------------------- 1 | # Here are variables related to the install 2 | 3 | USER: nagios 4 | SNMP_COMMUNITY: osad 5 | SYS_LOCATION: SAT 6 | SYS_CONTACT: support@rackspace.com 7 | 8 | -------------------------------------------------------------------------------- /chap10-code/group_vars/hosts: -------------------------------------------------------------------------------- 1 | # Here are variables related to the install 2 | 3 | USER: nagios 4 | SNMP_COMMUNITY: osad 5 | SYS_LOCATION: SAT 6 | SYS_CONTACT: support@rackspace.com 7 | 8 | -------------------------------------------------------------------------------- /chap10-code/group_vars/nagios-server: -------------------------------------------------------------------------------- 1 | # Here are variables related to the install 2 | 3 | DB_NAME: NCONF_DB 4 | DB_USER: root 5 | DB_PASS: passwd -------------------------------------------------------------------------------- /chap10-code/hosts: -------------------------------------------------------------------------------- 1 | 2 | [nagios-server] 3 | 021579-nagios01 4 | -------------------------------------------------------------------------------- /chap10-code/post-nagios-install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for NConf. 3 | 4 | - hosts: nagios-server 5 | remote_user: root 6 | become: true 7 | roles: 8 | - nagios-post-install -------------------------------------------------------------------------------- /chap10-code/post-nconf-install.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys components needed for NConf. 3 | 4 | - hosts: nagios-server 5 | remote_user: root 6 | become: true 7 | roles: 8 | - nconf-post-install -------------------------------------------------------------------------------- /chap10-code/roles/create-nagios-user/files/nagios-key: -------------------------------------------------------------------------------- 1 | ssh-dss AAAAB3NzaC1kc3MAAACBAJI8cQX6ujs5iXdJ/vsqjHZeZHyT11hc7TJ6p5sb1nd8v8vfQ2Z1azyOZ0Zraz5gk9QkiBhM2lhulQKhHdcjh9SRuVWaiL6Xn074FWPNqWBqI5kMNDu87oxrFFqjhl9xHCicQL2FeL3J2K64OqhX7reTmnXeU4EpiUvGBiCEU9HjAAAAFQCmu5AuLABeUiu0DBJVFHiDLXR+zQAAAIB79/1R1zQdG95ZSGNwiyHTeb2rBTvSP11hbRYFpCJ0NwmGLOIajrbJsgPcHwmroAwBo2HlRaOcjtDSyzHxaUpTXwck0HnzuffnbEH18WvWYxFQ9LIk+xbQybakADJMVncd/AKbS3g+x9bPpcUwJT2ir5CCfwwol5YTS5icl3bZCwAAAIEAi93ycGNBLVtMeafSGiCdiHrPToO4HGokpepHuIo5ryaE8G6B5r4NyrJCudGfVYIiyhrUDcgUyV2PA91m/HqmxczhyexyqTy0Edev6FEPoxR5dh02NLd+zHa7yFNaGvT1meFM42hCltcIW61/ofveuijGzwdU9cohosFKeMrRC3w= nagios@021579-deploy01 -------------------------------------------------------------------------------- /chap10-code/roles/create-nagios-user/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Create Nagios user 4 | user: name="{{ USER }}" comment="{{ USER }} User" 5 | ignore_errors: yes 6 | 7 | - name: Create user .ssh directory 8 | file: path=/home/"{{ USER }}"/.ssh state=directory 9 | 10 | - name: Copy authorized keys 11 | copy: src=nagios-key dest=/home/"{{ USER }}"/.ssh/authorized_keys mode=0644 12 | 13 | - name: Set home directory permissions 14 | file: path=/home/"{{ USER }}" owner="{{ USER }}" group="{{ USER }}" recurse=yes -------------------------------------------------------------------------------- /chap10-code/roles/infra-plugin-config/files/check_http: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/OpenStack-Administration-with-Ansible-2/b873eba0b58ab6db8274fb8b68a4424533c19a54/chap10-code/roles/infra-plugin-config/files/check_http -------------------------------------------------------------------------------- /chap10-code/roles/infra-plugin-config/files/check_port.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | #=============================================================================== 3 | # 4 | # FILE: check_port.pl 5 | # 6 | # USAGE: check_port.pl -p