# Slashes in shell commands

**URL:** <https://forum.ansible.com/t/slashes-in-shell-commands/16864>\
**Category:** Ansible Project\
**Created:** [November 24, 2014, 4:28pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864 "2014-11-24T16:28:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 24, 2014, 4:28pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/1 "2014-11-24T16:28:34Z")

</div>

Hi,

Prior to Ansible 1.7.2 I did not need to add slashes to the end of each line. Since this version it complains if I don’t

This causes a problem as different environments have different versions of ansible. Some 1.7, some 1.7.2

Is there a way to query the version of ansible?

For example

- name: Generate permissions  
tags:
- db
- data  
shell: \>  
chdir=“{{ release\_dir }}/some\_app”  
tclsh {{ genperms }} **\ \<---------**

-format LOAD \*_\*_  
-output\_dir “{{ release\_dir }}/reference/db” \*_\*_  
“{{ conf\_dir }}//box\_specific/some\_app.cfg”

I plan to move some of these shell commands into a module which would sort this, but I need solution that doesn’t rely on that.

Thanks

James

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 24, 2014, 4:51pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/2 "2014-11-24T16:51:39Z")

</div>

Hi James, the variable ansible\_version is available for this. Here’s an example of the debug output of this variable:

TASK: [debug var=ansible\_version] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [127.0.0.1] =\> {  
“ansible\_version”: {  
“full”: “1.8”,  
“major”: 1,  
“minor”: 8,  
“revision”: 0,  
“string”: “…”  
}  
}

The “string” portion contains what is shown when you run something like “ansible-playbook --version”, I’ve just omitted here since it’s a pretty long string.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kontusz](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@Tomasz\_Kontusz](https://forum.ansible.com/u/Tomasz_Kontusz)\
**Post date:** [November 24, 2014, 5:17pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/3 "2014-11-24T17:17:32Z")

</div>

I think ansible\_version is pretty new (1.8?), so it won’t help much with older versions

James Cammarata [jcammarata@ansible.com](mailto:jcammarata@ansible.com) napisał:

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 24, 2014, 5:32pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/4 "2014-11-24T17:32:58Z")

</div>

Yeah i’m using Ansible from EPEL so can’t just get the latest version.

I would guess the change came about from

> Improved multi-line parsing when using YAML literal blocks (using \> or |).

[https://github.com/ansible/ansible/blob/devel/CHANGELOG.md](https://github.com/ansible/ansible/blob/devel/CHANGELOG.md)

So I may just move everything to a single line until we know we are \> 1.7.2

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [November 24, 2014, 6:00pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/5 "2014-11-24T18:00:44Z")

</div>

My apologies, I didn’t check to see when we’d added that.

And yes, that change came from bugs related to newlines when parsing statements like yours, which had somewhat different behavior when using the two literal operators in YAML.

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 24, 2014, 6:14pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/6 "2014-11-24T18:14:09Z")

</div>

Hi,

No worries, I think I have a workaround

Out of interest when do you think 1.8 will make it onto epel?

Cheers

James

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 24, 2014, 10:31pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/7 "2014-11-24T22:31:27Z")

</div>

EPEL testing picks things up really quick as @nirik is super quick on those things.

It takes a while dependent on package karma to hit EPEL-EPEL.

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 25, 2014, 12:02pm UTC](https://forum.ansible.com/t/slashes-in-shell-commands/16864/8 "2014-11-25T12:02:00Z")

</div>

Ok thanks for the info Michael
