Slashes in shell commands

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

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!

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

James Cammarata jcammarata@ansible.com napisał:

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

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

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.

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

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.

Ok thanks for the info Michael