Ansible Multiple playbook exercise
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
1. Write a 3 yaml playbook i.e main.yaml, second.yaml and third.yaml with some demo debug tasks and call second.yaml and third.yaml from main.yaml using inlcude.
-------------------------------------second.yaml-------------------------------
---
- name: Update web servers
hosts: web
tasks:
- name: Install the latest version of Apache
yum:
name={{ packagename }}
state=latest
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: index.html
dest: /var/www/html/index.html
--------------------------------------third.yaml----------------------------------
- name: Update web servers
hosts: db
tasks:
- name: Start service httpd, if not started
ansible.builtin.service:
name={{ servicename }}
state=started
- name: include default step variables
include_vars: var-include.yml
- name: Print the vars
ansible.builtin.debug:
msg: My name {{ myname }} and My age is {{ age }}
------------------------------------main.py-------------------------------------
- include: second.yaml
- include: third.yaml