Monday 22 April 2019

Ansible Plays and Play books

Ansible Plays and Play books
Plays maps hosts to tasks
A play can have multiple tasks
A play book can have multiple plays.
at HOME dir:-
[ansible@ansibleserver ~]$ cat .vimrc
autocmd FileType yaml setlocal ai ts=2 sw=2 et

[ansible@ansibleserver playbooks]$ cat firstplay.yaml
---
- name: first yaml file
  hosts: db
  vars_prompt:
  - name: "sitename"
    prompt: "what is new state name?"
  tasks:
  - debug: msg="new state name is {{sitename}}"
...
[ansible@ansibleserver playbooks]$ ansible-playbook firstplay.yaml
what is new state name?:

PLAY [first yaml file] ***************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************
ok: [10.25.12.10]

TASK [debug] *************************************************************************************************************************
ok: [10.25.12.10] => {
    "msg": "new state name is TS"
}

PLAY RECAP ***************************************************************************************************************************
10.25.12.10                : ok=2    changed=0    unreachable=0    failed=0

No comments:

Post a Comment