do this steps.
step1: vi /home/thor/ansible/inventory
then add according to the given server like if given app server1 -
“stapp01 ansible_host=172.16.238.10 ansible_user=tony ansible_ssh_pass=Ir0nM@n”
save and exit
step2: vi /home/thor/ansible/playbook.yml
then add this
—
- name: Create a file appserver
hosts: stapp01
become: yes
tasks:
- name: Create the file
file:
path: /tmp/file.txt
state: touch
save and exit.
step3: cd /home/thor/ansible
step4: run this command - ansible-playbook -i inventory playbook.yml
it will successfully created the file in the appserver.