Using modules in Playbooks.
Create a play book hostname putting into the file , its more interesting in this
Lets create playbook , addline-infile.yml file ,
[ansible@ansible1 ~]$ vi addline-infile.yml
I have used hosts as database server , I have used module add line in file ,
I have created two task ,
• One is if file is not found in that directory to create that
• Second is line to add HOSTNAME in that file
Lets run the playbook ,
[ansible@ansible1 ~]$ ansible-playbook addline-infile.yml
Playbook run exactly !!!
Go to target server to check that file found or not ,
File has been created and line has been added hostname correctly !!!!