├── Day-28-Roles
├── roles
│ ├── myweb
│ │ ├── tests
│ │ │ ├── inventory
│ │ │ └── test.yml
│ │ ├── vars
│ │ │ └── main.yml
│ │ ├── defaults
│ │ │ └── main.yml
│ │ ├── handlers
│ │ │ └── main.yml
│ │ ├── tasks
│ │ │ └── main.yml
│ │ ├── .travis.yml
│ │ ├── README.md
│ │ └── meta
│ │ │ └── main.yml
│ └── geerlingguy.git
│ │ ├── .ansible-lint
│ │ ├── .gitignore
│ │ ├── vars
│ │ ├── main.yml
│ │ ├── Debian.yml
│ │ ├── RedHat.yml
│ │ └── Fedora.yml
│ │ ├── meta
│ │ ├── .galaxy_install_info
│ │ └── main.yml
│ │ ├── .yamllint
│ │ ├── .github
│ │ ├── FUNDING.yml
│ │ └── stale.yml
│ │ ├── molecule
│ │ └── default
│ │ │ ├── converge.yml
│ │ │ ├── playbook-source.yml
│ │ │ └── molecule.yml
│ │ ├── tasks
│ │ ├── main.yml
│ │ └── install-from-source.yml
│ │ ├── defaults
│ │ └── main.yml
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ └── README.md
├── ansible.cfg
├── inventory
├── role.yaml
├── myweb.yaml
└── site.yaml
├── Day-07-Managing-Ansible-Inventory
├── README.md
├── ansible.cfg
└── inventory
├── Day-08-Running-Ad-Hoc-Commands
└── README.md
├── Day-13-Ansible-Extra-Variables
└── Readme.md
├── z_In_Prog
├── 08-Day-Managing-Facts
│ └── README.md
├── 07-Day-Managing-Variables
│ └── README.md
├── 11-Day-Implementing-Roles
│ └── README.md
├── 09-Day-Task-Control-in-Ansible
│ └── README.md
├── 10-Day-Using-Jinja2-Temaplates
│ └── README.md
└── 12-Day-Deploying-Roles-with-Ansible-Galaxy
│ └── README.md
├── Use-Case-Calling-Role-with-Variable
├── roles
│ └── test-role
│ │ ├── tests
│ │ ├── inventory
│ │ └── test.yml
│ │ ├── vars
│ │ └── main.yml
│ │ ├── defaults
│ │ └── main.yml
│ │ ├── handlers
│ │ └── main.yml
│ │ ├── tasks
│ │ └── main.yml
│ │ ├── .travis.yml
│ │ ├── README.md
│ │ └── meta
│ │ └── main.yml
├── inventory
├── ansible.cfg
└── site.yml
├── .DS_Store
├── Day-14-Ansible-Host-Variables-and-Group-Variables
├── host_vars
│ ├── node2
│ └── node1
├── ansible.cfg
├── inventory
├── vars.yml
├── group_vars
│ └── nodes
├── .user.yaml.swp
├── user.yaml
├── vars2.yaml
└── site.yml
├── Day-26-Blocks
├── ansible.cfg
├── inventory
└── site.yaml
├── Day-27-Jinja2
├── ansible.cfg
├── inventory
├── user_list.j2
├── motd.j2
├── site.yaml
└── system-information.j2.html
├── Day-24-Handlers
├── ansible.cfg
├── inventory
└── site.yaml
├── Use-Case-Vault-Advanced
├── vault-pass-client.py
├── ansible.cfg
├── inventory
├── site.yaml
├── vault.py
├── secret-vars.yaml
└── user-passwd.yaml
├── Day-17-Ansible-Facts
├── ansible.cfg
├── inventory
├── site.yaml
└── set-fact.yaml
├── Day-20-Ansible-Secrets
├── ansible.cfg
├── inventory
├── site.yaml
└── secret-data.yaml
├── Day-25-Task-Failures
├── ansible.cfg
├── inventory
├── changed.yaml
├── site.yaml
├── handler.yaml
└── README.md
├── Day-18-Ansible-Custom-Facts
├── ansible.cfg
├── inventory
└── site.yaml
├── Day-23-Conditional-Execution
├── ansible.cfg
├── inventory
├── user-passwd.yaml
├── task-control-sample2.yaml
└── site.yaml
├── Use-Case-Modify-JSON-YAML
├── ansible.cfg
├── inventory
├── data-var.yaml
└── site.yaml
├── ansible-videos.png
├── Day-12-Managing-Ansible-Variables
├── ansible.cfg
├── inventory
├── vars.yaml
├── .user.yaml.swp
└── site.yml
├── Day-15-Ansible-Variable-Arrays
├── ansible.cfg
├── inventory
├── site.yaml
└── user_list.yaml
├── Day-19-Ansible-Magic-Variables
├── ansible.cfg
├── inventory
└── site.yaml
├── Day-21-Using-Secrets-in-Playbook
├── ansible.cfg
├── inventory
├── site.yaml
└── user-passwd.yaml
├── Day-22-Task-Control-and-Loops
├── ansible.cfg
├── inventory
├── user-passwd.yaml
└── site.yaml
├── Use-Case-Collect-Host-Info
├── ansible.cfg
├── inventory
├── hosts.j2
└── site.yml
├── Day-16-Ansible-Registered-Variables
├── ansible.cfg
├── inventory
├── site2.yaml
└── site.yaml
├── 30-days-of-ansible-3.png
├── Day-29-Parallelism
├── ansible.cfg
├── inventory
└── site.yaml
├── Day-30-Host-Patterns
├── ansible.cfg
├── inventory
└── site.yaml
├── Day-11-Find-Modules-to-Use
└── README.md
├── Day-02-Setup-Your-Lab-Environment-Using-VirtualBox-and-Vagrant
└── README.md
├── Day-01-Introduction-to-Ansible
└── README.md
├── README.md
├── Day-06-Deploying-Ansible
├── ansible.cfg
└── README.md
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── Use-Case-Ansible-Variables
└── README.md
├── Day-10-Remote-User-and-Privilege-Management
└── README.md
├── Day-09-Playbooks
├── site.yaml
└── README.md
├── Day-03-Ansible-Lab-Environment-Using-VirtualBox-and-Vagrant
└── README.md
├── Day-05-Installing-Ansible-on-Linux
└── README.md
├── Day-04-Create-Ansible-Lab-using-Vagrant-and-VirtualBox
└── README.md
└── LICENSE
/Day-28-Roles/roles/myweb/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for myweb
--------------------------------------------------------------------------------
/Day-07-Managing-Ansible-Inventory/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/Day-08-Running-Ad-Hoc-Commands/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/Day-13-Ansible-Extra-Variables/Readme.md:
--------------------------------------------------------------------------------
1 | # Ansible Extra Variables
2 |
--------------------------------------------------------------------------------
/z_In_Prog/08-Day-Managing-Facts/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.ansible-lint:
--------------------------------------------------------------------------------
1 | skip_list:
2 | - '204'
3 |
--------------------------------------------------------------------------------
/z_In_Prog/07-Day-Managing-Variables/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/z_In_Prog/11-Day-Implementing-Roles/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/z_In_Prog/09-Day-Task-Control-in-Ansible/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/z_In_Prog/10-Day-Using-Jinja2-Temaplates/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/Day-07-Managing-Ansible-Inventory/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.gitignore:
--------------------------------------------------------------------------------
1 | *.retry
2 | */__pycache__
3 | *.pyc
4 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/tests/inventory:
--------------------------------------------------------------------------------
1 | localhost
2 |
3 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamgini/30-Days-of-Ansible-Bootcamp/HEAD/.DS_Store
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/host_vars/node2:
--------------------------------------------------------------------------------
1 | ansible_user: vagrant
2 |
--------------------------------------------------------------------------------
/Day-26-Blocks/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/z_In_Prog/12-Day-Deploying-Roles-with-Ansible-Galaxy/README.md:
--------------------------------------------------------------------------------
1 | ## Work in Progress
2 |
3 |
--------------------------------------------------------------------------------
/Day-24-Handlers/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/vault-pass-client.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | print ('password')
4 |
--------------------------------------------------------------------------------
/Day-17-Ansible-Facts/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-20-Ansible-Secrets/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-25-Task-Failures/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This space intentionally left blank.
3 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/vars/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # vars file for test-role
3 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-18-Ansible-Custom-Facts/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-23-Conditional-Execution/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Use-Case-Modify-JSON-YAML/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/ansible-videos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamgini/30-Days-of-Ansible-Bootcamp/HEAD/ansible-videos.png
--------------------------------------------------------------------------------
/Day-12-Managing-Ansible-Variables/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-15-Ansible-Variable-Arrays/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-19-Ansible-Magic-Variables/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-21-Using-Secrets-in-Playbook/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-22-Task-Control-and-Loops/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for test-role
3 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/handlers/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # handlers file for test-role
3 |
--------------------------------------------------------------------------------
/Use-Case-Collect-Host-Info/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-16-Ansible-Registered-Variables/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - myweb
--------------------------------------------------------------------------------
/30-days-of-ansible-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamgini/30-Days-of-Ansible-Bootcamp/HEAD/30-days-of-ansible-3.png
--------------------------------------------------------------------------------
/Day-28-Roles/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
5 | roles_path = roles
6 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/meta/.galaxy_install_info:
--------------------------------------------------------------------------------
1 | {install_date: 'Fri Jun 18 11:19:13 2021', version: 3.0.0}
2 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
--------------------------------------------------------------------------------
/Day-18-Ansible-Custom-Facts/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 |
6 | [myself]
7 | localhost ansible_connection=local
8 |
--------------------------------------------------------------------------------
/Use-Case-Collect-Host-Info/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [myself]
6 | localhost ansible_connection=local
7 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/host_vars/node1:
--------------------------------------------------------------------------------
1 | ansible_user: devops
2 | web_package: nginx
3 | web_service: nginx
4 |
--------------------------------------------------------------------------------
/Day-15-Ansible-Variable-Arrays/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 |
6 | [myself]
7 | localhost ansible_connection=local
8 |
--------------------------------------------------------------------------------
/Day-17-Ansible-Facts/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 | node3
5 |
6 |
7 | [myself]
8 | localhost ansible_connection=local
9 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [myself]
6 | localhost ansible_connection=local
7 |
--------------------------------------------------------------------------------
/Day-12-Managing-Ansible-Variables/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 |
6 | [myself]
7 | localhost ansible_connection=local
8 |
--------------------------------------------------------------------------------
/Day-16-Ansible-Registered-Variables/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 |
6 | [myself]
7 | localhost ansible_connection=local
8 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.yamllint:
--------------------------------------------------------------------------------
1 | ---
2 | extends: default
3 | rules:
4 | line-length:
5 | max: 160
6 | level: warning
7 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
5 | roles_path = ./roles
--------------------------------------------------------------------------------
/Day-29-Parallelism/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
5 | roles_path = roles
6 |
7 | forks = 5
8 |
--------------------------------------------------------------------------------
/Day-30-Host-Patterns/ansible.cfg:
--------------------------------------------------------------------------------
1 | [defaults]
2 | inventory = ./inventory
3 | remote_user = devops
4 |
5 | roles_path = roles
6 |
7 | forks = 5
8 |
--------------------------------------------------------------------------------
/Day-12-Managing-Ansible-Variables/vars.yaml:
--------------------------------------------------------------------------------
1 | web_package: httpd
2 | web_service: httpd
3 | firewall_package: firewalld
4 | firewall_service: firewalld
5 |
--------------------------------------------------------------------------------
/Day-28-Roles/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 |
6 | [myself]
7 | localhost ansible_connection=local
8 |
--------------------------------------------------------------------------------
/Day-24-Handlers/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-26-Blocks/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # defaults file for myweb
3 | web_package: httpd
4 | web_service: httpd
5 | firewall_package: firewalld
6 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/tests/test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | remote_user: root
4 | roles:
5 | - test-role
6 |
--------------------------------------------------------------------------------
/Day-20-Ansible-Secrets/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-25-Task-Failures/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 | ---
3 | github: geerlingguy
4 | patreon: geerlingguy
5 |
--------------------------------------------------------------------------------
/Day-29-Parallelism/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-12-Managing-Ansible-Variables/.user.yaml.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamgini/30-Days-of-Ansible-Bootcamp/HEAD/Day-12-Managing-Ansible-Variables/.user.yaml.swp
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/vars.yml:
--------------------------------------------------------------------------------
1 | web_package: httpd
2 | web_service: httpd
3 | firewall_package: firewalld
4 | firewall_service: firewalld
5 |
--------------------------------------------------------------------------------
/Day-28-Roles/role.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install Git
3 | hosts: node1
4 | become: yes
5 | roles:
6 | - role: geerlingguy.git
7 | - role: mynextrole
8 |
9 |
--------------------------------------------------------------------------------
/Use-Case-Modify-JSON-YAML/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-19-Ansible-Magic-Variables/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-21-Using-Secrets-in-Playbook/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-22-Task-Control-and-Loops/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-23-Conditional-Execution/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/group_vars/nodes:
--------------------------------------------------------------------------------
1 | web_package: httpd
2 | web_service: httpd
3 | firewall_package: firewalld
4 | firewall_service: firewalld
5 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/.user.yaml.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamgini/30-Days-of-Ansible-Bootcamp/HEAD/Day-14-Ansible-Host-Variables-and-Group-Variables/.user.yaml.swp
--------------------------------------------------------------------------------
/Use-Case-Collect-Host-Info/hosts.j2:
--------------------------------------------------------------------------------
1 | SNo., Start, Hostname
2 | {% for hostnode in ansible_play_hosts %}
3 | {{ loop.index }},{{ hostvars[hostnode]['shell_output']['start'] }},{{ hostnode }}
4 | {% endfor %}
5 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/vars/Debian.yml:
--------------------------------------------------------------------------------
1 | ---
2 | git_install_from_source_dependencies:
3 | - libcurl4-gnutls-dev
4 | - libexpat1-dev
5 | - gettext
6 | - libssl-dev
7 | - zlib1g-dev
8 | - build-essential
9 | - gcc
10 |
--------------------------------------------------------------------------------
/Day-15-Ansible-Variable-Arrays/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Create users
3 | hosts: nodes
4 | become: true
5 | vars_files:
6 | - user_list.yaml
7 | tasks:
8 | - name: Show users
9 | debug:
10 | msg: "{{ users }}"
11 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Loop & Task Control
3 | hosts: localhost
4 | gather_facts: false
5 | vars_files:
6 | - secret-vars.yaml
7 | tasks:
8 | - name: Show Message
9 | debug:
10 | msg: "{{ secret_token }}"
11 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/vars/RedHat.yml:
--------------------------------------------------------------------------------
1 | ---
2 | git_install_from_source_dependencies:
3 | - gettext-devel
4 | - expat-devel
5 | - curl-devel
6 | - zlib-devel
7 | - perl-devel
8 | - openssl-devel
9 | - subversion-perl
10 | - make
11 | - gcc
12 |
--------------------------------------------------------------------------------
/Day-15-Ansible-Variable-Arrays/user_list.yaml:
--------------------------------------------------------------------------------
1 | users:
2 | john:
3 | firstname: John
4 | lastname: Smit
5 | designation: Admin
6 | location: London
7 | lind:
8 | firstname: Linda
9 | lastname: Marry
10 | designation: Operator
11 | location: NewYork
12 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/vars/Fedora.yml:
--------------------------------------------------------------------------------
1 | ---
2 | git_install_from_source_dependencies:
3 | - gettext-devel
4 | - expat-devel
5 | - curl-devel
6 | - zlib-devel
7 | - perl-devel
8 | - openssl-devel
9 | - subversion-perl
10 | - make
11 | - gcc
12 | - tar
13 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/user_list.j2:
--------------------------------------------------------------------------------
1 | This is the user list deployed from Ansible
2 | -------------------------------------------
3 | {# For Statement #}
4 | {% for user in users %}
5 | {{ loop.index }}: {{ user }}
6 | {% endfor %}
7 | -------------------------------------------
8 | This is end of user list.
9 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/handlers/main.yml:
--------------------------------------------------------------------------------
1 | - name: restart firewalld
2 | service:
3 | name: firewalld
4 | enabled: true
5 | state: restarted
6 |
7 | - name: restart webservice
8 | service:
9 | name: "{{ web_service }}"
10 | enabled: true
11 | state: restarted
12 |
--------------------------------------------------------------------------------
/Day-18-Ansible-Custom-Facts/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Test Custom Facts
3 | hosts: nodes
4 | tasks:
5 | - name: Get Web details
6 | debug:
7 | msg: "{{ ansible_local.web.web_details.web_port }}"
8 | when: ansible_local.web.business.criticality is defined
9 |
10 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/user.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Create users
3 | hosts: nodes
4 | become: true
5 | vars_files:
6 | - vars2.yaml
7 | tasks:
8 | - name: Show users
9 | debug:
10 | msg: "{{ item.value }}"
11 | with_items: "{{ users }}"
12 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/vars2.yaml:
--------------------------------------------------------------------------------
1 | users:
2 | john:
3 | firstname: John
4 | lastname: Smit
5 | designation: Admin
6 | location: London
7 | lind:
8 | firstname: Linda
9 | lastname: Marry
10 | designation: Operator
11 | location: NewYork
12 |
--------------------------------------------------------------------------------
/Day-11-Find-Modules-to-Use/README.md:
--------------------------------------------------------------------------------
1 | ## How to find Ansible Modules and Plugins to Use
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 |
6 | ```shell
7 | ansible-doc -l
8 | ansible-doc -t TYPE -l
9 | ansible-doc -s yum
10 | ```
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # tasks file for test-role
3 | - debug:
4 | msg: "{{ service }}"
5 |
6 | - name: Using Dict from Main playbook
7 | debug:
8 | msg: "Service Name: {{ service.name }}, Service Port: {{ service.port }}"
9 | with_items: "{{ service }}"
--------------------------------------------------------------------------------
/Day-16-Ansible-Registered-Variables/site2.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Run a Command
3 | hosts: nodes
4 | become: true
5 | tasks:
6 | - name: Check Uptime
7 | shell: 'uptime'
8 | register: shell_output
9 |
10 | - name: Print the output
11 | debug:
12 | msg: "{{ shell_output.stdout_lines }}"
13 |
--------------------------------------------------------------------------------
/Day-17-Ansible-Facts/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Ansible Fact Demo
3 | hosts: nodes
4 | gather_facts: false
5 | tasks:
6 | - name: collect facts
7 | setup:
8 | - name: Show details
9 | debug:
10 | msg: "{{ ansible_distribution }} {{ ansible_hostname }} {{ ansible_default_ipv4['address'] }}"
11 |
--------------------------------------------------------------------------------
/Day-21-Using-Secrets-in-Playbook/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Using Secrets in Playbook
3 | hosts: nodes
4 | become: true
5 | vars_files:
6 | - user-passwd.yaml
7 | tasks:
8 | - name: Create User
9 | user:
10 | name: "{{ username }}"
11 | password: "{{ passwd | password_hash('sha256') }}"
12 |
--------------------------------------------------------------------------------
/Day-07-Managing-Ansible-Inventory/inventory:
--------------------------------------------------------------------------------
1 | [myself]
2 | localhost
3 |
4 | [webservers]
5 | servera
6 | serverb
7 | serverc
8 |
9 | [database]
10 | db1
11 | db2
12 | db3
13 |
14 | [servers:children]
15 | database
16 | webservers
17 |
18 | [somanyservers]
19 | db[a:f].example.com
20 |
21 | [manyips]
22 | 192.168.0.[10:20]
23 |
--------------------------------------------------------------------------------
/Day-02-Setup-Your-Lab-Environment-Using-VirtualBox-and-Vagrant/README.md:
--------------------------------------------------------------------------------
1 | ## Setup Your Lab Environment
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Before you install Ansible](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=BjwVE8bWrMU)
--------------------------------------------------------------------------------
/Day-25-Task-Failures/changed.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Changed_when
3 | hosts: nodes
4 | become: true
5 | tasks:
6 | - name: Uptime
7 | shell: uptime
8 | register: uptime_message
9 | changed_when: "'Success' in uptime_message"
10 |
11 | - name: Print message
12 | debug:
13 | msg: "{{ uptime_message }}"
14 | failed_when: not myvariable is defined
15 |
--------------------------------------------------------------------------------
/Day-20-Ansible-Secrets/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Learn Magic Variables
3 | hosts: nodes
4 | gather_facts: false
5 | tasks:
6 | - name: Show Inventory Host Name
7 | debug:
8 | msg: "{{ inventory_hostname }}"
9 | - name: Show Group
10 | debug:
11 | msg: "{{ group_names }}"
12 |
13 | - name: Show Host Variable
14 | debug:
15 | msg: "{{ hostvars }}"
16 |
--------------------------------------------------------------------------------
/Day-01-Introduction-to-Ansible/README.md:
--------------------------------------------------------------------------------
1 | ## Introduction to Ansible
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Ansible Introduction](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=K4wGqwS2RLw)
6 |
7 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
8 |
--------------------------------------------------------------------------------
/Day-19-Ansible-Magic-Variables/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Learn Magic Variables
3 | hosts: nodes
4 | gather_facts: false
5 | tasks:
6 | - name: Show Inventory Host Name
7 | debug:
8 | msg: "{{ inventory_hostname }}"
9 | - name: Show Group
10 | debug:
11 | msg: "{{ group_names }}"
12 |
13 | - name: Show Host Variable
14 | debug:
15 | msg: "{{ hostvars }}"
16 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/vault.py:
--------------------------------------------------------------------------------
1 | import subprocess
2 | from subprocess import Popen, PIPE
3 | mypass = "password"
4 | runansible = subprocess.run(['ansible-playbook', 'site.yaml', '--ask-vault-pass'], stdin=PIPE)
5 | Popen.communicate('mypass\n'.encode())
6 |
7 | #import pexpect
8 | #child = pexpect.spawn('ansible-playbook main.yml --ask-vault-pass')
9 | #child.expect('password')
10 | #child.sendline('test')
11 | #child.interact()
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/molecule/default/converge.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Converge
3 | hosts: all
4 | become: true
5 |
6 | vars:
7 | git_install_from_source: false
8 | git_install_path: /usr/local
9 |
10 | pre_tasks:
11 | - name: Update apt cache.
12 | apt: update_cache=true cache_valid_time=600
13 | when: ansible_os_family == 'Debian'
14 | changed_when: false
15 |
16 | roles:
17 | - role: geerlingguy.git
18 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/motd.j2:
--------------------------------------------------------------------------------
1 | Welcome to {{ ansible_facts.hostname }}
2 | (IP Address: {{ ansible_facts.default_ipv4.address }})
3 |
4 | Access is restricted; if you are not authorized to use it
5 | please logout from this system
6 |
7 | If you have any issues, please contact {{ system_admin_email }}.
8 | Phone: {{ system_admin_phone | default('1800 1111 2222') }}
9 |
10 | -------------------------------------
11 | This message is configured by Ansible
12 | -------------------------------------
13 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/molecule/default/playbook-source.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Converge
3 | hosts: all
4 | become: true
5 |
6 | vars:
7 | git_install_from_source: true
8 | git_install_from_source_force_update: true
9 | git_version: "2.26.0"
10 |
11 | pre_tasks:
12 | - name: Update apt cache.
13 | apt: update_cache=true cache_valid_time=600
14 | when: ansible_os_family == 'Debian'
15 | changed_when: false
16 |
17 | roles:
18 | - role: geerlingguy.git
19 |
--------------------------------------------------------------------------------
/Day-16-Ansible-Registered-Variables/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install Web Package
3 | hosts: nodes
4 | become: true
5 | tasks:
6 | - name: Install nginx
7 | yum:
8 | name: nginx
9 | state: latest
10 | register: yum_output
11 | ignore_errors: yes
12 |
13 | - name: Print the output
14 | debug:
15 | msg: "{{ yum_output }}"
16 |
17 | - name: Print if Failed
18 | debug:
19 | msg: "Package Failed To Install"
20 | when: yum_output.failed == true
21 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Using Jinja2
2 | hosts: nodes
3 | become: yes
4 | vars:
5 | system_admin_email: admin@lab.local
6 | #system_admin_phone: '1800 0000 0000'
7 | users:
8 | - John
9 | - Lisa
10 | - Raj
11 | - Vinod
12 | - Gini
13 | tasks:
14 | - name: Deploy motd
15 | template:
16 | dest: /etc/motd
17 | src: motd.j2
18 | - name: Deploy user list
19 | template:
20 | dest: /tmp/user_list
21 | src: user_list.j2
22 |
23 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/secret-vars.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 33353765623865316562373064373162643066346364343535346636303938326235623962363735
3 | 3931646534623135613634373563343036323665636339380a303563336438623039383931313733
4 | 64623361353562636635653461386439326162376661366361616466613137656535363561373235
5 | 3333383364343030650a353965383635613265346664633330656165363537613861633561626662
6 | 66633839333539643366333432326135653431313339373638353538396634613362356262346633
7 | 6238623536613964353131316431303934303866663431343563
8 |
--------------------------------------------------------------------------------
/Use-Case-Vault-Advanced/user-passwd.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 66386266656262333439656535373964323962353938316631333435353363313862363236323138
3 | 3663313132356163313562373836363465663865636162350a646134383036333566653133656337
4 | 36666632623430323232363964643634633032373465336663656531306339663365376163303036
5 | 3563316364303534660a306633616665353463323237393838666663363764383537653362383135
6 | 39383233386238396134653332313130363466623832653363643937653636376233356633623533
7 | 3965613164323938653163663336356335353261346364393032
8 |
--------------------------------------------------------------------------------
/Day-22-Task-Control-and-Loops/user-passwd.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 66386266656262333439656535373964323962353938316631333435353363313862363236323138
3 | 3663313132356163313562373836363465663865636162350a646134383036333566653133656337
4 | 36666632623430323232363964643634633032373465336663656531306339663365376163303036
5 | 3563316364303534660a306633616665353463323237393838666663363764383537653362383135
6 | 39383233386238396134653332313130363466623832653363643937653636376233356633623533
7 | 3965613164323938653163663336356335353261346364393032
8 |
--------------------------------------------------------------------------------
/Day-23-Conditional-Execution/user-passwd.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 66386266656262333439656535373964323962353938316631333435353363313862363236323138
3 | 3663313132356163313562373836363465663865636162350a646134383036333566653133656337
4 | 36666632623430323232363964643634633032373465336663656531306339663365376163303036
5 | 3563316364303534660a306633616665353463323237393838666663363764383537653362383135
6 | 39383233386238396134653332313130363466623832653363643937653636376233356633623533
7 | 3965613164323938653163663336356335353261346364393032
8 |
--------------------------------------------------------------------------------
/Day-21-Using-Secrets-in-Playbook/user-passwd.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 66386266656262333439656535373964323962353938316631333435353363313862363236323138
3 | 3663313132356163313562373836363465663865636162350a646134383036333566653133656337
4 | 36666632623430323232363964643634633032373465336663656531306339663365376163303036
5 | 3563316364303534660a306633616665353463323237393838666663363764383537653362383135
6 | 39383233386238396134653332313130363466623832653363643937653636376233356633623533
7 | 3965613164323938653163663336356335353261346364393032
8 |
--------------------------------------------------------------------------------
/Use-Case-Collect-Host-Info/site.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Collect the Uptime of hosts in CSV Format
3 | hosts: "{{ hostlist }}"
4 | tasks:
5 | - name: Check hosts uptime
6 | shell: 'uptime'
7 | register: shell_output
8 |
9 | - name: Display Uptime
10 | debug:
11 | msg: "{{ hostvars[inventory_hostname]['shell_output']['start'] }}"
12 |
13 | - name: Generate Report
14 | template:
15 | src: hosts.j2
16 | dest: /tmp/host_report.csv
17 | delegate_to: localhost
18 | run_once: yes
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 30-days-of-ansible-bootcamp
2 |
3 | **Ansible Learning BootCamp**
4 |
5 | My intension is to cover end-to-end topic for Ansible and enable the user to start with Automation usecases at their work.
6 |
7 |
8 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
9 |
10 | [](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
11 |
12 |
13 | Subscribe to **[techbeatly YouTube Channel](https://www.youtube.com/techbeatly)**.
14 |
15 |
--------------------------------------------------------------------------------
/Day-30-Host-Patterns/inventory:
--------------------------------------------------------------------------------
1 | [nodes]
2 | node1
3 | node2
4 |
5 | [newnodes]
6 | node1
7 |
8 | [myself]
9 | localhost ansible_connection=local
10 |
11 | web.lab.local
12 | data.lab.local
13 |
14 | [lab]
15 | labhost1.lab.local
16 | labhost2.lab.local
17 |
18 | [test]
19 | test1.lab.local
20 | test2.lab.local
21 |
22 | [datacenter1]
23 | labhost1.lab.local
24 | test1.lab.local
25 |
26 | [datacenter2]
27 | labhost2.lab.local
28 | test2.lab.local
29 |
30 | [datacenter:children]
31 | datacenter1
32 | datacenter2
33 |
34 | [new]
35 | 192.168.2.1
36 | 192.168.2.2
37 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/molecule/default/molecule.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependency:
3 | name: galaxy
4 | driver:
5 | name: docker
6 | lint: |
7 | set -e
8 | yamllint .
9 | ansible-lint
10 | platforms:
11 | - name: instance
12 | image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
13 | command: ${MOLECULE_DOCKER_COMMAND:-""}
14 | volumes:
15 | - /sys/fs/cgroup:/sys/fs/cgroup:ro
16 | privileged: true
17 | pre_build_image: true
18 | provisioner:
19 | name: ansible
20 | playbooks:
21 | converge: ${MOLECULE_PLAYBOOK:-converge.yml}
22 |
--------------------------------------------------------------------------------
/Day-06-Deploying-Ansible/ansible.cfg:
--------------------------------------------------------------------------------
1 | [Defaults]
2 | #inventory file location
3 | inventory = ./inventory
4 |
5 | #which user credential ansible has to use to connect to host
6 | remote_user = someuser
7 |
8 | #whether it should ask for "someuser" password"
9 | ask_pass = false
10 |
11 | [privilege_escalation]
12 | #enable privilege escalation
13 | become = true
14 |
15 | #set to use sudo for privilege escalation
16 | become_method = sudo
17 |
18 | #privilege escalation user
19 | become_user = root
20 |
21 | #enable prompting for the privilege escalation password
22 | become_ask_pass = true
--------------------------------------------------------------------------------
/Day-20-Ansible-Secrets/secret-data.yaml:
--------------------------------------------------------------------------------
1 | $ANSIBLE_VAULT;1.1;AES256
2 | 31616433613339313435326636313232633864396165663266383631346665633935396335333364
3 | 3362366561363562343132353962393061646537393337330a373733363666626162383964313836
4 | 37393834643762663461303837363465346633653630356535343234323765386131373365323330
5 | 6335373531643334660a623666613936663634356533623335373731366262613331616231316162
6 | 63316163323135663962383034646161343366326163396461303965383930396430643831343134
7 | 35366535316562633561656330353835366638653466623938326132326431633335656434313930
8 | 346536643864386561373765613062623363
9 |
--------------------------------------------------------------------------------
/Day-28-Roles/myweb.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: nodes
3 | become: yes
4 | vars:
5 | web_package: nginx
6 | web_service: nginx
7 | tasks:
8 | - name: remove existing package
9 | yum:
10 | name:
11 | - httpd
12 | - nginx
13 | state: absent
14 |
15 | - name: myweb role
16 | include_role:
17 | name: myweb
18 |
19 | - name: Test intranet web server
20 | hosts: localhost
21 | become: no
22 | tasks:
23 | - name: connect to intranet webserver
24 | uri:
25 | url: http://node1
26 | status_code: 200
27 |
--------------------------------------------------------------------------------
/Day-23-Conditional-Execution/task-control-sample2.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Task Control based on String Value
3 | hosts: localhost
4 | gather_facts: false
5 | vars:
6 | ftp_word: " FTP "
7 | sftp_word: " SFTP "
8 | comment: "Install SFTP Server"
9 | tasks:
10 | - name: Ensure FTP Installed
11 | debug:
12 | msg: "Installing FTP Server....."
13 | when: (ftp_word in comment) or (ftp_word | lower in comment)
14 |
15 | - name: Ensure SFTP Installed
16 | debug:
17 | msg: "Installing SFTP Server....."
18 | when: (sftp_word in comment) or (sftp_word | lower in comment)
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/meta/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | dependencies: []
3 |
4 | galaxy_info:
5 | author: geerlingguy
6 | description: Git version control software
7 | company: "Midwestern Mac, LLC"
8 | license: "license (BSD, MIT)"
9 | min_ansible_version: 2.5
10 | platforms:
11 | - name: EL
12 | versions:
13 | - all
14 | - name: Fedora
15 | versions:
16 | - all
17 | - name: Debian
18 | versions:
19 | - all
20 | - name: Ubuntu
21 | versions:
22 | - all
23 | galaxy_tags:
24 | - development
25 | - system
26 | - git
27 | - vcs
28 | - source
29 | - code
30 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/tasks/main.yml:
--------------------------------------------------------------------------------
1 | - name: Install httpd and firewalld
2 | yum:
3 | name:
4 | - "{{ web_package }}"
5 | - "{{ firewall_package }}"
6 | state: latest
7 | notify:
8 | - restart webservice
9 | - restart firewalld
10 |
11 | - name: firewalld permitt httpd service
12 | firewalld:
13 | #service: http
14 | port: 80/tcp
15 | permanent: true
16 | state: enabled
17 | immediate: yes
18 | notify:
19 | - restart webservice
20 | - restart firewalld
21 |
22 | - name: Test html page is installed
23 | copy:
24 | content: "Welcome to the example.com intranet!\n"
25 | dest: /var/www/html/index.html
26 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/.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/
--------------------------------------------------------------------------------
/Day-17-Ansible-Facts/set-fact.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Ansible Fact Demo
3 | hosts: nodes
4 | gather_facts: false
5 | tasks:
6 | - name: Set username for node2
7 | set_fact:
8 | ansible_user: "adminuser"
9 | ansible_password: "adminpassword"
10 | when: inventory_hostname == 'node2'
11 |
12 | - name: Show host vars node2
13 | debug:
14 | msg: "{{ hostvars['node2'] }}"
15 | when: inventory_hostname == 'node2'
16 |
17 | - name: Show User of node2
18 | shell: 'whoami;id'
19 | when: inventory_hostname == 'node2'
20 | register: node2_data
21 |
22 | - name: Node2 Data
23 | debug:
24 | msg: "{{ node2_data }}"
25 |
26 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/.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/
--------------------------------------------------------------------------------
/Day-25-Task-Failures/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Package Installation
2 | hosts: nodes
3 | become: yes
4 | tasks:
5 | - name: Install wrong package
6 | yum:
7 | name: wrongpackage
8 | state: present
9 | ignore_errors: yes
10 | register: error_message
11 |
12 | - name: Display
13 | debug:
14 | msg: "{{ error_message }}"
15 |
16 | - name: Fail if there is failed status
17 | fail:
18 | msg: "The state is failed"
19 | when: error_message.failed == True
20 |
21 |
22 | - name: Install good package
23 | yum:
24 | name: httpd
25 | state: present
26 |
27 | - name: Message
28 | debug:
29 | msg: "Package Done"
30 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Ensure git is installed (RedHat).
3 | package:
4 | name: "{{ git_packages }}"
5 | state: present
6 | enablerepo: "{{ git_enablerepo | default(omit, true) }}"
7 | when:
8 | - not git_install_from_source | bool
9 | - ansible_os_family == 'RedHat'
10 |
11 | - name: Update apt cache (Debian).
12 | apt: update_cache=true cache_valid_time=86400
13 | when: ansible_os_family == 'Debian'
14 |
15 | - name: Ensure git is installed (Debian).
16 | apt:
17 | name: "{{ git_packages }}"
18 | state: present
19 | when:
20 | - not git_install_from_source | bool
21 | - ansible_os_family == 'Debian'
22 |
23 | - import_tasks: install-from-source.yml
24 | when: git_install_from_source | bool
25 |
--------------------------------------------------------------------------------
/Day-22-Task-Control-and-Loops/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Loop & Task Control
3 | hosts: nodes
4 | become: true
5 | vars:
6 | userlist:
7 | - user101
8 | - user102
9 | - user103
10 | tasks:
11 | - name: Show users
12 | debug:
13 | msg: "{{ item }}"
14 | with_list: "{{ userlist }}"
15 |
16 | - name: Create users
17 | user:
18 | name: "{{ item }}"
19 | with_list: "{{ userlist }}"
20 |
21 | - name: Install Packages
22 | yum:
23 | name:
24 | - httpd
25 | - firewalld
26 | state: present
27 | - name: Enable Service
28 | service:
29 | name: "{{ item }}"
30 | state: started
31 | enabled: true
32 | loop:
33 | - httpd
34 | - firewalld
35 |
36 |
--------------------------------------------------------------------------------
/Use-Case-Ansible-Variables/README.md:
--------------------------------------------------------------------------------
1 | ## Managing Variables in Ansible
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | **Variable Naming**
6 |
7 | | Valid Variable Names | Invalid Names |
8 | | ----------- | ----------- |
9 | | file_name | file name |
10 | | new_server | new.server |
11 | | webserver_1 | 1st webserver |
12 | | router_ip_101 | router-ip-$1 |
13 |
14 |
15 | **Defining Variables**
16 |
17 | You can define variables at different levels in Ansible projects
18 | - Global Scope – when you set variables in Ansible configuration or via command line.
19 | - Play Scope – set in the play
20 | - Host Scope – when you set variables for hosts or groups inside inventory, fact gathering or registered tasks.
21 |
22 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/site.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Calling Role with Dict Variable
3 | hosts: "{{ hostlist }}"
4 | gather_facts: false
5 | vars:
6 | service_list:
7 | tomcat:
8 | name: tomcat
9 | port: 8080
10 | nexus:
11 | name: nexus
12 | port: 8282
13 | tasks:
14 | - debug:
15 | msg: "{{ service_item.value }}"
16 | loop: "{{ lookup('dict', service_list) }}"
17 |
18 | loop_control:
19 | loop_var: service_item
20 |
21 | - name: "Calling Start Service Role"
22 | include_role:
23 | name: test-role
24 | vars:
25 | service: "{{ service_item }}"
26 | #with_items: "{{ service_list }}"
27 | loop: "{{ lookup('dict', service_list) }}"
28 | loop_control:
29 | loop_var: service_item
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/defaults/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | workspace: /root
3 |
4 | # If git_install_from_source is set to false, these two variables define whether
5 | # to use an additional repo for the package installation, and which git packages
6 | # will be installed.
7 | git_enablerepo: ""
8 | git_packages:
9 | - git
10 |
11 | # If set to TRUE, git will be installed from source, using the version set with
12 | # the 'git_version' variable instead of using a package.
13 | git_install_from_source: false
14 | git_install_path: "/usr"
15 | git_version: "2.26.0"
16 |
17 | # If git is already installed at and older version, force a new source build.
18 | # Only applies if git_install_from_source is `true`.
19 | git_install_from_source_force_update: false
20 |
21 | # Leave this at it's default.
22 | git_reinstall_from_source: false
23 |
--------------------------------------------------------------------------------
/Day-26-Blocks/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Package Installation
2 | hosts: nodes
3 | become: yes
4 | tasks:
5 | - name: Say hello
6 | debug:
7 | msg: "Hello"
8 |
9 | - name: Install some packages
10 | yum:
11 | name: nginx
12 | state: present
13 |
14 | - block:
15 | - name: Show Message
16 | debug:
17 | msg: "Trying httpd"
18 |
19 | - name: Install Package
20 | yum:
21 | name: httpd-wrong
22 | state: present
23 | rescue:
24 | - name: Show error
25 | debug:
26 | msg: "Unknown Package"
27 | - name: Install nginx
28 | yum:
29 | name: nginx
30 | state: latest
31 |
32 | always:
33 | - name: Message
34 | debug:
35 | msg: "Playbook Done"
36 |
--------------------------------------------------------------------------------
/Day-10-Remote-User-and-Privilege-Management/README.md:
--------------------------------------------------------------------------------
1 | ## Remote User and Privilege Managemet
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | **Inside `ansible.cfg`**
6 |
7 | ```shell
8 | [privilege_escalation]
9 | ## enable privilege escalation
10 | become = true
11 |
12 | ## set to use sudo for privilege escalation
13 | become_method = sudo
14 |
15 | ## privilege escalation user
16 | become_user = root
17 |
18 | ## enable prompting for the privilege escalation password
19 | become_ask_pass = true
20 | ```
21 | **Inside Playbook**
22 |
23 | ```shell
24 | - name: Enable Intranet Services
25 | hosts: node1.techbeatly.com
26 | become: yes
27 | tasks:
28 | - name: Install httpd and firewalld
29 | yum:
30 | .
31 | .
32 | ```
33 |
34 | **Inside Inventory**
35 |
36 | ```shell
37 | ansible_user: myuser
38 | ansible_become: yes
39 | ansible_become_method: enable
40 | ```
--------------------------------------------------------------------------------
/Use-Case-Modify-JSON-YAML/data-var.yaml:
--------------------------------------------------------------------------------
1 | Company:
2 | Country:
3 | states:
4 | - employee:
5 | Internal_1:
6 | payroll_emp:
7 | key_1: val_1
8 | key_2: val_2
9 | id: 1000
10 | CWF:
11 | on-shore:
12 | key_1: val_1
13 | key_2: val_2
14 | id: 1001
15 | Internal_2:
16 | payroll_emp:
17 | key_1: val_1
18 | key_2: val_2
19 | id: 1000
20 | CWF:
21 | on-shore:
22 | key_1: val_1
23 | key_2: val_2
24 | id: 1001
25 | Internal_3:
26 | payroll_emp:
27 | key_1: val_1
28 | key_2: val_2
29 | id: 1000
30 | CWF:
31 | on-shore:
32 | key_1: val_1
33 | key_2: val_2
34 | id: 1001
--------------------------------------------------------------------------------
/Day-23-Conditional-Execution/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Loop & Task Control
3 | hosts: nodes
4 | become: true
5 | vars:
6 | install_package: "ok"
7 | supported_os:
8 | - RedHat
9 | - Fedora
10 | - CentOS
11 | min_memory: 100
12 | userlist:
13 | - user101
14 | - user102
15 | - user103
16 | tasks:
17 |
18 | - name: Create users
19 | user:
20 | name: "{{ item }}"
21 | with_list: "{{ userlist }}"
22 |
23 | - name: Install Packages
24 | yum:
25 | name:
26 | - httpd
27 | - firewalld
28 | state: present
29 | when:
30 | - install_package == "ok"
31 | - ansible_distribution in supported_os
32 | - min_memory is defined
33 |
34 | - name: Enable Service
35 | service:
36 | name: "{{ item }}"
37 | state: started
38 | enabled: true
39 | loop:
40 | - httpd
41 | - firewalld
42 |
43 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: python
3 | services: docker
4 |
5 | env:
6 | global:
7 | - ROLE_NAME: git
8 | matrix:
9 | - MOLECULE_DISTRO: centos7
10 | MOLECULE_PLAYBOOK: playbook-source.yml
11 | - MOLECULE_DISTRO: ubuntu1804
12 | MOLECULE_PLAYBOOK: playbook-source.yml
13 | - MOLECULE_DISTRO: centos7
14 | - MOLECULE_DISTRO: centos6
15 | - MOLECULE_DISTRO: ubuntu1804
16 | - MOLECULE_DISTRO: ubuntu1604
17 | - MOLECULE_DISTRO: debian9
18 |
19 | install:
20 | # Install test dependencies.
21 | - pip install molecule yamllint ansible-lint docker
22 |
23 | before_script:
24 | # Use actual Ansible Galaxy role name for the project directory.
25 | - cd ../
26 | - mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
27 | - cd geerlingguy.$ROLE_NAME
28 |
29 | script:
30 | # Run tests.
31 | - molecule test
32 |
33 | notifications:
34 | webhooks: https://galaxy.ansible.com/api/v1/notifications/
35 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/Day-28-Roles/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: node1.techbeatly.com
3 | become: yes
4 | tasks:
5 | - name: Install httpd and firewalld
6 | yum:
7 | name:
8 | - httpd
9 | - firewalld
10 | state: latest
11 | - name: Enable and Run Firewalld
12 | service:
13 | name: firewalld
14 | enabled: true
15 | state: started
16 | - name: firewalld permitt httpd service
17 | firewalld:
18 | service: http
19 | permanent: true
20 | state: enabled
21 | immediate: yes
22 | - name: httpd enabled and running
23 | service:
24 | name: httpd
25 | enabled: true
26 | state: started
27 | - name: Test html page is installed
28 | copy:
29 | content: "Welcome to the example.com intranet!\n"
30 | dest: /var/www/html/index.html
31 | - name: Test intranet web server
32 | hosts: localhost
33 | become: no
34 | tasks:
35 | - name: connect to intranet webserver
36 | uri:
37 | url: http://lab.techbeatly.com
38 | status_code: 200
39 |
--------------------------------------------------------------------------------
/Day-09-Playbooks/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: node1.techbeatly.com
3 | become: yes
4 | tasks:
5 | - name: Install httpd and firewalld
6 | yum:
7 | name:
8 | - httpd
9 | - firewalld
10 | state: latest
11 | - name: Enable and Run Firewalld
12 | service:
13 | name: firewalld
14 | enabled: true
15 | state: started
16 | - name: firewalld permitt httpd service
17 | firewalld:
18 | service: http
19 | permanent: true
20 | state: enabled
21 | immediate: yes
22 | - name: httpd enabled and running
23 | service:
24 | name: httpd
25 | enabled: true
26 | state: started
27 | - name: Test html page is installed
28 | copy:
29 | content: "Welcome to the example.com intranet!\n"
30 | dest: /var/www/html/index.html
31 | - name: Test intranet web server
32 | hosts: localhost
33 | become: no
34 | tasks:
35 | - name: connect to intranet webserver
36 | uri:
37 | url: http://lab.techbeatly.com
38 | status_code: 200
39 |
--------------------------------------------------------------------------------
/Day-30-Host-Patterns/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: nodes
3 | become: yes
4 | tasks:
5 | - name: Install httpd and firewalld
6 | yum:
7 | name:
8 | - httpd
9 | - firewalld
10 | state: latest
11 | - name: Enable and Run Firewalld
12 | service:
13 | name: firewalld
14 | enabled: true
15 | state: started
16 | - name: firewalld permitt httpd service
17 | firewalld:
18 | service: http
19 | permanent: true
20 | state: enabled
21 | immediate: yes
22 | - name: httpd enabled and running
23 | service:
24 | name: httpd
25 | enabled: true
26 | state: started
27 | - name: Test html page is installed
28 | copy:
29 | content: "Welcome to the example.com intranet!\n"
30 | dest: /var/www/html/index.html
31 | - name: Test intranet web server
32 | hosts: localhost
33 | become: no
34 | tasks:
35 | - name: connect to intranet webserver
36 | uri:
37 | url: "http://{{ item }}"
38 | status_code: 200
39 | with_items:
40 | - node1
41 | - node2
42 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017 Jeff Geerling
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Day-29-Parallelism/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: nodes
3 | become: yes
4 | serial: 25%
5 | tasks:
6 | - name: Install httpd and firewalld
7 | yum:
8 | name:
9 | - httpd
10 | - firewalld
11 | state: latest
12 | - name: Enable and Run Firewalld
13 | service:
14 | name: firewalld
15 | enabled: true
16 | state: started
17 | - name: firewalld permitt httpd service
18 | firewalld:
19 | service: http
20 | permanent: true
21 | state: enabled
22 | immediate: yes
23 | - name: httpd enabled and running
24 | service:
25 | name: httpd
26 | enabled: true
27 | state: started
28 | - name: Test html page is installed
29 | copy:
30 | content: "Welcome to the example.com intranet!\n"
31 | dest: /var/www/html/index.html
32 | - name: Test intranet web server
33 | hosts: localhost
34 | become: no
35 | tasks:
36 | - name: connect to intranet webserver
37 | uri:
38 | url: "http://{{ item }}"
39 | status_code: 200
40 | with_items:
41 | - node1
42 | - node2
43 |
--------------------------------------------------------------------------------
/Day-24-Handlers/site.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: nodes
3 | become: yes
4 | tasks:
5 | - name: Install httpd and firewalld
6 | yum:
7 | name:
8 | - httpd
9 | - firewalld
10 | state: latest
11 | notify:
12 | - restart httpd
13 |
14 | - name: Enable and Run Firewalld
15 | service:
16 | name: firewalld
17 | enabled: true
18 | state: started
19 | - name: firewalld permitt httpd service
20 | firewalld:
21 | service: http
22 | permanent: true
23 | state: enabled
24 | immediate: yes
25 |
26 | - name: Test html page is installed
27 | copy:
28 | content: "Welcome to the example.com intranet!\n"
29 | dest: /var/www/html/index.html
30 | notify: restart httpd
31 |
32 | handlers:
33 | - name: restart httpd
34 | service:
35 | name: httpd
36 | enabled: true
37 | state: restarted
38 |
39 | - name: Test intranet web server
40 | hosts: localhost
41 | become: no
42 | tasks:
43 | - name: connect to intranet webserver
44 | uri:
45 | url: http://node1.techbeatly.com
46 | status_code: 200
47 |
--------------------------------------------------------------------------------
/Day-06-Deploying-Ansible/README.md:
--------------------------------------------------------------------------------
1 | ## Deploying Ansible
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Deploying Ansible](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=KroiohW4k-0)
6 |
7 | You can store your ansible.cfg at below locations and see the preference order. (top item has the most priority)
8 |
9 | - `$ANSIBLE_CONFIG` – Environment variable
10 | - `./ansible.cfg` – cfg file in current directory
11 | - `~/.ansible.cfg` – home directory
12 | - `/etc/ansible/ansible.cfg` – default cfg
13 |
14 | ```bash
15 | ## find ansible configuration file in use from version information
16 | [root@ansible-box ansible]# ansible --version
17 | ansible 2.5.3
18 | config file = /root/ansible/ansible.cfg
19 | configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
20 | ansible python module location = /usr/lib/python2.7/site-packages/ansible
21 | executable location = /bin/ansible
22 | python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
23 | ```
24 |
25 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
--------------------------------------------------------------------------------
/Day-25-Task-Failures/handler.yaml:
--------------------------------------------------------------------------------
1 | - name: Enable Intranet Services
2 | hosts: nodes
3 | become: yes
4 | force_handlers: yes
5 | tasks:
6 | - name: Install httpd and firewalld
7 | yum:
8 | name:
9 | - httpd
10 | - firewalld
11 | state: latest
12 | notify:
13 | - restart httpd
14 |
15 | - name: Enable and Run Firewalld
16 | service:
17 | name: firewalld-wrong
18 | enabled: true
19 | state: started
20 | - name: firewalld permitt httpd service
21 | firewalld:
22 | service: http
23 | permanent: true
24 | state: enabled
25 | immediate: yes
26 |
27 | - name: Test html page is installed
28 | copy:
29 | content: "Welcome to the example.com intranet!\n"
30 | dest: /var/www/html/index.html
31 | notify: restart httpd
32 |
33 | handlers:
34 | - name: restart httpd
35 | service:
36 | name: httpd
37 | enabled: true
38 | state: restarted
39 |
40 | - name: Test intranet web server
41 | hosts: localhost
42 | become: no
43 | tasks:
44 | - name: connect to intranet webserver
45 | uri:
46 | url: http://node1.techbeatly.com
47 | status_code: 200
48 |
--------------------------------------------------------------------------------
/Day-14-Ansible-Host-Variables-and-Group-Variables/site.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install and configure httpd
3 | hosts: "{{ nodes }}"
4 | become: yes
5 | tasks:
6 |
7 | - name: Install {{ web_package }} & {{ firewall_package }}
8 | yum:
9 | name:
10 | - "{{ web_package }}"
11 | - "{{ firewall_package }}"
12 | state: latest
13 | - name: Enable and Start {{ web_service }}
14 | service:
15 | name: "{{ web_service }}"
16 | enabled: true
17 | state: started
18 | - name: Enable and Start {{ firewall_service }}
19 | service:
20 | name: "{{ firewall_service }}"
21 | enabled: true
22 | state: started
23 |
24 | - name: Open firewall ports
25 | firewalld:
26 | service: http
27 | permanent: true
28 | state: enabled
29 | immediate: yes
30 | - name: Copy html content
31 | copy:
32 | content: "Welcome to our website
(This is deployed using Ansible)"
33 | dest: /var/www/html/index.html
34 |
35 | - name: Test and Verify Webservers
36 | hosts: localhost
37 | become: no
38 | tasks:
39 | - name: Connect to the webserver
40 | uri:
41 | url: http://node2
42 | status_code: 200
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Day-12-Managing-Ansible-Variables/site.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install and configure httpd
3 | hosts: "{{ nodes }}"
4 | become: yes
5 | vars_files:
6 | - vars.yaml
7 | tasks:
8 |
9 | - name: Install {{ web_package }} & {{ firewall_package }}
10 | yum:
11 | name:
12 | - "{{ web_package }}"
13 | - "{{ firewall_package }}"
14 | state: latest
15 | - name: Enable and Start {{ web_service }}
16 | service:
17 | name: "{{ web_service }}"
18 | enabled: true
19 | state: started
20 | - name: Enable and Start {{ firewall_service }}
21 | service:
22 | name: "{{ firewall_service }}"
23 | enabled: true
24 | state: started
25 |
26 | - name: Open firewall ports
27 | firewalld:
28 | service: http
29 | permanent: true
30 | state: enabled
31 | immediate: yes
32 | - name: Copy html content
33 | copy:
34 | content: "Welcome to our website
(This is deployed using Ansible)"
35 | dest: /var/www/html/index.html
36 |
37 | - name: Test and Verify Webservers
38 | hosts: localhost
39 | become: no
40 | tasks:
41 | - name: Connect to the webserver
42 | uri:
43 | url: http://node2
44 | status_code: 200
45 |
46 |
47 |
--------------------------------------------------------------------------------
/Day-03-Ansible-Lab-Environment-Using-VirtualBox-and-Vagrant/README.md:
--------------------------------------------------------------------------------
1 | ## Setting up Lab Environment
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Setting up a Lab Environment using Vagrant and VirtualBox](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=qoliqxGvX84)
6 |
7 | ### Install VirtualBox
8 |
9 | [Download](https://www.virtualbox.org/wiki/Downloads) and [install](https://www.virtualbox.org/manual/ch02.html) VirtualBox on your Laptop or Workstation. Select the appropriate package for your OS platform (Linux, Windows or Mac)
10 |
11 | ### Install Vagrant
12 |
13 | [Download](https://www.vagrantup.com/downloads) and [install](https://www.vagrantup.com/docs/installation) Vagrant on your workstation or laptop.
14 |
15 | **Spin up a test VM with Vagrant**
16 |
17 | ```bash
18 | ## initialize the VM and Vagrantfile
19 | $ vagrant init centos/8
20 |
21 | ## spinup vagrant vm
22 | $ vagrant up
23 |
24 | ## login to the VM
25 | $ vagrant ssh
26 |
27 | ## destroy vagrant VM once tested
28 | $ vagrant destroy
29 | ```
30 |
31 | *Note: We have ready-to-use `Vagrantfile` for setting up the Ansible Lab, so do not need to worry on this configurations.*
32 |
33 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
--------------------------------------------------------------------------------
/Day-05-Installing-Ansible-on-Linux/README.md:
--------------------------------------------------------------------------------
1 | ## Installing Ansible
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Installing Ansible on Linux](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=-v-ddXSYSRI)
6 |
7 | Refer full article [Installing Ansible on techbeatly.com](https://www.techbeatly.com/2018/06/ansible-part-2-installing-ansible.html)
8 |
9 | ```bash
10 | ## Check python version
11 | $ sudo yum list installed python
12 |
13 | ## Install python if not installed
14 | $ sudo yum install paython3
15 |
16 | ## Install Ansible
17 | $ sudo yum install -y ansible
18 |
19 | ## Verify Ansible
20 | [devops@ansible-box dep-install]$ ansible --version
21 | ansible 2.3.1.0
22 | config file = /etc/ansible/ansible.cfg
23 | configured module search path = Default w/o overrides
24 | python version = 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
25 | ```
26 |
27 | **Other Methods for Installing Ansible**
28 | ```bash
29 | ## Via python pip
30 | $ sudo pip install ansible
31 |
32 | ## PPA Repo
33 | $ sudo apt-get install ansible
34 |
35 | ## If CentOS, configure EPEL repo (Extra Packages for Enterprise Linux)
36 | sudo yum -y install epel-release
37 | ```
38 |
39 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/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 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/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 |
--------------------------------------------------------------------------------
/Day-04-Create-Ansible-Lab-using-Vagrant-and-VirtualBox/README.md:
--------------------------------------------------------------------------------
1 | ## Setting up Lab Environment
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | [Create an Ansible Lab using Vagrant and VirtualBox](https://www.youtube.com/watch?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK&v=6sulABLjEJM)
6 |
7 | ```bash
8 | ## clone the repository which contains multiple vagrant samples
9 | $ git clone https://github.com/ginigangadharan/vagrant-iac-usecases.git
10 | $ cd vagrant-iac-usecases
11 |
12 | ## switch to the directory where we have Vagrantfile for ansible lab
13 | $ cd virtualbox-ansible-lab
14 |
15 | ## Review the Vagrantfile and update the node counts as needed.
16 | ## for the basic setup we just need 2 managed nodes;
17 | ## Update it to 2 for example
18 | ANSIBLE_NODES = 2
19 |
20 | ## Spinup VM's with Vagrant and VirtualBox and wait for the VM's to create
21 | $ vagrant up
22 | ## Also you can switch to the virtualbox GUI and check if VM creation in progress
23 | ## Review other files in the directory for your reference.
24 |
25 | ## check VM Status
26 | $ vagrant status
27 |
28 | ## Login to the VMs and test access
29 | $ vagrant ssh ansible-engine
30 |
31 | ## Ansible will be installed Ansible Engine node automatically; verify the same.
32 | [vagrant@ansible-engine ~] ansible --version
33 | [vagrant@ansible-engine ~] exit
34 |
35 | ## stop VM's once testing done;
36 | ## no need to destroy as you can use the same lab on next day for practicing.
37 | $ vagrant halt
38 | ```
39 |
40 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
--------------------------------------------------------------------------------
/Day-28-Roles/roles/myweb/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: DevOps
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 |
54 |
--------------------------------------------------------------------------------
/Use-Case-Calling-Role-with-Variable/roles/test-role/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.1
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 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/README.md:
--------------------------------------------------------------------------------
1 | # Ansible Role: Git
2 |
3 | [](https://travis-ci.org/geerlingguy/ansible-role-git)
4 |
5 | Installs Git, a distributed version control system, on any RHEL/CentOS or Debian/Ubuntu Linux system.
6 |
7 | ## Requirements
8 |
9 | None.
10 |
11 | ## Role Variables
12 |
13 | Available variables are listed below, along with default values (see `defaults/main.yml`):
14 |
15 | workspace: /root
16 |
17 | Where certain files will be downloaded and adjusted prior to git installation, if needed.
18 |
19 | git_enablerepo: ""
20 |
21 | This variable, a well as `git_packages`, will be used to install git via a particular `yum` repo if `git_install_from_source` is false (CentOS only). Any additional repositories you have installed that you would like to use for a newer/different Git version.
22 |
23 | git_packages:
24 | - git
25 |
26 | The specific Git packages that will be installed. By default, only `git` is installed, but you could add additional git-related packages like `git-svn` if desired.
27 |
28 | git_install_from_source: false
29 | git_install_path: "/usr"
30 | git_version: "2.26.0"
31 |
32 | Whether to install Git from source; if set to `true`, `git_version` is required and will be used to install a particular version of git (see all available versions here: https://www.kernel.org/pub/software/scm/git/), and `git_install_path` defines where git should be installed.
33 |
34 | git_install_from_source_force_update: false
35 |
36 | If git is already installed at and older version, force a new source build. Only applies if `git_install_from_source` is `true`.
37 |
38 | ## Dependencies
39 |
40 | None.
41 |
42 | ## Example Playbook
43 |
44 | - hosts: servers
45 | roles:
46 | - { role: geerlingguy.git }
47 |
48 | ## License
49 |
50 | MIT / BSD
51 |
52 | ## Author Information
53 |
54 | This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
55 |
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/tasks/install-from-source.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Include OS-specific variables (RedHat).
3 | include_vars: "{{ ansible_os_family }}.yml"
4 | when:
5 | - ansible_os_family == "RedHat"
6 | - ansible_distribution != "Fedora"
7 |
8 | - name: Include OS-specific variables (Fedora).
9 | include_vars: "{{ ansible_distribution }}.yml"
10 | when: ansible_distribution == "Fedora"
11 |
12 | - name: Include OS-specific variables (Debian).
13 | include_vars: "{{ ansible_os_family }}.yml"
14 | when: ansible_os_family == "Debian"
15 |
16 | - name: Define git_install_from_source_dependencies.
17 | set_fact:
18 | git_install_from_source_dependencies: "{{ __git_install_from_source_dependencies | list }}"
19 | when: git_install_from_source_dependencies is not defined
20 |
21 | - name: Ensure git's dependencies are installed.
22 | package:
23 | name: "{{ git_install_from_source_dependencies }}"
24 | state: present
25 |
26 | - name: Get installed version.
27 | command: >
28 | git --version
29 | warn=no
30 | changed_when: false
31 | failed_when: false
32 | check_mode: false
33 | register: git_installed_version
34 |
35 | - name: Force git install if the version numbers do not match.
36 | set_fact:
37 | git_reinstall_from_source: true
38 | when:
39 | - git_install_from_source_force_update | bool
40 | - (git_installed_version.rc == 0) and (git_installed_version.stdout | regex_replace("^.*?([0-9\.]+)$", "\\1") is version(git_version, operator="!="))
41 |
42 | - name: Download git.
43 | get_url:
44 | url: "https://www.kernel.org/pub/software/scm/git/git-{{ git_version }}.tar.gz"
45 | dest: "{{ workspace }}/git-{{ git_version }}.tar.gz"
46 | when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
47 |
48 | - name: Expand git archive.
49 | unarchive:
50 | src: "{{ workspace }}/git-{{ git_version }}.tar.gz"
51 | dest: "{{ workspace }}"
52 | creates: "{{ workspace }}/git-{{ git_version }}/README"
53 | copy: false
54 | when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
55 |
56 | - name: Build git.
57 | command: >
58 | make prefix={{ git_install_path }} {{ item }}
59 | chdir={{ workspace }}/git-{{ git_version }}
60 | with_items:
61 | - all
62 | - install
63 | when: (git_installed_version.rc != 0) or (git_reinstall_from_source | bool)
64 | become: true
65 |
--------------------------------------------------------------------------------
/Day-09-Playbooks/README.md:
--------------------------------------------------------------------------------
1 | ## Play with Ansible Playbooks
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | **YAML format**
6 |
7 | - Start with `---` (3 consecutive hyphens) end with `...` (optional)
8 | - A list `-` begin with dash followed by space
9 | - attribute definition
10 | ```yaml
11 | attribute1: value1
12 | attribute2: value2
13 | ```
14 | - Comments are preceded by `#`
15 | - Warning: DO NOT use TAB! (unless you configured tab expand)
16 | - Multiple Lines:
17 |
18 | ```yaml
19 | address: |
20 | 1, Jalan 2,
21 | Main Block,
22 | 89892 Abc, My.
23 |
24 | my_note: >
25 | This is a single
26 | line of text.
27 | ```
28 |
29 | A playbooks starts with `---` and with minimal entris about the play.
30 |
31 | ```yaml
32 | ---
33 | - name: Enable Intranet Services
34 | hosts: node1.techbeatly.com
35 | become: yes
36 | tasks:
37 | ```
38 |
39 | Add our first task to the Play – install packages
40 | ```yaml
41 | - name: Install httpd and firewalld
42 | yum:
43 | name:
44 | - httpd
45 | - firewalld
46 | state: latest
47 | ```
48 |
49 | and add other tasks as needed.
50 |
51 |
52 | Full Playbook
53 | ```yaml
54 | - name: Enable Intranet Services
55 | hosts: node1.techbeatly.com
56 | become: yes
57 | tasks:
58 | - name: Install httpd and firewalld
59 | yum:
60 | name:
61 | - httpd
62 | - firewalld
63 | state: latest
64 | - name: Enable and Run Firewalld
65 | service:
66 | name: firewalld
67 | enabled: true
68 | state: started
69 | - name: firewalld permitt httpd service
70 | firewalld:
71 | service: http
72 | permanent: true
73 | state: enabled
74 | immediate: yes
75 | - name: httpd enabled and running
76 | service:
77 | name: httpd
78 | enabled: true
79 | state: started
80 | - name: Test html page is installed
81 | copy:
82 | content: "Welcome to the example.com intranet!\n"
83 | dest: /var/www/html/index.html
84 | - name: Test intranet web server
85 | hosts: localhost
86 | become: no
87 | tasks:
88 | - name: connect to intranet webserver
89 | uri:
90 | url: http://lab.techbeatly.com
91 | status_code: 200
92 | ```
--------------------------------------------------------------------------------
/Day-25-Task-Failures/README.md:
--------------------------------------------------------------------------------
1 | ## Play with Ansible Playbooks
2 |
3 | [Ansible Full Course – YouTube Playlist](https://youtu.be/K4wGqwS2RLw?list=PLH5uDiXcw8tSW9Y6FsVsSQJQ88tMPBsbK)
4 |
5 | **YAML format**
6 |
7 | - Start with `---` (3 consecutive hyphens) end with `...` (optional)
8 | - A list `-` begin with dash followed by space
9 | - attribute definition
10 | ```yaml
11 | attribute1: value1
12 | attribute2: value2
13 | ```
14 | - Comments are preceded by `#`
15 | - Warning: DO NOT use TAB! (unless you configured tab expand)
16 | - Multiple Lines:
17 |
18 | ```yaml
19 | address: |
20 | 1, Jalan 2,
21 | Main Block,
22 | 89892 Abc, My.
23 |
24 | my_note: >
25 | This is a single
26 | line of text.
27 | ```
28 |
29 | A playbooks starts with `---` and with minimal entris about the play.
30 |
31 | ```yaml
32 | ---
33 | - name: Enable Intranet Services
34 | hosts: node1.techbeatly.com
35 | become: yes
36 | tasks:
37 | ```
38 |
39 | Add our first task to the Play – install packages
40 | ```yaml
41 | - name: Install httpd and firewalld
42 | yum:
43 | name:
44 | - httpd
45 | - firewalld
46 | state: latest
47 | ```
48 |
49 | and add other tasks as needed.
50 |
51 |
52 | Full Playbook
53 | ```yaml
54 | - name: Enable Intranet Services
55 | hosts: node1.techbeatly.com
56 | become: yes
57 | tasks:
58 | - name: Install httpd and firewalld
59 | yum:
60 | name:
61 | - httpd
62 | - firewalld
63 | state: latest
64 | - name: Enable and Run Firewalld
65 | service:
66 | name: firewalld
67 | enabled: true
68 | state: started
69 | - name: firewalld permitt httpd service
70 | firewalld:
71 | service: http
72 | permanent: true
73 | state: enabled
74 | immediate: yes
75 | - name: httpd enabled and running
76 | service:
77 | name: httpd
78 | enabled: true
79 | state: started
80 | - name: Test html page is installed
81 | copy:
82 | content: "Welcome to the example.com intranet!\n"
83 | dest: /var/www/html/index.html
84 | - name: Test intranet web server
85 | hosts: localhost
86 | become: no
87 | tasks:
88 | - name: connect to intranet webserver
89 | uri:
90 | url: http://lab.techbeatly.com
91 | status_code: 200
92 | ```
--------------------------------------------------------------------------------
/Use-Case-Modify-JSON-YAML/site.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | - hosts: localhost
3 | gather_facts: false
4 | vars_files:
5 | - data-var.yaml
6 | tasks:
7 | #- set_fact:
8 | # Company: "{{ Company }}"
9 | - name: Print Data
10 | debug:
11 | msg: "{{ Company }}"
12 | when: a is defined
13 |
14 | - name: Print Data 2
15 | debug:
16 | #msg: "{{ Company['Country']['states'][0]['employee'][] }}"
17 | #msg: "{{ item }}" #"hello" #
18 | msg: "{{ Company['Country']['states'][0]['employee'][item]['payroll_emp']['id'] }}" #"hello" #
19 | #with_items: "{{ Company['Country']['states'][0]['employee'] | to_json }}"
20 | with_items: "{{ Company | json_query('Country.states[0].employee') }}"
21 |
22 | - name: Set Data
23 | set_fact:
24 | #msg: "{{ Company['Country']['states'][0]['employee'][] }}"
25 | #msg: "{{ item }}" #"hello" #
26 | #Company['Country']['states'][0]['employee'][{{ item }}]['payroll_emp']['id']: 2000
27 | #Company['Country']['states'][0]['employee']['Internal_1']['payroll_emp']['id']: 2000
28 |
29 | #Company: "{{ Company | combine( { Country:{ states:[{employee: {Internal_1: {payroll_emp: {id: 1000}}}}]}}, recursive=True ) }}"
30 | Company: "{{ Company | combine( {'Country':{'states':[{'employee':{'Internal_1':{'payroll_emp':{'id':3000}}}}]}}, recursive=True, list_merge='append_rp' ) }}"
31 |
32 | #animals: "{{ animals|combine({'birds': {'cardinals': {'feathers': 'red'}}}, recursive=True) }}"
33 | #Company: "{{ Company | combine( NewCompany, recursive=True) }}"
34 | #Company: "{{ Company | combine( { CountryNewCountry: 1000 }, recursive=True ) }}"
35 | #{"Country":{"states":[{"employee":{"Internal_1":{"payroll_emp":{"id":1000}}}}]}}
36 | #with_items: "{{ Company['Country']['states'][0]['employee'] | to_json }}"
37 | #with_items: "{{ Company | json_query('Country.states[0].employee') }}"
38 |
39 | - name: Print Data
40 | debug:
41 | msg: "{{ Company }}"
42 | #when: a is defined
43 |
44 | # - name: replace id for payroll_emp
45 | # replace:
46 | # path: sample_file.yml
47 | # regexp: 'id:.*'
48 | # replace: 'id: 2000'
49 | # after: 'payroll_emp:.*'
50 |
51 | #- name: replace id for payroll_emp
52 | # replace:
53 | # path: sample_file.yml
54 | # regexp: 'id:.*'
55 | # replace: 'id: 2000
--------------------------------------------------------------------------------
/Day-28-Roles/roles/geerlingguy.git/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Configuration for probot-stale - https://github.com/probot/stale
2 |
3 | # Number of days of inactivity before an Issue or Pull Request becomes stale
4 | daysUntilStale: 90
5 |
6 | # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8 | daysUntilClose: 30
9 |
10 | # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11 | onlyLabels: []
12 |
13 | # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14 | exemptLabels:
15 | - pinned
16 | - security
17 | - planned
18 |
19 | # Set to true to ignore issues in a project (defaults to false)
20 | exemptProjects: false
21 |
22 | # Set to true to ignore issues in a milestone (defaults to false)
23 | exemptMilestones: false
24 |
25 | # Set to true to ignore issues with an assignee (defaults to false)
26 | exemptAssignees: false
27 |
28 | # Label to use when marking as stale
29 | staleLabel: stale
30 |
31 | # Limit the number of actions per hour, from 1-30. Default is 30
32 | limitPerRun: 30
33 |
34 | pulls:
35 | markComment: |-
36 | This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!
37 |
38 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale.
39 |
40 | unmarkComment: >-
41 | This pull request is no longer marked for closure.
42 |
43 | closeComment: >-
44 | This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details.
45 |
46 | issues:
47 | markComment: |-
48 | This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
49 |
50 | Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
51 |
52 | unmarkComment: >-
53 | This issue is no longer marked for closure.
54 |
55 | closeComment: >-
56 | This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
57 |
--------------------------------------------------------------------------------
/Day-27-Jinja2/system-information.j2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ system_report_title }}
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | |
23 | This report is generated by Ansible Automation
24 | |
25 |
26 |
27 | {{ dns_report_title }} |
28 |
29 |
30 |
31 |
32 |
33 | | System Name |
34 | {{ }} |
35 |
36 |
37 | | IP Address |
38 | {{ }} |
39 |
40 |
41 | | Architecture |
42 | {{ }} |
43 |
44 |
45 | | Operating System |
46 | {{ }} |
47 |
48 |
49 | | Version |
50 | {{ }} |
51 |
52 |
53 |
54 |
55 | |
56 |
57 |
58 | |
59 | If you find any mismatch in report, please report to {{ report_admin_email }}
60 | |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------