Ansible Module command: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 16: Line 16:
- name: A command example
- name: A command example
   command: some-command arg1 arg2
   command: some-command arg1 arg2
  become: true
  become_user: root
   args:
   args:
     chdir: /somedir/
     chdir: /somedir/
</syntaxhighlight>
</syntaxhighlight>
"become" and "become_user" are optional.

Revision as of 23:54, 29 December 2020

External

Internal

Overview

The command module takes the command name followed by a list of space-delimited arguments.

A command will NOT be interpreted by a shell, so variables like $HOME and operations like "<", ">", "|", ";" and "&" will not work. Use the shelll module for that.

- name: A command example
  command: some-command arg1 arg2
  become: true
  become_user: root
  args:
    chdir: /somedir/

"become" and "become_user" are optional.