You are on page 1of 2

Following Adhoc commands will be converted in in a playbook:

ansible -m ping 192.168.122.15

ansible -m user 192.168.122.15 -a "name=test state=present" -b

ansible -m yum 192.168.122.15 -a "name=httpd state=latest" -b

ansible -m service 192.168.122.15 -a "name=httpd state=started enabled=true" -b

Playbook = it is a list of plays

Play = List of tasks which can be executed on a host or a group of host, depending on what kind of
host pattern you define

Playbook is written in YAML

YAML = Yaml Ain't Markup Language

List/Dictitionaries

List

list of fruits

- apple
- banana
- mango

each (-), represents a list

and a ( ) space is mandatory after a dash (-)

Dictionatiries

dictionary of fruits (key: value)

fruit1: apple
fruit2: banana
fruit3: mango

after a key, a colon (:) and a space ( ) is mandatory


Rules to write a playbook:

Items are always written next to each other (below to each previou item)
Items which have parent-child relationship, child will be indented as comparing to its parent.

---- (Item 1)
---- (Item 2)
---- (Item 3)
---- (Child 1 of Item 3)
---- (Child 2 of Item 3)
---- (Child 3 of Item 3)
----
---- (Child 1 of Item 4)
---- (Child 1 of Item 4)

You might also like