shell

Collection: builtin

Full Name: parallax.builtin.shell

Aliases: ansible.builtin.shell, shell

Synopsis

Run a command through the target’s shell, with pipes and redirection

Parameters

NameTypeRequiredDefaultDescription
cmdstringyesThe shell command to run
chdirstringChange to this directory before running the command
createsstringA filename that this command creates. If it exists, the command will not be run
removesstringA filename that this command removes. If it does not exist, the command will not be run

Example

- name: Write the running config to a dated file
  shell:
    cmd: nginx -T > /var/backups/nginx-$(date +%F).conf
    chdir: /etc/nginx