Quoting the "=" seems to do the trick at least in my trivial test:
$ ansible -v -m raw -a 'env -i ABC\=blah /usr/bin/printenv' localhost Using /etc/ansible/ansible.cfg as config file localhost | SUCCESS | rc=0 >> ABC=blah On Tuesday, 29 March 2016 19:49:37 UTC+1, Johannes Kastl wrote: > > Am 29.03.16 schrieb Johannes Kastl: > > >> I opened issue 15191: > >> https://github.com/ansible/ansible/issues/15191 > <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fansible%2Fansible%2Fissues%2F15191&sa=D&sntz=1&usg=AFQjCNG1Uh_USaTPHiHx_Jxaxeye9ybdDw> > > > > > ...and I closed the issue, as I found the problem: > > > > The quoted string has to be quoted again, otherwise the controller's > > shell will eat the quotes and the "env ASSUME..." part... > > Once again I eat my words. Seems to become a habit... > > The twice-quoted command runs and returns a success message, but > apparently does nothing. > > Using the following playbook works: > > > - hosts: all > > gather_facts: false > > become_method: sudo > > become: yes > > tasks: > > - name: Bootstrapping pkg > > raw: /usr/sbin/pkg -N > > register: pkg > > ignore_errors: True > > > > - raw: /usr/bin/env ASSUME_ALWAYS_YES=1 /usr/sbin/pkg bootstrap -f > > when: pkg|failed > > > > - name: install python > > raw: /usr/sbin/pkg install -y python27 > > So it seems to be some kind of quoting hell. How to quote the argument > for the raw module in a way that everything works? > > > ansible -m raw -a 'env ASSUME_ALWAYS_YES=YES pkg bootstrap -f' foobar > hangs waiting for the confirmation > > > ansible -m raw -a "env ASSUME_ALWAYS_YES=YES pkg bootstrap -f" foobar > hangs waiting for the confirmation > > > ansible -m raw -a '"env ASSUME_ALWAYS_YES=YES pkg bootstrap -f"' foobar > returns with success, but does nothing > > > ansible -m raw -a "'env ASSUME_ALWAYS_YES=YES pkg bootstrap -f'" foobar > returns with success, but does nothing > > > ansible -m raw -a "\"env ASSUME_ALWAYS_YES=YES pkg bootstrap -f\"" > foobar > returns with success, but does nothing > > Regards, > Johannes > > > -- 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/a1a4b53b-ed49-441b-8132-7d83f0a0d52b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
