Monday, 12 August 2019

Ansible Variable by Raj Gupta


[ansible@ip-172-31-80-19 ~]$ cat variablel.yml
-
  name: this is our first playbook.
  hosts: all
  vars:
    servicename: apache2
  tasks:
    -
      name: 'creating file using variable'
      service: name={{ servicename }} state=started
[ansible@ip-172-31-80-19 ~]$ ansible-playbook variablel.yml -i inventory.txt

Now Run the below command on client to check the status of apache2

[root@ip-172-31-85-190 ~]# service apache2 status


-----------------------------------------------------------------------------------------

Now to stop the ftp service 

[ansible@ip-172-31-80-19 ~]$ vi variablel.yml
[ansible@ip-172-31-80-19 ~]$ cat variablel.yml
-
  name: this is our first playbook.
  hosts: all
  vars:
    servicename: vsftpd
  tasks:
    -
      name: 'creating file using variable'
      service: name={{ servicename }} state=stopped
[ansible@ip-172-31-80-19 ~]$ ansible-playbook variablel.yml -i inventory.txt



No comments:

Post a Comment