# Tricky shell syntax error

**URL:** <https://forum.ansible.com/t/tricky-shell-syntax-error/14036>\
**Category:** Ansible Project\
**Created:** [November 29, 2013, 11:27pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036 "2013-11-29T23:27:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 29, 2013, 11:27pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/1 "2013-11-29T23:27:46Z")

</div>

I’m trying to run a task that invokes bash as part of the task. The command works directly from the user’s command line on the box but fails when run via Ansible:

Here’s the task that’s running:

- name: Install User RVM via RVM::FW  
when: rvm\_fw == True and rvm\_version.rc != 0  
shell: \bash \< \<( curl {{rvm\_fw\_url}}/releases/rvm-install-latest )  
register: rvm\_install  
failed\_when: rvm\_install.rc != 0

And the resulting output:

TASK: [ruby | Install User RVM via RVM::FW] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [33.33.33.10] =\> {“changed”: true, “cmd”: "\bash \< \<( curl [http://rvm-fw.herokuapp.com/releases/rvm-install-latest](http://rvm-fw.herokuapp.com/releases/rvm-install-latest) ) ", “delta”: “0:00:00.002708”, “end”: “2013-11-29 18:23:45.768494”, “failed”: true, “failed\_when\_result”: true, “item”: “”, “rc”: 2, “start”: “2013-11-29 18:23:45.765786”, “stdout\_lines”: }  
stderr: /bin/sh: -c: line 0: syntax error near unexpected token `<' /bin/sh: -c: line 0: `\bash \< \<( curl [http://rvm-fw.herokuapp.com/releases/rvm-install-latest](http://rvm-fw.herokuapp.com/releases/rvm-install-latest) ) ’

Any ideas on how to tweak this line so that Ansible’s shell module will pass it through properly?

Ansible version is 1.4.0 currently.

Thanks for everyone’s help as always,

Steven

---

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 29, 2013, 11:29pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/2 "2013-11-29T23:29:39Z")

</div>

Sorry, the shell action line should read:

shell: bash \< \<( curl {{rvm\_fw\_url}}/releases/rvm-install-latest )

I tried to escape it as a debug measure with no success.

Thanks!

---

<div class="post-metadata">

**Author:** ![Michel\_Blanc1](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Michel\_Blanc1](https://forum.ansible.com/u/Michel_Blanc1)\
**Post date:** [November 29, 2013, 11:53pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/3 "2013-11-29T23:53:56Z")

</div>

Hi Steven,

Any chance this can be solved by changing 'bash \< \<( curl  
{{rvm\_fw\_url}}/releases/rvm-install-latest )' to 'curl  
{{rvm\_fw\_url}}/releases/rvm-install-latest | bash' ?  
The shell module is a bit tricky sometimes 🙂

M

---

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 30, 2013, 2:03am UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/4 "2013-11-30T02:03:40Z")

</div>

Michel,

It’s definitely not the way old school RVM instructions said it had to be done, but it seems to work on this particular instance just fine!

Thanks!

---

<div class="post-metadata">

**Author:** ![Lars\_Hansson](https://avatars.discourse-cdn.com/v4/letter/l/8edcca/32.png) [@Lars\_Hansson](https://forum.ansible.com/u/Lars_Hansson)\
**Post date:** [November 30, 2013, 7:35am UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/5 "2013-11-30T07:35:56Z")

</div>

Try:

shell: “bash \< \<( curl {{rvm\_fw\_url}}/releases/rvm-install-latest )”

Cheers,  
Lars

---

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 30, 2013, 7:40am UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/6 "2013-11-30T07:40:12Z")

</div>

Lars,

Thanks. I actually tried wrapping it in quotes before posting with no change. Sorry I forgot to mention that.

-Steven

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 30, 2013, 1:01pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/7 "2013-11-30T13:01:46Z")

</div>

You should probably download a local copy of that install script, review it personally, and save it to a server or in a location you trust. Then deploy that script with the script module, which is native in Ansible.

[http://ansibleworks.com/docs/modules.html#script](http://ansibleworks.com/docs/modules.html#script)

Package systems like EPEL are at least generally signed, but it’s ridiculously easy to see a webserver compromised, for instance, in taking advantage of a bug in wordpress.

---

<div class="post-metadata">

**Author:** ![Steven\_Haddox](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@Steven\_Haddox](https://forum.ansible.com/u/Steven_Haddox)\
**Post date:** [November 30, 2013, 1:13pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/8 "2013-11-30T13:13:45Z")

</div>

Michael,

Thanks! This is incredibly wise advice. The script itself is actually from the first year of RVM’s installation process itself. The new installation script they have is considerably too complicated for me to follow and so I’ve stuck to maintaining the original one on my RVM::FW project.

I actually created and maintain the RVM::FW project (including this script). Rather than duplicating this script and copying it out myself, since others use this on internal production networks already, is there a tutorial or suggestion on how to learn about properly signing this script or securing it more soundly?

I appreciate your help as always. Ansible has already made learning it an extremely wise choice if only to help me improve some of my basic sysadmin habits.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jerome\_Wagner](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jerome\_Wagner](https://forum.ansible.com/u/Jerome_Wagner)\
**Post date:** [December 1, 2013, 6:12pm UTC](https://forum.ansible.com/t/tricky-shell-syntax-error/14036/9 "2013-12-01T18:12:01Z")

</div>

for information on why

shell: bash \< \<( curl {{rvm\_fw\_url}}/releases/rvm-install-latest )

did not work when you tried with ansible.

the notation “\<(commands)” is called “process substitution” and is a bash extension that does not exist in the bourne shell /bin/sh. It exists in other shells too.

by default, ansible systematically executes commands inside a /bin/sh shell so the \<(command) breaks with the message you got.

if you really want to execute it after Michael’s warning, it should work with :

shell: bash \< \<( curl {{rvm\_fw\_url}}/releases/rvm-install-latest ) executable=/usr/bin/bash
