0% found this document useful (0 votes)
832 views

Ansible Notes

Modules allow Ansible to execute commands on client machines by creating a communication path between the server and client. Common modules are used to check status (ping), manage packages (yum), copy files, start/stop services, manage files and directories, and execute commands. Playbooks allow automating multiple tasks and are written in YAML format. They can be tested and debugged using options like --syntax-check, --check, and --step.

Uploaded by

Amarender Busani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
832 views

Ansible Notes

Modules allow Ansible to execute commands on client machines by creating a communication path between the server and client. Common modules are used to check status (ping), manage packages (yum), copy files, start/stop services, manage files and directories, and execute commands. Playbooks allow automating multiple tasks and are written in YAML format. They can be tested and debugged using options like --syntax-check, --check, and --step.

Uploaded by

Amarender Busani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 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