Ansible Notes

Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 2

Ansible notes:

Module: whenever ansible command issued or ran ,module will go to client and
sits there. It will create communication path between server and client to
execute the command.

/etc/ansible/host >> inventory file ( client ip’s or hostnames)


Syntax:
[groupname]
Client IP

/etc/ansible/ansible.cfg

Modules: ping, yum , copy, service, file, command, exicute, shell , ec2, aws,
user, group

Ansible-doc -l > will show all modules

Ansible-doc -s modulename. >> its kind of man page for module.

Ansible -m ping all >> ping status for all clients available in hosts file.

ansible -m yum -a "name=httpd state=present" all

ansible -m file -a "path=/tmp/ansible state=directory” dbserver

ansible -m file -a "path=/tmp/ansible owner=jenkins group=jenkins mode=777” all

ansible -m service -a "name=httpd state=stopped" all

Ansible programs are called as playbook, playbooks can be written in yml


language(yaml. Playbacks will be in general English only.

ansible-playbook playbook1.yml –syntax-check >> sysntax check

ansible-playbook playbook1.yml –check -- dry run

ansible-playbook playbook1.yml --start-at-task="httpd service restart"

ansible-playbook playbook1.yml –list-tasks


ansible-playbook playbook1.yml –list-tags

ansible-playbook playbook1.yml –forks=5

ansible-playbook playbook1.yml –step

sample playbook1

---
- hosts: all
tasks:
- name: installing package
yum: name=httpd state=present
- name: creating file
file: path=/tmp/playbook state=touch
- name: httpd service restart
service: name=httpd state=started

You might also like