FreeKB - Ansible command module (invoking a command)
Ansible - command module (invoking a command)

Typically, the shellcommand, or script modules are used to invoke a command on a managed node (e.g. target systems). /usr/bin/python needs to exist on the managed node to use these modules. If Python does not exist, the raw module can be used instead. 

The ansible-doc command command can be used to show the Ansible documention on the command module.

In this example, the ps command will be invoked on the managed nodes.

- name: ps command
  command: ps

 

The playbook can then be executed using this command.

ansible-playbook playbook.yml

 

The following should be produced.

TASK [ps command]
changed: [server1.example.com]

 

By default, no stdout is printed. The debug module can be used to print output to the console.

By default, Ansible performs tasks on managed node. The connectiondelegate_to, or local_action modules/parameters can be used to run the task on the control node (that's your Ansible server).



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 2df0b in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |