Without loop to uninstall software on client
[ansible@ip-172-31-80-19 ~]$ vi loop.yml
[ansible@ip-172-31-80-19 ~]$ cat loop.yml
-
name: this is our first playbook.
hosts: all
tasks:
-
name: 'installing'
apt: name="vsftpd" state=absent
-
name: 'installing'
apt: name="tree" state=absent
[ansible@ip-172-31-80-19 ~]$ ansible-playbook loop.yml -i inventory.txt
To install replace state=absent with state=present
-------------------------------------------------------------------------------------------------
Now doing same thing by the help of loop
[ansible@ip-172-31-80-19 ~]$ vi loop.yml
[ansible@ip-172-31-80-19 ~]$ cat loop.yml
-
name: this is our first playbook.
hosts: all
tasks:
-
name: 'installing'
apt: name="{{ item }}" state=present
with_items:
- vsftpd
- tree
[ansible@ip-172-31-80-19 ~]$ ansible-playbook loop.yml -i inventory.txt
[ansible@ip-172-31-80-19 ~]$ vi loop.yml
[ansible@ip-172-31-80-19 ~]$ cat loop.yml
-
name: this is our first playbook.
hosts: all
tasks:
-
name: 'installing'
apt: name="vsftpd" state=absent
-
name: 'installing'
apt: name="tree" state=absent
[ansible@ip-172-31-80-19 ~]$ ansible-playbook loop.yml -i inventory.txt
To install replace state=absent with state=present
-------------------------------------------------------------------------------------------------
Now doing same thing by the help of loop
[ansible@ip-172-31-80-19 ~]$ vi loop.yml
[ansible@ip-172-31-80-19 ~]$ cat loop.yml
-
name: this is our first playbook.
hosts: all
tasks:
-
name: 'installing'
apt: name="{{ item }}" state=present
with_items:
- vsftpd
- tree
[ansible@ip-172-31-80-19 ~]$ ansible-playbook loop.yml -i inventory.txt
No comments:
Post a Comment