Playbook
In Ansible, a script is called a playbook.
A playbook describes which hosts to configure, and an ordered list of tasks to perform on those hosts.
The playbook can be execute by using the ansible-playbook command
Ansible’s playbook syntax is built on top of YAML
$ ansible-playbook <name>.yml
Ansible will make SSH connections in parallel
It will execute the first task on the list on all hosts simultaneously.
eg:- 1st tasks
- name: Install nginx
apt: name=nginx
Ansible will do the following:
1. Generate a Python script that installs the required package
2. Copy the script to host1, host2, and host3
3. Execute the script on host1, host2, and host3
4. Wait for the script to complete execution on all hosts
Ansible will then move to the next task in the list, and go through these same four steps. It’s important to note the following:
• Ansible runs each task in parallel across all hosts.
• Ansible waits until all hosts have completed a task before moving to the next task.
• Ansible runs the tasks in the order that you specify them.
Simple Terms
Ansible playbooks as executable documentation. It’s like the README file that describes the commands you had to type out to deploy your software, except that the instructions will never go out-of-date because they are also the
code that gets executed directly.
Remote Hosts
To manage a server with Ansible, the server needs to have SSH and Python 2.5 or later installed, or Python 2.4 with the Python simplejson library installed.
There’s no need to preinstall an agent or any other software on the host.
Control machine
The control machine (the one that you use to control remote machines) needs to have Python 2.6 or later installed
No comments:
Post a Comment