Create an Ansible Playbook which will dynamically load the variable file named same as OS_name and just by using the variable names we can Configure our target node
Jan 3, 2021
playbook:
For this tasks I’m using 2 AWS instance with Rhel8 and Ubuntu and for CN I’m using Rhel8 on vm
inventory file:
here I’m using ansible_ssh_private_key_file keyword, you will be required to transfer the pem key to the CN
now ansible wb -m ping to check the connectivity
now I have created 2 files named as Redhat and Debian
we will be including these files into our main playbook
now the main playbook:
here, the {{ ansible_os_family }}.yml will dynamically load the variables according to the OS type:
result:
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —