2. Modules

Modules

  • Modules are executable plugins that get the job done

  • They take key value as arguments

  • They can be invoked using command line or included in ansible playbook


Sample Commands

Ping all inventory hosts

ansible all -m ping

Flush IP table rules on all hosts in the inventory using sudo privileges

ansible -i inventory all -m command -a "iptables -F" --become --ask-become-pass

List files on web-servers inventory

ansible webservers -m command -a "ls"

Extact docs on particular module

ansible-doc setup

Sample Playbooks

apt_key module

apt_repository module

apt module

shell module


Last updated