Slashes in shell commands

133 views
Skip to first unread message

James Morgan

unread,
Nov 24, 2014, 11:28:34 AM11/24/14
to ansible...@googlegroups.com
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

James Cammarata

unread,
Nov 24, 2014, 11:51:49 AM11/24/14
to ansible...@googlegroups.com
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!


--
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/bdfe4515-bcaf-451e-9bb2-4b97397a1dcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomasz Kontusz

unread,
Nov 24, 2014, 12:17:52 PM11/24/14
to ansible...@googlegroups.com
I think ansible_version is pretty new (1.8?), so it won't help much with older versions

James Cammarata <jcamm...@ansible.com> napisał:

--
Wysłane za pomocą K-9 Mail.

James Morgan

unread,
Nov 24, 2014, 12:32:58 PM11/24/14
to ansible...@googlegroups.com

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 |).

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

James Cammarata

unread,
Nov 24, 2014, 1:00:54 PM11/24/14
to ansible...@googlegroups.com
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.

--
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.

James Morgan

unread,
Nov 24, 2014, 1:14:09 PM11/24/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Nov 24, 2014, 5:31:32 PM11/24/14
to ansible...@googlegroups.com
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.



--
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.

James Morgan

unread,
Nov 25, 2014, 7:02:00 AM11/25/14
to ansible...@googlegroups.com
Ok thanks for the info Michael
Reply all
Reply to author
Forward
0 new messages