-1

How to show a process list using ansible ad-hoc command?

yuderb
  • 11
  • 1

1 Answers1

2

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.

Skanda Shastry
  • 182
  • 6
  • 17