Tell ansible to don't escape quotes in shell

2,037 views
Skip to first unread message

Bruno Galindro da Costa

unread,
Jun 7, 2015, 10:10:30 AM6/7/15
to ansible...@googlegroups.com
How can I tell to ansible to execute this command in shell without double quote escaping?

- name: Configure S3 bucket for website
  shell
: aws s3api put-bucket-website --bucket {{ item }} --website-configuration "$(< /tmp/s3_config_{{ item }}.json)"
  with_items
: frontend_s3_buckets
  environment
:
    AWS_ACCESS_KEY_ID
: "{{ ansible_aws_access_key_id }}"
    AWS_SECRET_ACCESS_KEY
: "{{ ansible_aws_secret_access_key }}"
  tags
:
   
- frontend_s3


My problem is: when the command is executed, it is sent to shell with double quotes escaped:


TASK: [frontend_s3 | Configure S3 bucket for website] *************************
failed
: [54.94.253.5] => (item=teste.socialbase.com.br) => {"changed": true, "cmd": "aws s3api put-bucket-website --bucket teste.socialbase.com.br --website-configuration \"$(< /tmp/s3_config_test.json)\"", "delta": "0:00:00.199463", "end": "2015-06-07 13:54:28.956900", "item": "teste.socialbase.com.br", "rc": 255, "start": "2015-06-07 13:54:28.757437", "warnings": []}
stderr
:
string index out of range

FATAL
: all hosts have already failed -- aborting


It is executing as follows:

aws s3api put-bucket-website --bucket {{ item }} --website-configuration \"$(< /tmp/s3_config_test.json)\"



But I need that it execute the command without double quote escaping, as follows:

aws s3api put-bucket-website --bucket {{ item }} --website-configuration "$(< /tmp/s3_config_test.json)"







Brian Coca

unread,
Jun 8, 2015, 10:17:20 AM6/8/15
to ansible...@googlegroups.com
it needs to be escaped as it runt throush shell + ssh + shell +shell,
but it should end up being exactly what you put in, but it does print
to debug a quoted version that is being fed through the pipeline.




--
Brian Coca

Bruno Galindro da Costa

unread,
Jun 19, 2015, 12:47:36 PM6/19/15
to ansible...@googlegroups.com
Sorry but I don't understand what do you said. I've made a workarround: copy a templated script to remote host and executing it there.

You are saying that it is impossible to do this task as I tried before? If no, how would you solve this problem without using a script?

Brian Coca

unread,
Jun 19, 2015, 12:49:12 PM6/19/15
to ansible...@googlegroups.com
No, I'm saying the escaping in needed for your command line to survive
the transport to the end shell, but that the escapes should be
stripped out by then.
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/857295a1-c79c-4835-b56e-72395e39729f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages