variable fun

--Michael

Hi,

I am using the devel branch from github.
Two problems for me with variables:

1)

Thanks for testing!

Are you saying only_if is not expanding variables or are you saying only_if is generally not working?

Since there is a considerable amount of refactoring in 0.5, it is highly likely "only_if" doesn't presently interpolate, which is an easy fix.

If you want to help, you could add some debug code to runner to see what the conditional (it's called conditional in runner/__init__.py I recall) and print that out to quickly isolate this.

- hosts: app201:app505m
vars:
is_cen5: "'ansible_distribution_version' == '5.8'"
is_cen6: "'ansible_distribution_version' == '6.2'"
tasks:
- name: deploy centos5 specific monitoring
action: copy src=../monitoring/cen5_proc.py dest=/home/mweber/proc.py owner=mweber group=users mode=0740
only_if: "$is_cen5"
- name: deploy centos6 specific monitoring
action: copy src=../monitoring/cen6_proc.py dest=/home/mweber/proc.py owner=mweber group=users mode=0740
only_if: "$is_cen6"

This doesn't work.

TASK: [deploy centos5 specific monitoring] *********************

skipping: [app505]

skipping: [app201]

2)

- hosts: app505:app201
user: mweber
sudo: True
tasks:
- name: roll out ${item}
action: copy src=../monitoring/$item dest=/home/mweber/$item owner=mweber group=users mode=0740
with_items:
- cpu.py
- io.py
- proc.py
- guardian.py
- net.py

TASK: [roll out cpu.py] *********************

fatal: [app505] => file or module does not exist: ../monitoring/$item
fatal: [app201] => file or module does not exist: ../monitoring/$item

This seems to say with_items isn't interpolating right, but it might be specific to file, I'm not sure. Please file an issue in github so we can take a look.

Thanks for testing!

Are you saying only_if is not expanding variables or are you saying only_if is generally not working?

Since there is a considerable amount of refactoring in 0.5, it is highly likely “only_if” doesn’t presently interpolate, which is an easy fix.

If you want to help, you could add some debug code to runner to see what the conditional (it’s called conditional in runner/init.py I recall) and print that out to quickly isolate this.

I will look into the code on the weekend. Thanks!

This seems to say with_items isn’t interpolating right, but it might be specific to file, I’m not sure. Please file an issue in github so we can take a look.

Will do.