shell - Execute commands in nodes.

Author:Michael DeHaan

Synopsis

The shell module takes the command name followed by a list of space-delimited arguments. It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node.

Options

parameter required default choices comments
chdir no
    cd into this directory before running the command (added in Ansible 0.6)
    creates no
      a filename, when it already exists, this step will not be run.
      executable no
        change the shell used to execute the command. Should be an absolute path to the executable. (added in Ansible 0.9)
        free_form yes
          The shell module takes a free form command to run, as a string. There's not an actual option named "free form". See the examples!
          removes no
            a filename, when it does not exist, this step will not be run. (added in Ansible 0.8)

            Examples


            # Execute the command in remote shell; stdout goes to the specified
            # file on the remote
            - shell: somescript.sh >> somelog.txt
            

            Note

            If you want to execute a command securely and predictably, it may be better to use the command module instead. Best practices when writing playbooks will follow the trend of using command unless shell is explicitly required. When running ad-hoc commands, use your best judgement.

            Table Of Contents

            Previous topic

            script - Runs a local script on a remote node after transferring it

            Next topic

            Database Modules