is a config management tool,sample inventory file is /etc/ansible/hosts

sudo apt install ansible or pip install ansible and /etc/ansible/ansible.cfg is the config file

ansible -m ping localhost --ask-pass will give a message that sshpass needs to be installed, install using sudo apt install sshpass

ssh user@localhost, will ask for ssh password of the user you are logging in once

successful run ansible -m ping localhost --ask-pass again you should see succesful ping pong message

# This is the default ansible 'hosts' file. It should live in /etc/ansible/hosts




##  ansible_user=vagrant

## www[001:006]

## [dbservers]



## db-[99:101]

[appservers]  ansible_user=vagrant


Ansible ad hoc commands

ansible -m ping localhost --ask-pass

sudo ansible localhost -m "date" --ask-pass

ansible -m setup localhost --ask-pass

ansible -b -m apt -a "name=ntp state=present"  localhost --ask-pass -vvvv # -vvvv is verbose 

ansible -b -a "service ntp start" localhost -k # k is the same as ask-pass

ansible -b -a "service ntp stop" localhost -k

ansible -m ping localhost -k

ansible localhost -b -a "tail /var/log/nginx/error.log" -k

ansible localhost -b -m shell -a "tail /var/log/nginx/error.log" -k

** ansible-doc command **

ansible-doc service for example

Playbook file

Playbook files are YAML files, Be careful with indentation and do not use tab and always spaces

ansible-playbook --syntax-check playbooktest.yml 

- hosts: centos
  remote_user: root
  gather_facts: no

  - name: test ping
     remote_user: root
  - name: check ssh
        name: sshd
        state: started
  - name: check nginx
        name: nginx

where centos is a group of servers,remote_user will run as root,facts are disabled

These writings represent my own personal views alone.
Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.