0

is it possible to write the shell command in one line ?

- shell: my command register: var run_once: true 

this work

- shell: "my command" register=var run_once=true 

this does not work

1 Answer 1

1

Shell is a one-to-one comparison to running the command yourself. From Ansible documentation:

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

So my_command register=var run_once=true would be correct if my_command runs that way when you run it in your local shell.

While you didn't ask about it, it's worth noting that it looks like you're trying to add parameters to the shell module that don't exist, so the first example you provided would have to use the args parameter:

- name: Execute my command in a remote shell shell: my_command args: register: var run_once: true 

Documented examples of shell are here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.