├── .gitignore
├── README.md
├── Vagrantfile
├── ansible-lab1
├── README.md
└── hosts
├── ansible-lab2
├── README.md
└── hosts
├── ansible-lab3
├── README.md
├── hosts
├── playbook1.yml
└── templates
│ ├── index.html.j2
│ └── ports.conf.j2
├── ansible-lab4
├── README.md
├── handlers
│ └── main.yml
├── hosts
├── playbook1.yml
├── tasks
│ └── apache2_install.yml
└── templates
│ ├── index.html.j2
│ └── ports.conf.j2
├── ansible-lab5
├── README.md
├── hosts
├── playbook1.yml
└── roles
│ ├── apache2
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── apache2_install.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ └── ports.conf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── common
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_tools.yml
│ │ └── main.yml
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ └── nginx
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ ├── configure_nginx.yml
│ ├── install_packages.yml
│ └── main.yml
│ ├── templates
│ └── mysite.j2
│ ├── tests
│ ├── inventory
│ └── test.yml
│ └── vars
│ └── main.yml
├── ansible-lab6
├── README.md
├── hosts
├── playbook1.yml
└── roles
│ ├── apache2
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── apache2_install.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ └── ports.conf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── common
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_tools.yml
│ │ ├── main.yml
│ │ └── system_configuration.yml
│ ├── templates
│ │ └── hosts.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ └── nginx
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ ├── configure_nginx.yml
│ ├── install_packages.yml
│ └── main.yml
│ ├── templates
│ └── mysite.j2
│ ├── tests
│ ├── inventory
│ └── test.yml
│ └── vars
│ └── main.yml
├── ansible-lab7
├── README.md
├── group_vars
│ └── all
│ │ └── common_variables.yml
├── host_vars
│ └── web01.yml
├── hosts
├── playbook1.yml
└── roles
│ ├── apache2
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── apache2_install.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ └── ports.conf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── common
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_tools.yml
│ │ ├── main.yml
│ │ └── system_configuration.yml
│ ├── templates
│ │ └── hosts.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ └── nginx
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ ├── configure_nginx.yml
│ ├── install_packages.yml
│ └── main.yml
│ ├── templates
│ └── mysite.j2
│ ├── tests
│ ├── inventory
│ └── test.yml
│ └── vars
│ └── main.yml
├── ansible-lab8
├── README.md
├── group_vars
│ └── all
│ │ └── common_variables.yml
├── host_vars
│ └── web01.yml
├── inventories
│ ├── dev
│ └── prod
├── playbook1.yml
└── roles
│ ├── apache2
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── apache2_install.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ └── ports.conf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── common
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_tools.yml
│ │ ├── main.yml
│ │ └── system_configuration.yml
│ ├── templates
│ │ └── hosts.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ └── nginx
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ ├── configure_nginx.yml
│ ├── install_packages.yml
│ └── main.yml
│ ├── templates
│ └── mysite.j2
│ ├── tests
│ ├── inventory
│ └── test.yml
│ └── vars
│ └── main.yml
├── ansible-lab9
├── README.md
├── group_vars
│ └── all
│ │ └── common_variables.yml
├── host_vars
│ ├── db01.yml
│ └── web01.yml
├── inventories
│ ├── dev
│ └── prod
├── playbook1.retry
├── playbook1.yml
└── roles
│ ├── apache2
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── apache2_install.yml
│ │ └── main.yml
│ ├── templates
│ │ ├── index.html.j2
│ │ └── ports.conf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── common
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_tools.yml
│ │ ├── main.yml
│ │ └── system_configuration.yml
│ ├── templates
│ │ └── hosts.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ ├── mysql
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ │ └── main.yml
│ ├── handlers
│ │ └── main.yml
│ ├── meta
│ │ └── main.yml
│ ├── tasks
│ │ ├── install_mysql.yml
│ │ ├── main.yml
│ │ └── setup_mysql.yml
│ ├── templates
│ │ └── my.cnf.j2
│ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ └── vars
│ │ └── main.yml
│ └── nginx
│ ├── .travis.yml
│ ├── README.md
│ ├── defaults
│ └── main.yml
│ ├── handlers
│ └── main.yml
│ ├── meta
│ └── main.yml
│ ├── tasks
│ ├── configure_nginx.yml
│ ├── install_packages.yml
│ └── main.yml
│ ├── templates
│ └── mysite.j2
│ ├── tests
│ ├── inventory
│ └── test.yml
│ └── vars
│ └── main.yml
├── hosts_file
└── lab
├── ansible_facts.json
├── group_vars
└── all
│ └── common_variables.yml
├── host_vars
└── web01.yml
├── inventories
├── dev
└── prod
├── playbook1.retry
├── playbook1.yml
└── roles
├── apache2
├── README.md
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── tasks
│ ├── apache2_install.yml
│ └── main.yml
├── templates
│ ├── index.html.j2
│ └── ports.conf.j2
├── tests
│ ├── inventory
│ └── test.yml
└── vars
│ └── main.yml
├── common
├── README.md
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── tasks
│ ├── install_tools.yml
│ ├── main.yml
│ └── system_configuration.yml
├── templates
│ └── hosts.j2
├── tests
│ ├── inventory
│ └── test.yml
└── vars
│ └── main.yml
├── mysql
├── README.md
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── tasks
│ ├── install_mysql.yml
│ ├── main.yml
│ └── setup_mysql.yml
├── templates
│ └── my.cnf.j2
├── tests
│ ├── inventory
│ └── test.yml
└── vars
│ └── main.yml
└── nginx
├── README.md
├── defaults
└── main.yml
├── handlers
└── main.yml
├── meta
└── main.yml
├── tasks
├── configure_nginx.yml
├── install_packages.yml
└── main.yml
├── templates
└── mysite.j2
├── tests
├── inventory
└── test.yml
└── vars
└── main.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
2 |
3 | # Created by https://www.gitignore.io/api/windows,visualstudiocode
4 | # Edit at https://www.gitignore.io/?templates=windows,visualstudiocode
5 |
6 | ### VisualStudioCode ###
7 | .vscode/*
8 | !.vscode/settings.json
9 | !.vscode/tasks.json
10 | !.vscode/launch.json
11 | !.vscode/extensions.json
12 |
13 | ### VisualStudioCode Patch ###
14 | # Ignore all local history of files
15 | .history
16 |
17 | ### Windows ###
18 | # Windows thumbnail cache files
19 | Thumbs.db
20 | Thumbs.db:encryptable
21 | ehthumbs.db
22 | ehthumbs_vista.db
23 |
24 | # Dump file
25 | *.stackdump
26 |
27 | # Folder config file
28 | [Dd]esktop.ini
29 |
30 | # Recycle Bin used on file shares
31 | $RECYCLE.BIN/
32 |
33 | # Windows Installer files
34 | *.cab
35 | *.msi
36 | *.msix
37 | *.msm
38 | *.msp
39 |
40 | # Windows shortcuts
41 | *.lnk
42 |
43 | # End of https://www.gitignore.io/api/windows,visualstudiocode
44 |
45 | # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
46 | .vagrant/*
47 | jenkins/*
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Labs
2 |
3 | These are Ansible Labs for the youtube Channel DevOps Journey.
4 |
5 | Each folder corrasponds to a video. Follow along and let's learn ansible together.
6 |
7 | Video Playlist:
8 | https://www.youtube.com/watch?v=KuiAiUyuDY4&list=PLnFWJCugpwfzTlIJ-JtuATD2MBBD7_m3u
9 |
10 | ## How to use these Labs
11 | 1. Install Oracle Virtual Box: https://www.virtualbox.org/
12 |
13 | 2. Install Vagrant: https://www.vagrantup.com/downloads.html
14 |
15 | 3. In a new Directory copy this respository:
16 | ``` shell
17 | git clone https://github.com/bradmorg/ansible-labs.git
18 | ```
19 |
20 | 4. Start the vagrant instance.
21 | ``` shell
22 | vagrant up
23 | ```
24 |
25 | 5. SSH into the ansible-control virtual machine.
26 | ``` shell
27 | vagrant ssh ansible-control
28 | ```
29 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | Vagrant.configure("2") do |config|
2 | servers=[
3 | {
4 | :hostname => "ansible-control",
5 | :box => "bento/ubuntu-18.04",
6 | :ip => "192.168.56.100",
7 | :ssh_port => '2215'
8 | },
9 | {
10 | :hostname => "db01",
11 | :box => "bento/ubuntu-18.04",
12 | :ip => "192.168.56.101",
13 | :ssh_port => '2210'
14 | },
15 | {
16 | :hostname => "web01",
17 | :box => "bento/ubuntu-18.04",
18 | :ip => "192.168.56.102",
19 | :ssh_port => '2211'
20 | },
21 | {
22 | :hostname => "web02",
23 | :box => "bento/ubuntu-18.04",
24 | :ip => "192.168.56.103",
25 | :ssh_port => '2212'
26 | },
27 | {
28 | :hostname => "loadbalancer",
29 | :box => "bento/ubuntu-18.04",
30 | :ip => "192.168.56.104",
31 | :ssh_port => '2213'
32 | }
33 |
34 | ]
35 |
36 | servers.each do |machine|
37 |
38 | config.vm.define machine[:hostname] do |node|
39 | node.vm.box = machine[:box]
40 | node.vm.hostname = machine[:hostname]
41 |
42 | node.vm.network :private_network, ip: machine[:ip]
43 | node.vm.network "forwarded_port", guest: 22, host: machine[:ssh_port], id: "ssh"
44 |
45 | node.vm.provider :virtualbox do |v|
46 | v.customize ["modifyvm", :id, "--memory", 512]
47 | v.customize ["modifyvm", :id, "--name", machine[:hostname]]
48 | end
49 | end
50 | end
51 |
52 | end
--------------------------------------------------------------------------------
/ansible-lab1/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 1 - Installation and Inventory file basics
2 |
3 | 1. Create VMs using vagrant and ssh to our control server
4 | 2. Copy /vagrant/hosts_file to /etc/hosts
5 | 3. Install ansible
6 | 4. Create an inventory file named hosts
7 | 5. Test out a command
8 | 6. Generate SSH Keys and copy to hosts
9 | 7. Test running ad-hoc commands to all hosts
10 | 8. Install python-simplejson module. This allows clients to be fully managed.
11 |
12 | ### Setup Vagrant and connect to ansible-control server
13 | ``` shell
14 | vagrant up
15 | vagrant ssh ansible-control
16 | ```
17 |
18 | ### Copy hosts file on ansible-control
19 | ``` shell
20 | cp /vagrant/hosts_file /etc/hosts
21 | ```
22 |
23 | ### Install Ansible
24 | ``` shell
25 | sudo apt-get install ansible
26 | ```
27 |
28 | ### Create a SSH key and copy to all servers
29 | ``` shell
30 | ssh-keygen
31 | ssh-copy-id localhost
32 | ssh-copy-id web01 && ssh-copy-id web02 && ssh-copy-id loadbalancer && ssh-copy-id db01
33 | ```
34 |
35 | ### Run a ad-hoc command to the webstack group
36 | ``` shell
37 | ansible webstack -i hosts -m command -a hostname
38 | ```
39 |
40 | ### Install python-simplejson
41 | ``` shell
42 | ansible all -i hosts -m command -a 'sudo apt-get -y install python-simplejson'
43 | ```
44 |
--------------------------------------------------------------------------------
/ansible-lab1/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
--------------------------------------------------------------------------------
/ansible-lab2/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 2 - Ad HOC tasks and Modules
2 |
3 |
4 | 1. Use APT module to install services
5 | 2. Use service module to manage services
6 | 3. Use ansible to reboot webstack
7 |
8 | ### Install Services using APT module
9 | https://docs.ansible.com/ansible/latest/modules/apt_module.html
10 | ``` shell
11 | ansible all -i hosts --become -m apt -a "update_cache=yes"
12 | ansible webservers -i hosts --become -m apt -a "name=apache2 state=present"
13 | ansible database -i hosts --become -m apt -a "name=mysql-server state=present"
14 | ```
15 |
16 | ### Restart Services using Service module
17 | https://docs.ansible.com/ansible/latest/modules/service_module.html
18 | ``` shell
19 | ansible database -i hosts -m service -a "name=mysql state=started"
20 | ansible database --become -i hosts -m service -a "name=mysql state=restarted"
21 | ```
22 |
23 | ### Use Ansible to reboot the webstack
24 | ``` shell
25 | ansible webstack -i hosts --become -a "reboot --reboot"
26 | ```
--------------------------------------------------------------------------------
/ansible-lab2/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab3/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 3 - Playbooks and Templates
2 |
3 | 1. Create playbook and look over the details of the YAML file
4 | 2. Create Templates
5 | 3. Run the playbook
6 | 4. Test connectivity to server
7 |
8 | ### Run playbook
9 | ``` shell
10 | ansible-playbook -i hosts -K playbook1.yml
11 | ```
12 |
13 | ### Test Connectivity to server
14 | ``` shell
15 | curl web01:8000
16 | ```
--------------------------------------------------------------------------------
/ansible-lab3/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab3/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | vars:
4 | http_port: 8000
5 | https_port: 4443
6 | html_welcome_msg: "Hello world!"
7 | tasks:
8 | - name: ensure apache is at the latest version
9 | apt:
10 | name: apache2
11 | state: latest
12 |
13 | - name: write the apache2 ports.conf config file
14 | template:
15 | src: templates/ports.conf.j2
16 | dest: /etc/apache2/ports.conf
17 | notify:
18 | - restart apache
19 |
20 | - name: write a basic index.html file
21 | template:
22 | src: templates/index.html.j2
23 | dest: /var/www/html/index.html
24 | notify:
25 | - restart apache
26 |
27 | - name: ensure apache is running
28 | service:
29 | name: apache2
30 | state: started
31 |
32 | handlers:
33 | - name: restart apache
34 | service:
35 | name: apache2
36 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab3/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ html_welcome_msg }}
4 |
5 |
--------------------------------------------------------------------------------
/ansible-lab3/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab4/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 4 - Re-usable playbooks - including and importing
2 |
3 | 1. Move tasks to a tasks subfolder
4 | 2. Move handler to handler subfolder
5 | 3. Run the playbook
6 |
7 | ``` shell
8 | ansible-playbook -i hosts -K playbook1.yml
9 | ```
--------------------------------------------------------------------------------
/ansible-lab4/handlers/main.yml:
--------------------------------------------------------------------------------
1 | - name: restart apache
2 | service:
3 | name: apache2
4 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab4/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab4/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | vars:
4 | http_port: 8000
5 | https_port: 4443
6 | html_welcome_msg: "Hello world!"
7 | tasks:
8 | - import_tasks: tasks/apache2_install.yml
9 |
10 | handlers:
11 | - import_tasks: handlers/main.yml
--------------------------------------------------------------------------------
/ansible-lab4/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 |
4 | - name: write the apache2 ports.conf config file
5 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
6 | notify: restart apache
7 |
8 | - name: write a basic index.html file
9 | template:
10 | src: templates/index.html.j2
11 | dest: /var/www/html/index.html
12 | notify:
13 | - restart apache
14 |
15 | - name: ensure apache is running
16 | service:
17 | name: apache2
18 | state: started
--------------------------------------------------------------------------------
/ansible-lab4/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }}
4 |
5 |
--------------------------------------------------------------------------------
/ansible-lab4/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab5/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 5 - Roles and Ansible Galaxy
2 |
3 | ansible-galaxy allows you to download roles and also provides an excellent default framework for creating your own roles.
4 |
5 | ## Change Playbook so it uses the Role functionality to setup apache2
6 | 1. Use ansible-galaxy to create webserver role scaffolding
7 | 2. Move the tasks to the roles\webserver folder
8 | 3. Run playbook
9 |
10 |
11 | ### Create Apache2 Role, move tasks/handlers/templates to new roles/apache2 structure. Run playbook.
12 | ``` shell
13 | ansible-galaxy init roles/apache2
14 | ansible-playbook -i hosts -K playbook1.yml
15 | ```
16 |
17 | ### Create a 'common' Role and add it to 'web', 'loadbalancer' and 'database' servers
18 |
19 | 1. Use ansible-galaxy to create nginx role scaffolding
20 | 2. Setup tasks/main.yml and tasks/install_tools.yml
21 | 3. Run playbook and test
22 |
23 | ``` shell
24 | ansible-galaxy init roles/nginx
25 | ansible-playbook -i hosts -K playbook1.yml
26 | ```
27 |
28 | ### Create a nginx Role and setup the configuration
29 |
30 | 1. Use ansible-galaxy to create nginx role scaffolding
31 | 2. Setup tasks, handlers and templates
32 |
33 | ``` shell
34 | ansible-galaxy init roles/nginx
35 | ansible-playbook -i hosts -K playbook1.yml
36 | ```
--------------------------------------------------------------------------------
/ansible-lab5/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab5/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | vars:
4 | http_port: 8000
5 | https_port: 4443
6 | html_welcome_msg: "Hello world!"
7 | roles:
8 | - common
9 | - apache2
10 |
11 | - hosts: proxy
12 | become: yes
13 | roles:
14 | - common
15 | - nginx
16 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/webservers
3 | - name: restart apache
4 | service:
5 | name: apache2
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 |
4 | - name: write the apache2 ports.conf config file
5 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
6 | notify: restart apache
7 |
8 | - name: write a basic index.html file
9 | template:
10 | src: templates/index.html.j2
11 | dest: /var/www/html/index.html
12 | notify:
13 | - restart apache
14 |
15 | - name: ensure apache is running
16 | service:
17 | name: apache2
18 | state: started
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/webservers
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }}
4 |
5 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/ansible-lab5/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Common packages"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - pydf
5 | - tree
6 | - open-vm-tools
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 | - include: install_tools.yml
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/ansible-lab5/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 | - name: restart nginx
4 | service: name=nginx state=restarted
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy Nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 |
5 | - name: Remove defaults
6 | file: path="/etc/nginx/sites-enabled/default" state=absent
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 | - include: install_packages.yml
4 | - include: configure_nginx.yml
5 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | upstream webservers {
2 | server 192.168.56.102:8000;
3 | server 192.168.56.103:8000;
4 | }
5 |
6 | server {
7 | listen 80;
8 |
9 | location / {
10 | proxy_pass http://webservers;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/ansible-lab5/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab6/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 6 - Using Tags
2 |
3 | Tags allow you to categorize items in your playbooks and tasks.
4 |
5 | 1. Use --list-tags to see the current tags enabled.
6 | 2. Start adding tags to your playbooks and tasks. Make use of the 'always' keyword for common task of copying hostfile
7 | 3. Use --list-tags again to see the now enabled tags, and see tag inheritance.
8 | 4. Run your playbooks using tags to only run certain items
9 |
10 | ## Check Current Tags
11 | ``` shell
12 | ansible-playbook -i hosts -K playbook1.yml --list-tags
13 | ```
14 |
15 | ## Run Playbook for Specific Tags
16 | ``` shell
17 | ansible-playbook -i hosts -K playbook1.yml --tags configuration
18 | ansible-playbook -i hosts -K playbook1.yml --tags proxy
19 | ```
20 |
21 | ### Notes:
22 |
23 | Tags use "OR" logic, not "AND". If any of your tags match the item will run. You should use unique tags if the item should only be run under specific conditions.
24 |
25 | Special tags: always, never. Meaning "always" run or "never" run unless explicitly told to do so.
26 | Special tag keywords: tagged, untagged and all. By default we run playbooks at -tags all
27 |
--------------------------------------------------------------------------------
/ansible-lab6/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab6/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | vars:
4 | http_port: 8000
5 | https_port: 4443
6 | html_welcome_msg: "Hello world!"
7 | roles:
8 | - common
9 | - apache2
10 | tags:
11 | web
12 |
13 | - hosts: proxy
14 | become: yes
15 | roles:
16 | - common
17 | - nginx
18 | tags:
19 | proxy
20 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/webservers
3 | - name: restart apache
4 | service:
5 | name: apache2
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 | tags: installation
4 |
5 | - name: write the apache2 ports.conf config file
6 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
7 | notify: restart apache
8 | tags: configuration
9 |
10 | - name: write a basic index.html file
11 | template:
12 | src: templates/index.html.j2
13 | dest: /var/www/html/index.html
14 | notify:
15 | - restart apache
16 | tags: configuration
17 |
18 | - name: ensure apache is running
19 | service:
20 | name: apache2
21 | state: started
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/webservers
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }}
4 |
5 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/ansible-lab6/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Common packages"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - pydf
5 | - open-vm-tools
6 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 | - include: install_tools.yml
4 | - include: system_configuration.yml
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/tasks/system_configuration.yml:
--------------------------------------------------------------------------------
1 | - name: "Copy hosts file"
2 | template: src=hosts.j2 dest="/etc/hosts"
3 | tags: always
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | 127.0.0.1 localhost
2 |
3 | 192.168.56.100 ansible-control
4 | 192.168.56.101 db01
5 | 192.168.56.102 web01
6 | 192.168.56.103 web02
7 | 192.168.56.104 loadbalancer
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/ansible-lab6/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 | - name: restart nginx
4 | service: name=nginx state=restarted
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy Nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 | tags: configuration
5 |
6 | - name: Remove defaults
7 | file: path="/etc/nginx/sites-enabled/default" state=absent
8 | tags: configuration
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
5 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 | - include: install_packages.yml
4 | - include: configure_nginx.yml
5 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | upstream webservers {
2 | server 192.168.56.102:8000;
3 | server 192.168.56.103:8000;
4 | }
5 |
6 | server {
7 | listen 80;
8 |
9 | location / {
10 | proxy_pass http://webservers;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/ansible-lab6/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab7/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 7 - Ansible Variables
2 |
3 | Two types of variables. User set and "ansible facts".
4 |
5 | ## Gather ansible facts, these are dynamic variables automatically gathered by ansible
6 | 1. Use setup module to gather facts about a system.
7 | 2. View the output and discovery any useful information
8 | 3. Use {{ ansible_facts['nodename'] }} for the nodename variable for the local host. Add this to the index.html file.
9 | 4. Use a loop to dynamically access the nodename of the two webservers. add this to the mysite configuration of nginx proxy server.
10 |
11 |
12 | ``` shell
13 | ansible -i hosts proxy -m setup >> ansible_facts.json
14 | {{ ansible_facts['nodename'] }}
15 |
16 | {% for host in groups['webservers'] %}
17 | server {{ hostvars[host]['ansible_facts']['nodename'] }}:8000;
18 | {% endfor %}
19 | ```
20 |
21 | ## Move user defined variables to a different location
22 | 1. Move your current variables into the group_vars/all variables
23 | 2. Add these variables to your nginx mysite configuration
24 | 3. Create host_vars folder and make a unique variable for web01
25 |
--------------------------------------------------------------------------------
/ansible-lab7/group_vars/all/common_variables.yml:
--------------------------------------------------------------------------------
1 | http_port: 8000
2 | https_port: 4443
3 | html_welcome_msg: "Hello world!"
4 |
5 | ntp_server: default-time.example.com
6 | dns_server_primary: 8.8.8.8
7 | dns_server_secondary: 8.8.4.4
--------------------------------------------------------------------------------
/ansible-lab7/host_vars/web01.yml:
--------------------------------------------------------------------------------
1 | html_welcome_msg: "I'm Special!"
--------------------------------------------------------------------------------
/ansible-lab7/hosts:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 |
5 | [proxy]
6 | loadbalancer
7 |
8 | [webservers]
9 | web01
10 | web02
11 |
12 | [database]
13 | db01
14 |
15 | [webstack:children]
16 | proxy
17 | web
18 | database
19 |
--------------------------------------------------------------------------------
/ansible-lab7/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | roles:
4 | - common
5 | - apache2
6 | tags:
7 | web
8 |
9 | - hosts: proxy
10 | become: yes
11 | roles:
12 | - common
13 | - nginx
14 | tags:
15 | proxy
16 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/webservers
3 | - name: restart apache
4 | service:
5 | name: apache2
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 | tags: installation
4 |
5 | - name: write the apache2 ports.conf config file
6 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
7 | notify: restart apache
8 | tags: configuration
9 |
10 | - name: write a basic index.html file
11 | template:
12 | src: templates/index.html.j2
13 | dest: /var/www/html/index.html
14 | notify:
15 | - restart apache
16 | tags: configuration
17 |
18 | - name: ensure apache is running
19 | service:
20 | name: apache2
21 | state: started
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/webservers
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }} You have reached the {{ansible_facts['nodename']}} server.
4 |
5 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/ansible-lab7/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Common packages"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - pydf
5 | - open-vm-tools
6 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 | - include: install_tools.yml
4 | - include: system_configuration.yml
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/tasks/system_configuration.yml:
--------------------------------------------------------------------------------
1 | - name: "Copy hosts file"
2 | template: src=hosts.j2 dest="/etc/hosts"
3 | tags: always
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | 127.0.0.1 localhost
2 |
3 | 192.168.56.100 ansible-control
4 | 192.168.56.101 db01
5 | 192.168.56.102 web01
6 | 192.168.56.103 web02
7 | 192.168.56.104 loadbalancer
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/ansible-lab7/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 | - name: restart nginx
4 | service: name=nginx state=restarted
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy Nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 | tags: configuration
5 |
6 | - name: Remove defaults
7 | file: path="/etc/nginx/sites-enabled/default" state=absent
8 | tags: configuration
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
5 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 | - include: install_packages.yml
4 | - include: configure_nginx.yml
5 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | #Dynamic Config for server {{ ansible_facts['nodename'] }}
2 | upstream webservers {
3 | {% for host in groups['webservers'] %}
4 | server {{ hostvars[host]['ansible_facts']['nodename'] }}:{{http_port}};
5 | {% endfor %}
6 | }
7 |
8 | server {
9 | listen 80;
10 |
11 | location / {
12 | proxy_pass http://webservers;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/ansible-lab7/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab8/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 8 - Create a Developement/Production inventory file
2 |
3 | You can have multiple sets of inventories. Let's create a production and developement inventory file and set a variable for them.
4 |
5 | ## Gather ansible facts, these are dynamic variables automatically gathered by ansible
6 | 1. Create inventories directory.
7 | 2. Create an inventory file for dev and production.
8 | 3. Set a enviornement variable and run the playbook.
9 |
10 |
11 | ``` shell
12 | ansible-playbook -i inventories/dev -K playbook1.yml
13 | ansible-playbook -i inventories/prod -K playbook1.yml
14 | ```
15 |
--------------------------------------------------------------------------------
/ansible-lab8/group_vars/all/common_variables.yml:
--------------------------------------------------------------------------------
1 | http_port: 8000
2 | https_port: 4443
3 | html_welcome_msg: "Hello world!"
4 |
5 | ntp_server: default-time.example.com
6 | dns_server_primary: 8.8.8.8
7 | dns_server_secondary: 8.8.4.4
--------------------------------------------------------------------------------
/ansible-lab8/host_vars/web01.yml:
--------------------------------------------------------------------------------
1 | html_welcome_msg: "I'm Special!"
--------------------------------------------------------------------------------
/ansible-lab8/inventories/dev:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=development
21 |
--------------------------------------------------------------------------------
/ansible-lab8/inventories/prod:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=production
21 |
--------------------------------------------------------------------------------
/ansible-lab8/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | roles:
4 | - common
5 | - apache2
6 | tags:
7 | web
8 |
9 | - hosts: proxy
10 | become: yes
11 | roles:
12 | - common
13 | - nginx
14 | tags:
15 | proxy
16 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/webservers
3 | - name: restart apache
4 | service:
5 | name: apache2
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 | tags: installation
4 |
5 | - name: write the apache2 ports.conf config file
6 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
7 | notify: restart apache
8 | tags: configuration
9 |
10 | - name: write a basic index.html file
11 | template:
12 | src: templates/index.html.j2
13 | dest: /var/www/html/index.html
14 | notify:
15 | - restart apache
16 | tags: configuration
17 |
18 | - name: ensure apache is running
19 | service:
20 | name: apache2
21 | state: started
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/webservers
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }} You have reached the {{ansible_facts['nodename']}} server.
4 | You are in the {{myenvironment}} environment.
5 |
6 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/ansible-lab8/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Common packages"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - pydf
5 | - open-vm-tools
6 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 | - include: install_tools.yml
4 | - include: system_configuration.yml
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/tasks/system_configuration.yml:
--------------------------------------------------------------------------------
1 | - name: "Copy hosts file"
2 | template: src=hosts.j2 dest="/etc/hosts"
3 | tags: always
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | 127.0.0.1 localhost
2 |
3 | 192.168.56.100 ansible-control
4 | 192.168.56.101 db01
5 | 192.168.56.102 web01
6 | 192.168.56.103 web02
7 | 192.168.56.104 loadbalancer
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/ansible-lab8/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 | - name: restart nginx
4 | service: name=nginx state=restarted
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy Nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 | tags: configuration
5 |
6 | - name: Remove defaults
7 | file: path="/etc/nginx/sites-enabled/default" state=absent
8 | tags: configuration
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
5 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 | - include: install_packages.yml
4 | - include: configure_nginx.yml
5 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | #Dynamic Config for server {{ ansible_facts['nodename'] }}
2 | upstream webservers {
3 | {% for host in groups['webservers'] %}
4 | server {{ hostvars[host]['ansible_facts']['nodename'] }}:{{http_port}};
5 | {% endfor %}
6 | }
7 |
8 | server {
9 | listen 80;
10 |
11 | location / {
12 | proxy_pass http://webservers;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/ansible-lab8/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab9/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Lab 9 - Add the Database Server
2 |
3 | We've learned a lot so far. Let's see if we can add the mysql role and get a database up and running.
4 |
5 | ## Setup mysql-server on the Database Server
6 | 1. Add python-pip to common installation items.
7 | 2. Create mysql role using ansible-galaxy.
8 | 3. Create tasks and handlers for new mysql role.
9 | 5. Run playbook
10 | 6. Test a mysql connection to database
11 |
12 |
13 | ``` shell
14 | ansible-galaxy init roles/mysql
15 | ansible-playbook -i inventories/prod -K playbook1.yml --tags database
16 | ssh db01
17 | sudo /usr/bin/mysql -u root -p
18 | ```
19 |
--------------------------------------------------------------------------------
/ansible-lab9/group_vars/all/common_variables.yml:
--------------------------------------------------------------------------------
1 | http_port: 8000
2 | https_port: 4443
3 | html_welcome_msg: "Hello world!"
4 |
5 | ntp_server: default-time.example.com
6 | dns_server_primary: 8.8.8.8
7 | dns_server_secondary: 8.8.4.4
--------------------------------------------------------------------------------
/ansible-lab9/host_vars/db01.yml:
--------------------------------------------------------------------------------
1 | mysql_root_password: "root"
--------------------------------------------------------------------------------
/ansible-lab9/host_vars/web01.yml:
--------------------------------------------------------------------------------
1 | html_welcome_msg: "I'm Special!"
--------------------------------------------------------------------------------
/ansible-lab9/inventories/dev:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=development
--------------------------------------------------------------------------------
/ansible-lab9/inventories/prod:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=production
21 |
--------------------------------------------------------------------------------
/ansible-lab9/playbook1.retry:
--------------------------------------------------------------------------------
1 | db01
2 |
--------------------------------------------------------------------------------
/ansible-lab9/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | roles:
4 | - common
5 | - apache2
6 | tags:
7 | web
8 |
9 | - hosts: proxy
10 | become: yes
11 | roles:
12 | - common
13 | - nginx
14 | tags:
15 | proxy
16 |
17 | - hosts: database
18 | become: yes
19 | roles:
20 | - common
21 | - mysql
22 | tags: database
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/webservers
3 | - name: restart apache
4 | service:
5 | name: apache2
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt: name=apache2 state=latest
3 | tags: installation
4 |
5 | - name: write the apache2 ports.conf config file
6 | template: src=templates/ports.conf.j2 dest=/etc/apache2/ports.conf
7 | notify: restart apache
8 | tags: configuration
9 |
10 | - name: write a basic index.html file
11 | template:
12 | src: templates/index.html.j2
13 | dest: /var/www/html/index.html
14 | notify:
15 | - restart apache
16 | tags: configuration
17 |
18 | - name: ensure apache is running
19 | service:
20 | name: apache2
21 | state: started
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/webservers
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ html_welcome_msg }} You have reached the {{ansible_facts['nodename']}} server.
4 | You are in the {{myenvironment}} environment.
5 |
6 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 |
2 | # If you just change the port or add more ports here, you will likely also
3 | # have to change the VirtualHost statement in
4 | # /etc/apache2/sites-enabled/000-default.conf
5 |
6 | Listen {{ http_port }}
7 |
8 |
9 | Listen {{ https_port }}
10 |
11 |
12 |
13 | Listen {{ https_port }}
14 |
15 |
16 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
17 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/ansible-lab9/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Common packages"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - python-pip
5 | - pydf
6 | - open-vm-tools
7 | - libmysqlclient-dev
8 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 | - include: install_tools.yml
4 | - include: system_configuration.yml
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/tasks/system_configuration.yml:
--------------------------------------------------------------------------------
1 | - name: "Copy hosts file"
2 | template: src=hosts.j2 dest="/etc/hosts"
3 | tags: always
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | 127.0.0.1 localhost
2 |
3 | 192.168.56.100 ansible-control
4 | 192.168.56.101 db01
5 | 192.168.56.102 web01
6 | 192.168.56.103 web02
7 | 192.168.56.104 loadbalancer
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/ansible-lab9/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/mysql
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/mysql
3 | - name: restart mysql
4 | service:
5 | name: mysql
6 | state: restarted
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/tasks/install_mysql.yml:
--------------------------------------------------------------------------------
1 | - name: Ensure mysql-server is installed latest version
2 | apt: name=mysql-server state=latest
3 | tags: installation
4 |
5 | - name: Installing python module MySQL-python
6 | pip:
7 | name: MySQL-python
8 | tags: setup
9 |
10 | - name: Ensure mysql-server is running
11 | service:
12 | name: mysql
13 | state: started
14 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/mysql
3 | - include: install_mysql.yml
4 | - include: setup_mysql.yml
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/tasks/setup_mysql.yml:
--------------------------------------------------------------------------------
1 | - name: Create my.cnf configuration file
2 | template: src=templates/my.cnf.j2 dest=/etc/mysql/conf.d/mysql.cnf
3 | notify: restart mysql
4 |
5 | - name: Create database user with name 'bob' and password '12345' with all database privileges
6 | mysql_user:
7 | name: brad
8 | password: 12345
9 | priv: '*.*:ALL'
10 | state: present
11 | tags: mysqldb
12 |
13 | - name: Create a new database with name 'devops_journey'
14 | mysql_db:
15 | name: devops_journey
16 | state: present
17 | tags: mysqldb
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/templates/my.cnf.j2:
--------------------------------------------------------------------------------
1 | [mysql]
2 | bind-address = 0.0.0.0
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/mysql
--------------------------------------------------------------------------------
/ansible-lab9/roles/mysql/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/mysql
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | python: "2.7"
4 |
5 | # Use the new container infrastructure
6 | sudo: false
7 |
8 | # Install ansible
9 | addons:
10 | apt:
11 | packages:
12 | - python-pip
13 |
14 | install:
15 | # Install ansible
16 | - pip install ansible
17 |
18 | # Check ansible version
19 | - ansible --version
20 |
21 | # Create ansible.cfg with correct roles_path
22 | - printf '[defaults]\nroles_path=../' >ansible.cfg
23 |
24 | script:
25 | # Basic role syntax check
26 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27 |
28 | notifications:
29 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 | - name: restart nginx
4 | service: name=nginx state=restarted
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your role description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Choose a valid license ID from https://spdx.org - some suggested licenses:
11 | # - BSD-3-Clause (default)
12 | # - MIT
13 | # - GPL-2.0-or-later
14 | # - GPL-3.0-only
15 | # - Apache-2.0
16 | # - CC-BY-4.0
17 | license: license (GPL-2.0-or-later, MIT, etc)
18 |
19 | min_ansible_version: 2.9
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | #
25 | # Provide a list of supported platforms, and for each platform a list of versions.
26 | # If you don't wish to enumerate all versions for a particular platform, use 'all'.
27 | # To view available platforms and versions (or releases), visit:
28 | # https://galaxy.ansible.com/api/v1/platforms/
29 | #
30 | # platforms:
31 | # - name: Fedora
32 | # versions:
33 | # - all
34 | # - 25
35 | # - name: SomePlatform
36 | # versions:
37 | # - all
38 | # - 1.0
39 | # - 7
40 | # - 99.99
41 |
42 | galaxy_tags: []
43 | # List tags for your role here, one per line. A tag is a keyword that describes
44 | # and categorizes the role. Users find roles by searching for tags. Be sure to
45 | # remove the '[]' above, if you add tags to this list.
46 | #
47 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
48 | # Maximum 20 tags per role.
49 |
50 | dependencies: []
51 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
52 | # if you add dependencies to this list.
53 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy Nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 | tags: configuration
5 |
6 | - name: Remove defaults
7 | file: path="/etc/nginx/sites-enabled/default" state=absent
8 | tags: configuration
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install Nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
5 | tags: installation
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 | - include: install_packages.yml
4 | - include: configure_nginx.yml
5 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | #Dynamic Config for server {{ ansible_facts['nodename'] }}
2 | upstream webservers {
3 | {% for host in groups['webservers'] %}
4 | server {{ hostvars[host]['ansible_facts']['nodename'] }}:{{http_port}};
5 | {% endfor %}
6 | }
7 |
8 | server {
9 | listen 80;
10 |
11 | location / {
12 | proxy_pass http://webservers;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/ansible-lab9/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------
/hosts_file:
--------------------------------------------------------------------------------
1 | 192.168.56.100 ansible-control
2 | 192.168.56.101 db01
3 | 192.168.56.102 web01
4 | 192.168.56.103 web02
5 | 192.168.56.104 loadbalancer
6 |
--------------------------------------------------------------------------------
/lab/ansible_facts.json:
--------------------------------------------------------------------------------
1 | loadbalancer | SUCCESS => {
2 | "ansible_facts": {
3 | "ansible_all_ipv4_addresses": [
4 | "10.0.2.15",
5 | "192.168.56.104"
6 | ],
7 | "ansible_all_ipv6_addresses": [
8 | "fe80::a00:27ff:febc:dca4",
9 | "fe80::a00:27ff:fe81:f09f"
10 | ],
11 | "ansible_apparmor": {
12 | "status": "enabled"
13 | },
14 | "ansible_architecture": "x86_64",
15 | "ansible_bios_date": "12/01/2006",
16 | "ansible_bios_version": "VirtualBox",
17 | "ansible_cmdline": {
18 | "BOOT_IMAGE": "/boot/vmlinuz-4.15.0-72-generic",
19 | "biosdevname": "0",
20 | "net.ifnames": "0",
21 | "quiet": true,
22 | "ro": true,
23 | "root": "/dev/mapper/vagrant--vg-root"
24 | },
25 | "ansible_date_time": {
26 | "date": "2020-03-27",
27 | "day": "27",
28 | "epoch": "1585343057",
29 | "hour": "21",
30 | "iso8601": "2020-03-27T21:04:17Z",
31 | "iso8601_basic": "20200327T210417463329",
32 | "iso8601_basic_short": "20200327T210417",
33 | "iso8601_micro": "2020-03-27T21:04:17.463445Z",
34 | "minute": "04",
35 | "month": "03",
36 | "second": "17",
37 | "time": "21:04:17",
38 | "tz": "UTC",
39 | "tz_offset": "+0000",
40 | "weekday": "Friday",
41 | "weekday_number": "5",
42 | "weeknumber": "12",
43 | "year": "2020"
44 | },
45 | "ansible_default_ipv4": {
46 | "address": "10.0.2.15",
47 | "alias": "eth0",
48 | "broadcast": "10.0.2.255",
49 | "gateway": "10.0.2.2",
50 | "interface": "eth0",
51 | "macaddress": "08:00:27:bc:dc:a4",
52 | "mtu": 1500,
53 | "netmask": "255.255.255.0",
54 | "network": "10.0.2.0",
55 | "type": "ether"
56 | },
57 | "ansible_default_ipv6": {},
58 | "ansible_device_links": {
59 | "ids": {
60 | "dm-0": [
61 | "dm-name-vagrant--vg-root",
62 | "dm-uuid-LVM-ITaUT19Ftzfu4SZ21WBEja2y00zt3TX6Bz7vq9U609NfXIm3uQ6pqnTguAmI3AAv"
63 | ],
64 | "dm-1": [
65 | "dm-name-vagrant--vg-swap_1",
66 | "dm-uuid-LVM-ITaUT19Ftzfu4SZ21WBEja2y00zt3TX6q4oOsBr9022SBbc8ip5bjmddDOSx96du"
67 | ],
68 | "sda": [
69 | "ata-VBOX_HARDDISK_VB2019e386-f8e59238"
70 | ],
71 | "sda1": [
72 | "ata-VBOX_HARDDISK_VB2019e386-f8e59238-part1",
73 | "lvm-pv-uuid-eoDewq-fnYL-mVEv-Qilr-uIxR-mncS-TluLSB"
74 | ]
75 | },
76 | "labels": {},
77 | "masters": {
78 | "sda1": [
79 | "dm-0",
80 | "dm-1"
81 | ]
82 | },
83 | "uuids": {
84 | "dm-0": [
85 | "22c18419-b8a1-453d-9301-905e1b30d82d"
86 | ],
87 | "dm-1": [
88 | "411b955b-233a-4348-8bcb-ce41b8bbc2a6"
89 | ]
90 | }
91 | },
92 | "ansible_devices": {
93 | "dm-0": {
94 | "holders": [],
95 | "host": "",
96 | "links": {
97 | "ids": [
98 | "dm-name-vagrant--vg-root",
99 | "dm-uuid-LVM-ITaUT19Ftzfu4SZ21WBEja2y00zt3TX6Bz7vq9U609NfXIm3uQ6pqnTguAmI3AAv"
100 | ],
101 | "labels": [],
102 | "masters": [],
103 | "uuids": [
104 | "22c18419-b8a1-453d-9301-905e1b30d82d"
105 | ]
106 | },
107 | "model": null,
108 | "partitions": {},
109 | "removable": "0",
110 | "rotational": "1",
111 | "sas_address": null,
112 | "sas_device_handle": null,
113 | "scheduler_mode": "",
114 | "sectors": "132202496",
115 | "sectorsize": "512",
116 | "size": "63.04 GB",
117 | "support_discard": "0",
118 | "vendor": null,
119 | "virtual": 1
120 | },
121 | "dm-1": {
122 | "holders": [],
123 | "host": "",
124 | "links": {
125 | "ids": [
126 | "dm-name-vagrant--vg-swap_1",
127 | "dm-uuid-LVM-ITaUT19Ftzfu4SZ21WBEja2y00zt3TX6q4oOsBr9022SBbc8ip5bjmddDOSx96du"
128 | ],
129 | "labels": [],
130 | "masters": [],
131 | "uuids": [
132 | "411b955b-233a-4348-8bcb-ce41b8bbc2a6"
133 | ]
134 | },
135 | "model": null,
136 | "partitions": {},
137 | "removable": "0",
138 | "rotational": "1",
139 | "sas_address": null,
140 | "sas_device_handle": null,
141 | "scheduler_mode": "",
142 | "sectors": "2007040",
143 | "sectorsize": "512",
144 | "size": "980.00 MB",
145 | "support_discard": "0",
146 | "vendor": null,
147 | "virtual": 1
148 | },
149 | "loop0": {
150 | "holders": [],
151 | "host": "",
152 | "links": {
153 | "ids": [],
154 | "labels": [],
155 | "masters": [],
156 | "uuids": []
157 | },
158 | "model": null,
159 | "partitions": {},
160 | "removable": "0",
161 | "rotational": "1",
162 | "sas_address": null,
163 | "sas_device_handle": null,
164 | "scheduler_mode": "none",
165 | "sectors": "0",
166 | "sectorsize": "512",
167 | "size": "0.00 Bytes",
168 | "support_discard": "4096",
169 | "vendor": null,
170 | "virtual": 1
171 | },
172 | "loop1": {
173 | "holders": [],
174 | "host": "",
175 | "links": {
176 | "ids": [],
177 | "labels": [],
178 | "masters": [],
179 | "uuids": []
180 | },
181 | "model": null,
182 | "partitions": {},
183 | "removable": "0",
184 | "rotational": "1",
185 | "sas_address": null,
186 | "sas_device_handle": null,
187 | "scheduler_mode": "none",
188 | "sectors": "0",
189 | "sectorsize": "512",
190 | "size": "0.00 Bytes",
191 | "support_discard": "0",
192 | "vendor": null,
193 | "virtual": 1
194 | },
195 | "loop2": {
196 | "holders": [],
197 | "host": "",
198 | "links": {
199 | "ids": [],
200 | "labels": [],
201 | "masters": [],
202 | "uuids": []
203 | },
204 | "model": null,
205 | "partitions": {},
206 | "removable": "0",
207 | "rotational": "1",
208 | "sas_address": null,
209 | "sas_device_handle": null,
210 | "scheduler_mode": "none",
211 | "sectors": "0",
212 | "sectorsize": "512",
213 | "size": "0.00 Bytes",
214 | "support_discard": "0",
215 | "vendor": null,
216 | "virtual": 1
217 | },
218 | "loop3": {
219 | "holders": [],
220 | "host": "",
221 | "links": {
222 | "ids": [],
223 | "labels": [],
224 | "masters": [],
225 | "uuids": []
226 | },
227 | "model": null,
228 | "partitions": {},
229 | "removable": "0",
230 | "rotational": "1",
231 | "sas_address": null,
232 | "sas_device_handle": null,
233 | "scheduler_mode": "none",
234 | "sectors": "0",
235 | "sectorsize": "512",
236 | "size": "0.00 Bytes",
237 | "support_discard": "0",
238 | "vendor": null,
239 | "virtual": 1
240 | },
241 | "loop4": {
242 | "holders": [],
243 | "host": "",
244 | "links": {
245 | "ids": [],
246 | "labels": [],
247 | "masters": [],
248 | "uuids": []
249 | },
250 | "model": null,
251 | "partitions": {},
252 | "removable": "0",
253 | "rotational": "1",
254 | "sas_address": null,
255 | "sas_device_handle": null,
256 | "scheduler_mode": "none",
257 | "sectors": "0",
258 | "sectorsize": "512",
259 | "size": "0.00 Bytes",
260 | "support_discard": "0",
261 | "vendor": null,
262 | "virtual": 1
263 | },
264 | "loop5": {
265 | "holders": [],
266 | "host": "",
267 | "links": {
268 | "ids": [],
269 | "labels": [],
270 | "masters": [],
271 | "uuids": []
272 | },
273 | "model": null,
274 | "partitions": {},
275 | "removable": "0",
276 | "rotational": "1",
277 | "sas_address": null,
278 | "sas_device_handle": null,
279 | "scheduler_mode": "none",
280 | "sectors": "0",
281 | "sectorsize": "512",
282 | "size": "0.00 Bytes",
283 | "support_discard": "0",
284 | "vendor": null,
285 | "virtual": 1
286 | },
287 | "loop6": {
288 | "holders": [],
289 | "host": "",
290 | "links": {
291 | "ids": [],
292 | "labels": [],
293 | "masters": [],
294 | "uuids": []
295 | },
296 | "model": null,
297 | "partitions": {},
298 | "removable": "0",
299 | "rotational": "1",
300 | "sas_address": null,
301 | "sas_device_handle": null,
302 | "scheduler_mode": "none",
303 | "sectors": "0",
304 | "sectorsize": "512",
305 | "size": "0.00 Bytes",
306 | "support_discard": "0",
307 | "vendor": null,
308 | "virtual": 1
309 | },
310 | "loop7": {
311 | "holders": [],
312 | "host": "",
313 | "links": {
314 | "ids": [],
315 | "labels": [],
316 | "masters": [],
317 | "uuids": []
318 | },
319 | "model": null,
320 | "partitions": {},
321 | "removable": "0",
322 | "rotational": "1",
323 | "sas_address": null,
324 | "sas_device_handle": null,
325 | "scheduler_mode": "none",
326 | "sectors": "0",
327 | "sectorsize": "512",
328 | "size": "0.00 Bytes",
329 | "support_discard": "0",
330 | "vendor": null,
331 | "virtual": 1
332 | },
333 | "sda": {
334 | "holders": [],
335 | "host": "SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)",
336 | "links": {
337 | "ids": [
338 | "ata-VBOX_HARDDISK_VB2019e386-f8e59238"
339 | ],
340 | "labels": [],
341 | "masters": [],
342 | "uuids": []
343 | },
344 | "model": "VBOX HARDDISK",
345 | "partitions": {
346 | "sda1": {
347 | "holders": [
348 | "vagrant--vg-swap_1",
349 | "vagrant--vg-root"
350 | ],
351 | "links": {
352 | "ids": [
353 | "ata-VBOX_HARDDISK_VB2019e386-f8e59238-part1",
354 | "lvm-pv-uuid-eoDewq-fnYL-mVEv-Qilr-uIxR-mncS-TluLSB"
355 | ],
356 | "labels": [],
357 | "masters": [
358 | "dm-0",
359 | "dm-1"
360 | ],
361 | "uuids": []
362 | },
363 | "sectors": "134213632",
364 | "sectorsize": 512,
365 | "size": "64.00 GB",
366 | "start": "2048",
367 | "uuid": null
368 | }
369 | },
370 | "removable": "0",
371 | "rotational": "1",
372 | "sas_address": null,
373 | "sas_device_handle": null,
374 | "scheduler_mode": "cfq",
375 | "sectors": "134217728",
376 | "sectorsize": "512",
377 | "size": "64.00 GB",
378 | "support_discard": "0",
379 | "vendor": "ATA",
380 | "virtual": 1
381 | }
382 | },
383 | "ansible_distribution": "Ubuntu",
384 | "ansible_distribution_file_parsed": true,
385 | "ansible_distribution_file_path": "/etc/os-release",
386 | "ansible_distribution_file_variety": "Debian",
387 | "ansible_distribution_major_version": "18",
388 | "ansible_distribution_release": "bionic",
389 | "ansible_distribution_version": "18.04",
390 | "ansible_dns": {
391 | "nameservers": [
392 | "127.0.0.53"
393 | ],
394 | "options": {
395 | "edns0": true
396 | }
397 | },
398 | "ansible_domain": "",
399 | "ansible_effective_group_id": 1000,
400 | "ansible_effective_user_id": 1000,
401 | "ansible_env": {
402 | "HOME": "/home/vagrant",
403 | "LANG": "en_US.UTF-8",
404 | "LANGUAGE": "en_US:",
405 | "LOGNAME": "vagrant",
406 | "MAIL": "/var/mail/vagrant",
407 | "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games",
408 | "PWD": "/home/vagrant",
409 | "SHELL": "/bin/bash",
410 | "SHLVL": "1",
411 | "SSH_CLIENT": "192.168.56.100 48130 22",
412 | "SSH_CONNECTION": "192.168.56.100 48130 192.168.56.104 22",
413 | "SSH_TTY": "/dev/pts/0",
414 | "TERM": "cygwin",
415 | "USER": "vagrant",
416 | "XDG_RUNTIME_DIR": "/run/user/1000",
417 | "XDG_SESSION_ID": "13",
418 | "_": "/bin/sh"
419 | },
420 | "ansible_eth0": {
421 | "active": true,
422 | "device": "eth0",
423 | "features": {
424 | "esp_hw_offload": "off [fixed]",
425 | "esp_tx_csum_hw_offload": "off [fixed]",
426 | "fcoe_mtu": "off [fixed]",
427 | "generic_receive_offload": "on",
428 | "generic_segmentation_offload": "on",
429 | "highdma": "off [fixed]",
430 | "hw_tc_offload": "off [fixed]",
431 | "l2_fwd_offload": "off [fixed]",
432 | "large_receive_offload": "off [fixed]",
433 | "loopback": "off [fixed]",
434 | "netns_local": "off [fixed]",
435 | "ntuple_filters": "off [fixed]",
436 | "receive_hashing": "off [fixed]",
437 | "rx_all": "off",
438 | "rx_checksumming": "off",
439 | "rx_fcs": "off",
440 | "rx_udp_tunnel_port_offload": "off [fixed]",
441 | "rx_vlan_filter": "on [fixed]",
442 | "rx_vlan_offload": "on",
443 | "rx_vlan_stag_filter": "off [fixed]",
444 | "rx_vlan_stag_hw_parse": "off [fixed]",
445 | "scatter_gather": "on",
446 | "tcp_segmentation_offload": "on",
447 | "tx_checksum_fcoe_crc": "off [fixed]",
448 | "tx_checksum_ip_generic": "on",
449 | "tx_checksum_ipv4": "off [fixed]",
450 | "tx_checksum_ipv6": "off [fixed]",
451 | "tx_checksum_sctp": "off [fixed]",
452 | "tx_checksumming": "on",
453 | "tx_esp_segmentation": "off [fixed]",
454 | "tx_fcoe_segmentation": "off [fixed]",
455 | "tx_gre_csum_segmentation": "off [fixed]",
456 | "tx_gre_segmentation": "off [fixed]",
457 | "tx_gso_partial": "off [fixed]",
458 | "tx_gso_robust": "off [fixed]",
459 | "tx_ipxip4_segmentation": "off [fixed]",
460 | "tx_ipxip6_segmentation": "off [fixed]",
461 | "tx_lockless": "off [fixed]",
462 | "tx_nocache_copy": "off",
463 | "tx_scatter_gather": "on",
464 | "tx_scatter_gather_fraglist": "off [fixed]",
465 | "tx_sctp_segmentation": "off [fixed]",
466 | "tx_tcp6_segmentation": "off [fixed]",
467 | "tx_tcp_ecn_segmentation": "off [fixed]",
468 | "tx_tcp_mangleid_segmentation": "off",
469 | "tx_tcp_segmentation": "on",
470 | "tx_udp_tnl_csum_segmentation": "off [fixed]",
471 | "tx_udp_tnl_segmentation": "off [fixed]",
472 | "tx_vlan_offload": "on [fixed]",
473 | "tx_vlan_stag_hw_insert": "off [fixed]",
474 | "udp_fragmentation_offload": "off",
475 | "vlan_challenged": "off [fixed]"
476 | },
477 | "hw_timestamp_filters": [],
478 | "ipv4": {
479 | "address": "10.0.2.15",
480 | "broadcast": "10.0.2.255",
481 | "netmask": "255.255.255.0",
482 | "network": "10.0.2.0"
483 | },
484 | "ipv6": [
485 | {
486 | "address": "fe80::a00:27ff:febc:dca4",
487 | "prefix": "64",
488 | "scope": "link"
489 | }
490 | ],
491 | "macaddress": "08:00:27:bc:dc:a4",
492 | "module": "e1000",
493 | "mtu": 1500,
494 | "pciid": "0000:00:03.0",
495 | "promisc": false,
496 | "speed": 1000,
497 | "timestamping": [
498 | "tx_software",
499 | "rx_software",
500 | "software"
501 | ],
502 | "type": "ether"
503 | },
504 | "ansible_eth1": {
505 | "active": true,
506 | "device": "eth1",
507 | "features": {
508 | "esp_hw_offload": "off [fixed]",
509 | "esp_tx_csum_hw_offload": "off [fixed]",
510 | "fcoe_mtu": "off [fixed]",
511 | "generic_receive_offload": "on",
512 | "generic_segmentation_offload": "on",
513 | "highdma": "off [fixed]",
514 | "hw_tc_offload": "off [fixed]",
515 | "l2_fwd_offload": "off [fixed]",
516 | "large_receive_offload": "off [fixed]",
517 | "loopback": "off [fixed]",
518 | "netns_local": "off [fixed]",
519 | "ntuple_filters": "off [fixed]",
520 | "receive_hashing": "off [fixed]",
521 | "rx_all": "off",
522 | "rx_checksumming": "off",
523 | "rx_fcs": "off",
524 | "rx_udp_tunnel_port_offload": "off [fixed]",
525 | "rx_vlan_filter": "on [fixed]",
526 | "rx_vlan_offload": "on",
527 | "rx_vlan_stag_filter": "off [fixed]",
528 | "rx_vlan_stag_hw_parse": "off [fixed]",
529 | "scatter_gather": "on",
530 | "tcp_segmentation_offload": "on",
531 | "tx_checksum_fcoe_crc": "off [fixed]",
532 | "tx_checksum_ip_generic": "on",
533 | "tx_checksum_ipv4": "off [fixed]",
534 | "tx_checksum_ipv6": "off [fixed]",
535 | "tx_checksum_sctp": "off [fixed]",
536 | "tx_checksumming": "on",
537 | "tx_esp_segmentation": "off [fixed]",
538 | "tx_fcoe_segmentation": "off [fixed]",
539 | "tx_gre_csum_segmentation": "off [fixed]",
540 | "tx_gre_segmentation": "off [fixed]",
541 | "tx_gso_partial": "off [fixed]",
542 | "tx_gso_robust": "off [fixed]",
543 | "tx_ipxip4_segmentation": "off [fixed]",
544 | "tx_ipxip6_segmentation": "off [fixed]",
545 | "tx_lockless": "off [fixed]",
546 | "tx_nocache_copy": "off",
547 | "tx_scatter_gather": "on",
548 | "tx_scatter_gather_fraglist": "off [fixed]",
549 | "tx_sctp_segmentation": "off [fixed]",
550 | "tx_tcp6_segmentation": "off [fixed]",
551 | "tx_tcp_ecn_segmentation": "off [fixed]",
552 | "tx_tcp_mangleid_segmentation": "off",
553 | "tx_tcp_segmentation": "on",
554 | "tx_udp_tnl_csum_segmentation": "off [fixed]",
555 | "tx_udp_tnl_segmentation": "off [fixed]",
556 | "tx_vlan_offload": "on [fixed]",
557 | "tx_vlan_stag_hw_insert": "off [fixed]",
558 | "udp_fragmentation_offload": "off",
559 | "vlan_challenged": "off [fixed]"
560 | },
561 | "hw_timestamp_filters": [],
562 | "ipv4": {
563 | "address": "192.168.56.104",
564 | "broadcast": "192.168.56.255",
565 | "netmask": "255.255.255.0",
566 | "network": "192.168.56.0"
567 | },
568 | "ipv6": [
569 | {
570 | "address": "fe80::a00:27ff:fe81:f09f",
571 | "prefix": "64",
572 | "scope": "link"
573 | }
574 | ],
575 | "macaddress": "08:00:27:81:f0:9f",
576 | "module": "e1000",
577 | "mtu": 1500,
578 | "pciid": "0000:00:08.0",
579 | "promisc": false,
580 | "speed": 1000,
581 | "timestamping": [
582 | "tx_software",
583 | "rx_software",
584 | "software"
585 | ],
586 | "type": "ether"
587 | },
588 | "ansible_fips": false,
589 | "ansible_form_factor": "Other",
590 | "ansible_fqdn": "loadbalancer",
591 | "ansible_hostname": "loadbalancer",
592 | "ansible_interfaces": [
593 | "lo",
594 | "eth1",
595 | "eth0"
596 | ],
597 | "ansible_is_chroot": false,
598 | "ansible_kernel": "4.15.0-72-generic",
599 | "ansible_lo": {
600 | "active": true,
601 | "device": "lo",
602 | "features": {
603 | "esp_hw_offload": "off [fixed]",
604 | "esp_tx_csum_hw_offload": "off [fixed]",
605 | "fcoe_mtu": "off [fixed]",
606 | "generic_receive_offload": "on",
607 | "generic_segmentation_offload": "on",
608 | "highdma": "on [fixed]",
609 | "hw_tc_offload": "off [fixed]",
610 | "l2_fwd_offload": "off [fixed]",
611 | "large_receive_offload": "off [fixed]",
612 | "loopback": "on [fixed]",
613 | "netns_local": "on [fixed]",
614 | "ntuple_filters": "off [fixed]",
615 | "receive_hashing": "off [fixed]",
616 | "rx_all": "off [fixed]",
617 | "rx_checksumming": "on [fixed]",
618 | "rx_fcs": "off [fixed]",
619 | "rx_udp_tunnel_port_offload": "off [fixed]",
620 | "rx_vlan_filter": "off [fixed]",
621 | "rx_vlan_offload": "off [fixed]",
622 | "rx_vlan_stag_filter": "off [fixed]",
623 | "rx_vlan_stag_hw_parse": "off [fixed]",
624 | "scatter_gather": "on",
625 | "tcp_segmentation_offload": "on",
626 | "tx_checksum_fcoe_crc": "off [fixed]",
627 | "tx_checksum_ip_generic": "on [fixed]",
628 | "tx_checksum_ipv4": "off [fixed]",
629 | "tx_checksum_ipv6": "off [fixed]",
630 | "tx_checksum_sctp": "on [fixed]",
631 | "tx_checksumming": "on",
632 | "tx_esp_segmentation": "off [fixed]",
633 | "tx_fcoe_segmentation": "off [fixed]",
634 | "tx_gre_csum_segmentation": "off [fixed]",
635 | "tx_gre_segmentation": "off [fixed]",
636 | "tx_gso_partial": "off [fixed]",
637 | "tx_gso_robust": "off [fixed]",
638 | "tx_ipxip4_segmentation": "off [fixed]",
639 | "tx_ipxip6_segmentation": "off [fixed]",
640 | "tx_lockless": "on [fixed]",
641 | "tx_nocache_copy": "off [fixed]",
642 | "tx_scatter_gather": "on [fixed]",
643 | "tx_scatter_gather_fraglist": "on [fixed]",
644 | "tx_sctp_segmentation": "on",
645 | "tx_tcp6_segmentation": "on",
646 | "tx_tcp_ecn_segmentation": "on",
647 | "tx_tcp_mangleid_segmentation": "on",
648 | "tx_tcp_segmentation": "on",
649 | "tx_udp_tnl_csum_segmentation": "off [fixed]",
650 | "tx_udp_tnl_segmentation": "off [fixed]",
651 | "tx_vlan_offload": "off [fixed]",
652 | "tx_vlan_stag_hw_insert": "off [fixed]",
653 | "udp_fragmentation_offload": "off",
654 | "vlan_challenged": "on [fixed]"
655 | },
656 | "hw_timestamp_filters": [],
657 | "ipv4": {
658 | "address": "127.0.0.1",
659 | "broadcast": "host",
660 | "netmask": "255.0.0.0",
661 | "network": "127.0.0.0"
662 | },
663 | "ipv6": [
664 | {
665 | "address": "::1",
666 | "prefix": "128",
667 | "scope": "host"
668 | }
669 | ],
670 | "mtu": 65536,
671 | "promisc": false,
672 | "timestamping": [
673 | "tx_software",
674 | "rx_software",
675 | "software"
676 | ],
677 | "type": "loopback"
678 | },
679 | "ansible_local": {},
680 | "ansible_lsb": {
681 | "codename": "bionic",
682 | "description": "Ubuntu 18.04.3 LTS",
683 | "id": "Ubuntu",
684 | "major_release": "18",
685 | "release": "18.04"
686 | },
687 | "ansible_machine": "x86_64",
688 | "ansible_machine_id": "5977691375994a72af5961c472dd8446",
689 | "ansible_memfree_mb": 130,
690 | "ansible_memory_mb": {
691 | "nocache": {
692 | "free": 371,
693 | "used": 110
694 | },
695 | "real": {
696 | "free": 130,
697 | "total": 481,
698 | "used": 351
699 | },
700 | "swap": {
701 | "cached": 0,
702 | "free": 979,
703 | "total": 979,
704 | "used": 0
705 | }
706 | },
707 | "ansible_memtotal_mb": 481,
708 | "ansible_mounts": [
709 | {
710 | "block_available": 14955134,
711 | "block_size": 4096,
712 | "block_total": 16200089,
713 | "block_used": 1244955,
714 | "device": "/dev/mapper/vagrant--vg-root",
715 | "fstype": "ext4",
716 | "inode_available": 4090408,
717 | "inode_total": 4136960,
718 | "inode_used": 46552,
719 | "mount": "/",
720 | "options": "rw,relatime,errors=remount-ro,data=ordered",
721 | "size_available": 61256228864,
722 | "size_total": 66355564544,
723 | "uuid": "22c18419-b8a1-453d-9301-905e1b30d82d"
724 | }
725 | ],
726 | "ansible_nodename": "loadbalancer",
727 | "ansible_os_family": "Debian",
728 | "ansible_pkg_mgr": "apt",
729 | "ansible_processor": [
730 | "0",
731 | "GenuineIntel",
732 | "Intel(R) Core(TM) i7 CPU 950 @ 3.07GHz"
733 | ],
734 | "ansible_processor_cores": 1,
735 | "ansible_processor_count": 1,
736 | "ansible_processor_threads_per_core": 1,
737 | "ansible_processor_vcpus": 1,
738 | "ansible_product_name": "VirtualBox",
739 | "ansible_product_serial": "NA",
740 | "ansible_product_uuid": "NA",
741 | "ansible_product_version": "1.2",
742 | "ansible_python": {
743 | "executable": "/usr/bin/python",
744 | "has_sslcontext": true,
745 | "type": "CPython",
746 | "version": {
747 | "major": 2,
748 | "micro": 15,
749 | "minor": 7,
750 | "releaselevel": "final",
751 | "serial": 0
752 | },
753 | "version_info": [
754 | 2,
755 | 7,
756 | 15,
757 | "final",
758 | 0
759 | ]
760 | },
761 | "ansible_python_version": "2.7.15+",
762 | "ansible_real_group_id": 1000,
763 | "ansible_real_user_id": 1000,
764 | "ansible_selinux": {
765 | "status": "Missing selinux Python library"
766 | },
767 | "ansible_selinux_python_present": false,
768 | "ansible_service_mgr": "systemd",
769 | "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLJqhS21vA0LMQ4WhXRwGS0YdJuwvmZf19SjtcSLqw5RuM4sqO4AV0583i3yUuc/iM82e613EReXKJlxKKVjcAw=",
770 | "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIAiTtA1ZHUi1dqqxsSP3hRzL3ZcPzqsy53zpaOAqZsFM",
771 | "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQC8h66JfymnUkH7D+84if5LIWXUmVafaXq3Bvh9G8xLS8WbaYYXdg6HuB1ZIEUSZl/rQAylBuLgOj6OW2Hw9qqHGv4Ks1rOb1mJSua8KvP3EUGXo72h9yRAv+n4pLyhyjMEkjmVhaAvazD5IJqCI0yHHasFNx6rdiPjgYfh64SNiBQXfK71praFT7yZ1xK6G+tb78LMM05lQes6KYMD+jXnj83uvxPeTH/TN9ZOmwE5Ft+AsOh8zdLpjX9PAzgbwH4lO6YKLmmEB+cuaNbw9i2oy6CeBMZ2YKN+MFEoUzlOGKaRSSk3TPCfW33KxrXIInZUCFUWZheQVHbiTTZ1AQm/",
772 | "ansible_swapfree_mb": 979,
773 | "ansible_swaptotal_mb": 979,
774 | "ansible_system": "Linux",
775 | "ansible_system_capabilities": [
776 | ""
777 | ],
778 | "ansible_system_capabilities_enforced": "True",
779 | "ansible_system_vendor": "innotek GmbH",
780 | "ansible_uptime_seconds": 4756,
781 | "ansible_user_dir": "/home/vagrant",
782 | "ansible_user_gecos": "vagrant,,,",
783 | "ansible_user_gid": 1000,
784 | "ansible_user_id": "vagrant",
785 | "ansible_user_shell": "/bin/bash",
786 | "ansible_user_uid": 1000,
787 | "ansible_userspace_architecture": "x86_64",
788 | "ansible_userspace_bits": "64",
789 | "ansible_virtualization_role": "guest",
790 | "ansible_virtualization_type": "virtualbox",
791 | "gather_subset": [
792 | "all"
793 | ],
794 | "module_setup": true
795 | },
796 | "changed": false
797 | }
798 |
--------------------------------------------------------------------------------
/lab/group_vars/all/common_variables.yml:
--------------------------------------------------------------------------------
1 | http_port: 8000
2 | https_port: 4443
3 | html_welcome_msg: "Hello world!"
4 |
5 | ntp_server: default-time.example.com
6 | dns_server_primary: 8.8.8.8
7 | dns_server_secondary: 8.8.4.4
--------------------------------------------------------------------------------
/lab/host_vars/web01.yml:
--------------------------------------------------------------------------------
1 | html_welcome_msg: "I'm special!"
--------------------------------------------------------------------------------
/lab/inventories/dev:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=development
--------------------------------------------------------------------------------
/lab/inventories/prod:
--------------------------------------------------------------------------------
1 | [control]
2 | ansible-control
3 |
4 | [proxy]
5 | loadbalancer
6 |
7 | [webservers]
8 | web01
9 | web02
10 |
11 | [database]
12 | db01
13 |
14 | [webstack:children]
15 | proxy
16 | webservers
17 | database
18 |
19 | [all:vars]
20 | myenvironment=production
--------------------------------------------------------------------------------
/lab/playbook1.retry:
--------------------------------------------------------------------------------
1 | db01
2 |
--------------------------------------------------------------------------------
/lab/playbook1.yml:
--------------------------------------------------------------------------------
1 | - hosts: webservers
2 | become: yes
3 | roles:
4 | - common
5 | - apache2
6 | tags:
7 | web
8 |
9 | - hosts: proxy
10 | become: yes
11 | roles:
12 | - common
13 | - nginx
14 | tags:
15 | proxy
16 |
17 | - hosts: database
18 | become: yes
19 | roles:
20 | - common
21 | - mysql
22 | tags: database
--------------------------------------------------------------------------------
/lab/roles/apache2/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/lab/roles/apache2/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/apache2
--------------------------------------------------------------------------------
/lab/roles/apache2/handlers/main.yml:
--------------------------------------------------------------------------------
1 | - name: restart apache
2 | service:
3 | name: apache2
4 | state: restarted
--------------------------------------------------------------------------------
/lab/roles/apache2/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Some suggested licenses:
11 | # - BSD (default)
12 | # - MIT
13 | # - GPLv2
14 | # - GPLv3
15 | # - Apache
16 | # - CC-BY
17 | license: license (GPLv2, CC-BY, etc)
18 |
19 | min_ansible_version: 1.2
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | # Optionally specify the branch Galaxy will use when accessing the GitHub
25 | # repo for this role. During role install, if no tags are available,
26 | # Galaxy will use this branch. During import Galaxy will access files on
27 | # this branch. If Travis integration is configured, only notifications for this
28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch
29 | # (usually master) will be used.
30 | #github_branch:
31 |
32 | #
33 | # platforms is a list of platforms, and each platform has a name and a list of versions.
34 | #
35 | # platforms:
36 | # - name: Fedora
37 | # versions:
38 | # - all
39 | # - 25
40 | # - name: SomePlatform
41 | # versions:
42 | # - all
43 | # - 1.0
44 | # - 7
45 | # - 99.99
46 |
47 | galaxy_tags: []
48 | # List tags for your role here, one per line. A tag is a keyword that describes
49 | # and categorizes the role. Users find roles by searching for tags. Be sure to
50 | # remove the '[]' above, if you add tags to this list.
51 | #
52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
53 | # Maximum 20 tags per role.
54 |
55 | dependencies: []
56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
57 | # if you add dependencies to this list.
--------------------------------------------------------------------------------
/lab/roles/apache2/tasks/apache2_install.yml:
--------------------------------------------------------------------------------
1 | - name: ensure apache is at the latest version
2 | apt:
3 | name: apache2
4 | state: latest
5 | tags: installation
6 |
7 | - name: write the apache2 ports.conf config file
8 | template:
9 | src: templates/ports.conf.j2
10 | dest: /etc/apache2/ports.conf
11 | notify:
12 | - restart apache
13 | tags: configuration
14 |
15 | - name: write the apache2 index.html
16 | template:
17 | src: templates/index.html.j2
18 | dest: /var/www/html/index.html
19 | notify:
20 | - restart apache
21 | tags: configuration
22 |
23 | - name: ensure apache is running
24 | service:
25 | name: apache2
26 | state: started
27 | tags: always
28 |
--------------------------------------------------------------------------------
/lab/roles/apache2/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/apache2
3 | - include: apache2_install.yml
--------------------------------------------------------------------------------
/lab/roles/apache2/templates/index.html.j2:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ html_welcome_msg }}! I'm webserver {{ ansible_facts['nodename'] }}. This is the {{ myenvironment }} environment
5 |
6 |
--------------------------------------------------------------------------------
/lab/roles/apache2/templates/ports.conf.j2:
--------------------------------------------------------------------------------
1 | Listen {{ http_port }}
2 |
3 |
4 | Listen {{ https_port }}
5 |
6 |
7 |
8 | Listen {{ https_port }}
9 |
--------------------------------------------------------------------------------
/lab/roles/apache2/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/lab/roles/apache2/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/apache2
--------------------------------------------------------------------------------
/lab/roles/apache2/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/apache2
--------------------------------------------------------------------------------
/lab/roles/common/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/lab/roles/common/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/common
--------------------------------------------------------------------------------
/lab/roles/common/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/common
--------------------------------------------------------------------------------
/lab/roles/common/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Some suggested licenses:
11 | # - BSD (default)
12 | # - MIT
13 | # - GPLv2
14 | # - GPLv3
15 | # - Apache
16 | # - CC-BY
17 | license: license (GPLv2, CC-BY, etc)
18 |
19 | min_ansible_version: 1.2
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | # Optionally specify the branch Galaxy will use when accessing the GitHub
25 | # repo for this role. During role install, if no tags are available,
26 | # Galaxy will use this branch. During import Galaxy will access files on
27 | # this branch. If Travis integration is configured, only notifications for this
28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch
29 | # (usually master) will be used.
30 | #github_branch:
31 |
32 | #
33 | # platforms is a list of platforms, and each platform has a name and a list of versions.
34 | #
35 | # platforms:
36 | # - name: Fedora
37 | # versions:
38 | # - all
39 | # - 25
40 | # - name: SomePlatform
41 | # versions:
42 | # - all
43 | # - 1.0
44 | # - 7
45 | # - 99.99
46 |
47 | galaxy_tags: []
48 | # List tags for your role here, one per line. A tag is a keyword that describes
49 | # and categorizes the role. Users find roles by searching for tags. Be sure to
50 | # remove the '[]' above, if you add tags to this list.
51 | #
52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
53 | # Maximum 20 tags per role.
54 |
55 | dependencies: []
56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
57 | # if you add dependencies to this list.
--------------------------------------------------------------------------------
/lab/roles/common/tasks/install_tools.yml:
--------------------------------------------------------------------------------
1 | - name: "Install common packeges"
2 | apt: name={{ item }} state=latest
3 | with_items:
4 | - pydf
5 | - tree
6 | - open-vm-tools
7 | - python-pip
8 | tags: installation
9 |
10 |
--------------------------------------------------------------------------------
/lab/roles/common/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/common
3 |
4 | - include: install_tools.yml
5 | - include: system_configuration.yml
--------------------------------------------------------------------------------
/lab/roles/common/tasks/system_configuration.yml:
--------------------------------------------------------------------------------
1 | - name: "Copy hosts file"
2 | template: src=hosts.j2 dest="/etc/hosts"
3 | tags: always
4 |
--------------------------------------------------------------------------------
/lab/roles/common/templates/hosts.j2:
--------------------------------------------------------------------------------
1 | 127.0.0.1 localhost
2 |
3 | 192.168.56.100 ansible-control
4 | 192.168.56.101 db01
5 | 192.168.56.102 web01
6 | 192.168.56.103 web02
7 | 192.168.56.104 loadbalancer
--------------------------------------------------------------------------------
/lab/roles/common/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/lab/roles/common/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/common
--------------------------------------------------------------------------------
/lab/roles/common/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/common
--------------------------------------------------------------------------------
/lab/roles/mysql/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/lab/roles/mysql/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/mysql
--------------------------------------------------------------------------------
/lab/roles/mysql/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/mysql
3 | - name: restart mysql
4 | service:
5 | name: mysql
6 | state: restarted
--------------------------------------------------------------------------------
/lab/roles/mysql/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Some suggested licenses:
11 | # - BSD (default)
12 | # - MIT
13 | # - GPLv2
14 | # - GPLv3
15 | # - Apache
16 | # - CC-BY
17 | license: license (GPLv2, CC-BY, etc)
18 |
19 | min_ansible_version: 1.2
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | # Optionally specify the branch Galaxy will use when accessing the GitHub
25 | # repo for this role. During role install, if no tags are available,
26 | # Galaxy will use this branch. During import Galaxy will access files on
27 | # this branch. If Travis integration is configured, only notifications for this
28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch
29 | # (usually master) will be used.
30 | #github_branch:
31 |
32 | #
33 | # platforms is a list of platforms, and each platform has a name and a list of versions.
34 | #
35 | # platforms:
36 | # - name: Fedora
37 | # versions:
38 | # - all
39 | # - 25
40 | # - name: SomePlatform
41 | # versions:
42 | # - all
43 | # - 1.0
44 | # - 7
45 | # - 99.99
46 |
47 | galaxy_tags: []
48 | # List tags for your role here, one per line. A tag is a keyword that describes
49 | # and categorizes the role. Users find roles by searching for tags. Be sure to
50 | # remove the '[]' above, if you add tags to this list.
51 | #
52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
53 | # Maximum 20 tags per role.
54 |
55 | dependencies: []
56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
57 | # if you add dependencies to this list.
--------------------------------------------------------------------------------
/lab/roles/mysql/tasks/install_mysql.yml:
--------------------------------------------------------------------------------
1 | - name: Ensure mysql-server is installed latest version
2 | apt: name=mysql-server state=latest
3 | tags: installation
4 |
5 | - name: Installing python module PyMySQL which is required to for MySQL setup
6 | pip:
7 | name: PyMySQL
8 | tags: setup
9 |
10 | - name: Ensure mysql-server is running
11 | service:
12 | name: mysql
13 | state: started
--------------------------------------------------------------------------------
/lab/roles/mysql/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/mysql
3 |
4 | - include: install_mysql.yml
5 | - include: setup_mysql.yml
6 |
--------------------------------------------------------------------------------
/lab/roles/mysql/tasks/setup_mysql.yml:
--------------------------------------------------------------------------------
1 | - name: Create my.cnf configuration file
2 | template: src=templates/my.cnf.j2 dest=/etc/mysql/conf.d/mysql.cnf
3 | notify: restart mysql
--------------------------------------------------------------------------------
/lab/roles/mysql/templates/my.cnf.j2:
--------------------------------------------------------------------------------
1 | [mysql]
2 | bind-address = 0.0.0.0
--------------------------------------------------------------------------------
/lab/roles/mysql/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/lab/roles/mysql/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/mysql
--------------------------------------------------------------------------------
/lab/roles/mysql/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/mysql
--------------------------------------------------------------------------------
/lab/roles/nginx/README.md:
--------------------------------------------------------------------------------
1 | Role Name
2 | =========
3 |
4 | A brief description of the role goes here.
5 |
6 | Requirements
7 | ------------
8 |
9 | Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10 |
11 | Role Variables
12 | --------------
13 |
14 | A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
15 |
16 | Dependencies
17 | ------------
18 |
19 | A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
20 |
21 | Example Playbook
22 | ----------------
23 |
24 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
25 |
26 | - hosts: servers
27 | roles:
28 | - { role: username.rolename, x: 42 }
29 |
30 | License
31 | -------
32 |
33 | BSD
34 |
35 | Author Information
36 | ------------------
37 |
38 | An optional section for the role authors to include contact information, or a website (HTML is not allowed).
39 |
--------------------------------------------------------------------------------
/lab/roles/nginx/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for roles/nginx
--------------------------------------------------------------------------------
/lab/roles/nginx/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for roles/nginx
3 |
4 | - name: restart nginx
5 | service: name=nginx state=restarted
6 |
7 |
--------------------------------------------------------------------------------
/lab/roles/nginx/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: your name
3 | description: your description
4 | company: your company (optional)
5 |
6 | # If the issue tracker for your role is not on github, uncomment the
7 | # next line and provide a value
8 | # issue_tracker_url: http://example.com/issue/tracker
9 |
10 | # Some suggested licenses:
11 | # - BSD (default)
12 | # - MIT
13 | # - GPLv2
14 | # - GPLv3
15 | # - Apache
16 | # - CC-BY
17 | license: license (GPLv2, CC-BY, etc)
18 |
19 | min_ansible_version: 1.2
20 |
21 | # If this a Container Enabled role, provide the minimum Ansible Container version.
22 | # min_ansible_container_version:
23 |
24 | # Optionally specify the branch Galaxy will use when accessing the GitHub
25 | # repo for this role. During role install, if no tags are available,
26 | # Galaxy will use this branch. During import Galaxy will access files on
27 | # this branch. If Travis integration is configured, only notifications for this
28 | # branch will be accepted. Otherwise, in all cases, the repo's default branch
29 | # (usually master) will be used.
30 | #github_branch:
31 |
32 | #
33 | # platforms is a list of platforms, and each platform has a name and a list of versions.
34 | #
35 | # platforms:
36 | # - name: Fedora
37 | # versions:
38 | # - all
39 | # - 25
40 | # - name: SomePlatform
41 | # versions:
42 | # - all
43 | # - 1.0
44 | # - 7
45 | # - 99.99
46 |
47 | galaxy_tags: []
48 | # List tags for your role here, one per line. A tag is a keyword that describes
49 | # and categorizes the role. Users find roles by searching for tags. Be sure to
50 | # remove the '[]' above, if you add tags to this list.
51 | #
52 | # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
53 | # Maximum 20 tags per role.
54 |
55 | dependencies: []
56 | # List your role dependencies here, one per line. Be sure to remove the '[]' above,
57 | # if you add dependencies to this list.
--------------------------------------------------------------------------------
/lab/roles/nginx/tasks/configure_nginx.yml:
--------------------------------------------------------------------------------
1 | - name: Deploy nginx sites configuration
2 | template: src=mysite.j2 dest="/etc/nginx/sites-enabled/mysite"
3 | notify: restart nginx
4 | tags: configuration
5 |
6 | - name: Remove defaults
7 | file: path="/etc/nginx/sites-enabled/default" state=absent
8 | tags: configuration
--------------------------------------------------------------------------------
/lab/roles/nginx/tasks/install_packages.yml:
--------------------------------------------------------------------------------
1 | - name: "Install nginx packages"
2 | apt:
3 | name: nginx
4 | state: present
5 | tags: installation, nginx_configuration
6 |
7 |
--------------------------------------------------------------------------------
/lab/roles/nginx/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for roles/nginx
3 |
4 | - include: install_packages.yml
5 | - include: configure_nginx.yml
6 |
--------------------------------------------------------------------------------
/lab/roles/nginx/templates/mysite.j2:
--------------------------------------------------------------------------------
1 | # This configuration is for {{ ansible_facts['nodename'] }}
2 |
3 | upstream webservers {
4 | {% for host in groups['webservers'] %}
5 | server {{ hostvars[host]['ansible_facts']['nodename'] }}:{{ http_port }};
6 | {% endfor %}
7 |
8 |
9 | #server web01:8000;
10 | #server web02:8000;
11 | }
12 |
13 | server {
14 | listen 80;
15 | location / {
16 | proxy_pass http://webservers;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lab/roles/nginx/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/lab/roles/nginx/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - roles/nginx
--------------------------------------------------------------------------------
/lab/roles/nginx/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for roles/nginx
--------------------------------------------------------------------------------