Running Ad Hoc Command - lj198851/ansible GitHub Wiki
Running Ad Hoc Command
ansible host-pattern -m module [-a 'module arguments'] [-i inventory]
Use ping module
ansible all -m ping
List all the modules that are installed
ansible-doc -l
displays ping module
ansilbe-doc ping
The following modules might be immediately useful:
File modules
- copy (copy a localfile to the managed host)
- get_url(download a fileto the managed host)
- synchronize(to synchronize content like rsync)
- file(set permissions and other properties of a file)
- lineinfile(make sure a certain line is or isn't in a file)
Software package management modules
- yum ,dnf ,apt ,pip ,gem
System administration tools
-
service, user
-
uri(can test functionality or issue API requests)
Example:
-
run Commands with command Moule
ansible mymanagedhosts -m command -a /usr/bin/hostname ansible mymanagedhosts -m command -a /usr/bin/hostname -o
-o (in a single line format)