How to show a process list using ansible ad-hoc command?
-
[SOLVED] ansible <"hosts"> -m shell -a 'ps -ef' – yuderb Sep 16 '19 at 13:28
1 Answers
Ansible Ad-hoc Syntax:
ansible <"hosts"> [-m <"module_name">] -a <"arguments"> -u [--become]
Ex: ansible <"hosts"> -m shell -a 'ps -ef'
Hosts: It can be any entry in the inventory file. For specifying all hosts in inventory, use all or '*'. Wild card patterns are also accepted.
module_name: It's an optional parameter. There are hundreds of modules available in Ansible. By default it is a command. For example, shell, copy, yum, apt, file.
Arguments: We should pass values that are required by the module. It may change according to the module used.
Username: It specifies the user account in which Ansible can execute commands. User account, SSH.
Become: It's an optional parameter specified when we want to execute operations that need sudo privilege. By default become is false.
PS: If you put a -c option, then Ansible will do a dry run of the command. It will not actually be applied on the nodes.

- 182
- 6
- 17
-
ansible <"hosts"> -m shell -a 'ps -ef' worked. Thank you for the answer! – yuderb Sep 16 '19 at 13:26