Ansible Playbook

Ansible Playbook

Playbooks are created in YAML format using modules available in ansible

To list the available modules
$ansible-doc -l 

To know more about a specific module used ansible-doc modulename
$ansible-doc <modulename>

Below playbook use apt module to install Nginx and TFTP packages on ubuntu machines 

$ cat  install.yml
---
 - name: Install Packages
   gather_facts: false
   become: yes
   hosts: NODE

   tasks:
     - name: Install packages
       apt: pkg={{ item }} state=present update_cache=true
       with_items:
            - nginx
            - tftp



$ cat list.ini
[NODE]
localhost
server1
server2


$ansible-playbook -i list.ini install.yml --syntax-check (Verify syntax )

playbook: install.yml

Ansible playbook created runs on all the host under NODE group in list.ini file
$ansible-playbook -i list.ini install.yml  -bK 
-K to let the ansible request for the password for SUDO
-b Used to become the default root

Comments

Popular posts from this blog

AWS: Auto Scaling

Jenkins Pipeline

EC2-Instances-awscli