Playbooks--- Kind of glue tht brings everything together
Fetches hosts from inventory and maps it with the module actions and uses the config file to define the behavior.
Play map hosts to tasks.
A play can have multiple tasks
A playbook can have multiple plays
Sample Playbook:
Notice the indentation and whitespace as it is important or else we get syntax errors.
Each time after - and : we need to have a space.
Tasks are execute in order - top down
Tasks use modules
To execute a playbook:
ansible-playbook playbook.yml
Here, we didn't provide inventory file as it is predefined in ansible config file, if not, add it in above line using -i.
If a host fails a task, that host is removed from the rest of the playbook execution.
If a host fails, it wil be added to a retry file.
Newer version of ANsbile, allows you to change this directory in the config file.
Later, once the issue is fixed, no need to run complete playbook on all machines.
Instead use --limit option to specify the retry file to run only on these machines where failed.
ansible-playbook web_db.yaml --limit @/home/vagrant/web_db.yaml.retry
Fetches hosts from inventory and maps it with the module actions and uses the config file to define the behavior.
Play map hosts to tasks.
A play can have multiple tasks
A playbook can have multiple plays
Sample Playbook:
Notice the indentation and whitespace as it is important or else we get syntax errors.
Each time after - and : we need to have a space.
Tasks are execute in order - top down
Tasks use modules
To execute a playbook:
ansible-playbook playbook.yml
Here, we didn't provide inventory file as it is predefined in ansible config file, if not, add it in above line using -i.
If a host fails a task, that host is removed from the rest of the playbook execution.
If a host fails, it wil be added to a retry file.
Newer version of ANsbile, allows you to change this directory in the config file.
Later, once the issue is fixed, no need to run complete playbook on all machines.
Instead use --limit option to specify the retry file to run only on these machines where failed.
ansible-playbook web_db.yaml --limit @/home/vagrant/web_db.yaml.retry
No comments:
Post a Comment