Posts

Showing posts with the label Ansible

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...

Ansible

Ansible and Basic Commands Ansible is an open-source and  Infrastructure Management Tool. The Ansible file is in YAML format. Ansible is Agentless works with SSH Protocol. Ansible is written and uses Python Ansible has many modules to perform various operations without any programming knowledge.   Ansible Configuration file: PATH: /etc/ansible/ansible.cfg remote_tmp  = /commlocation (change to common location to avoid permissions issue) forks          = 50 (Adjust to number of instances to connect parallelly )  Default hosts file Path: /etc/ansible/hosts [TEST1] server1 server2 [TEST2] server3 server4 Command Usage: Ansible to use default host file  $ansible all -m ping -o (run on all the hosts in the hosts file) $ansible TEST1 -m ping -o (run on nodes under TEST1 group) to use a custom host file create a file and pass an argument with -i as below 4cat hostfile.ini [NODE1] testserver1 testserver2 [NODE2] testserver3 testserver4...