The problem is likely due to /bin/sh being something like dash which
doesn't support some arguments.  You might have to specify an executable=
for /bin/bash or similar

On Wednesday, September 16, 2015, 廖鹏辉 <[email protected]> wrote:

> I want to echo something to a file using local_action and shell module.
> When I use echo -e, ansible will treat -e as string to print rather than
> a command line argument. See below:
>
> $ cat t.yaml
> - hosts: localhost
>   remote_user: root
>   gather_facts: False
>   tasks:
>     - name: test
>       local_action: shell echo -e abc
>
> $ ansible-playbook -vv t.yaml
>
> PLAY [localhost] 
> **************************************************************
>
> TASK: [test] 
> ******************************************************************
> <127.0.0.1> REMOTE_MODULE command echo -e abc #USE_SHELL
> changed: [localhost -> 127.0.0.1] => {"changed": true, "cmd": "echo -e abc", 
> "delta": "0:00:00.006123", "end": "2015-09-17 11:04:00.381722", "rc": 0, 
> "start": "2015-09-17 11:04:00.375599", "stderr": "", "stdout": "-e abc", 
> "warnings": []}
>
> PLAY RECAP 
> ********************************************************************
> localhost                  : ok=1    changed=1    unreachable=0    failed=0
>
> The stdout filed shows that ansible echo a string that is -e abc which
> include the command line argument -e. I also test it without local_action
> option in the playbook. Its behavior is normal as I expected.
>
> $ cat t.yaml
> - hosts: localhost
>   remote_user: root
>   gather_facts: False
>   tasks:
>     - name: test
>       shell:  echo -e abc
>
> $ ansible-playbook -vv t.yaml
>
> PLAY [localhost] 
> **************************************************************
>
> TASK: [test] 
> ******************************************************************
> <localhost> REMOTE_MODULE command echo -e abc #USE_SHELL
> changed: [localhost] => {"changed": true, "cmd": "echo -e abc", "delta": 
> "0:00:00.001969", "end": "2015-09-17 03:06:25.842056", "rc": 0, "start": 
> "2015-09-17 03:06:25.840087", "stderr": "", "stdout": "abc", "warnings": []}
>
> PLAY RECAP 
> ********************************************************************
> localhost                  : ok=1    changed=1    unreachable=0    failed=0
>
> This time the stdout does not include the -e argument.
>
> Is there something else I need to do when use local_action and shell
> module to execute command with argument?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c683d261-56c4-4180-920d-57ed5ea717ab%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c683d261-56c4-4180-920d-57ed5ea717ab%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v94A%3D6ib4Lyk%3DRMHHs5i4O3PzQH6kM7suRbnxLite8w5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to