Earlier articles, we installed Ansible and added necessary admin users for managing nodes from Ansible server and implemented SSH key authentication to access nodes without password as SSH tunnel. We tested if our Ansible controller is working with pinging nodes and looked at few adhoc commands to centralized server management.
In this article, we will see how to use Ansible playbooks to bring together commands in one script for template way execution.
We use following Ansible yml file template to add our commands.
tasks:
- name: Add epel-release repo
yum:
name: epel-release
state: present
- name: Install nginx
yum:
name: nginx
state: present
Lets see it in a shell example.
In above example, we created a file called "ansible_pbook1.yml" and added our yml template into it. In that first simple "yml" file, we added ping command only and "Ansible-playbook" command used our "yml" and executed our Ansible commands.