Skip to content
Running a simple adhoc command on localhost
ansible localhost -m ping

Find the list of all modules available
ansible-doc -l

To copy files from ansible controller to ansible client
ansible [group] -m copy -a "src=source_path dest=destination_path"

To write content to file from ansible controller in any ansible client
ansible [group] -m copy -a "content="random content" dest=destination_path"

Creating a file
ansible [group] -m file -a "dest=location state=touch"

Delete a file
ansible [group] -m file -a "dest=location state=absent"

To give specific file permissions while creating
ansible [group] -m file -a "dest=location state=touch mode=0775"

To create a directory
ansible [group] -m file -a "dest=location state=directory"

Install or Delete packages
ansible [group] -m yum/apt -a "name=<package-name> state=<State>"

To execute a command as root user just append -b, Example
ansible [group] -m yum/apt -a "name=<package-name> state=<State>" -b

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.