On Tuesday, March 24, 2015 at 6:46:27 AM UTC-7, Jonathan Davila wrote:
>
> You could try to variablize the values of the module parameters into 
> os-specific vars files and then do conditional include statements based on 
> the os.
> Where you would have files named like debian-7.yml, etc. And within those 
> files you would have serial_regex/replace defined along with any other vars.
> Does that help?
>
>
Notionally yes, but ansible doesn't seem to like variables in - include: 
statements.

Does ansible do 'include' before 'gather_facts' perhaps ?????
If so, that would be a pretty major bug/misfeature to me...

Here's an example that shows the problem.

- hosts: all
  gather_facts: yes
  tasks:
    - debug: msg="{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml"
    - include: "{{ ansible_distribution }}-{{ ansible_distribution_version 
}}.yml"


Running that trivial playbook fails:


ERROR: file could not read: /tmp/{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml



But if you try to debug only (after commenting out the include: line) the 
fact collection works ok:


PLAY [all] 
********************************************************************

GATHERING FACTS 
***************************************************************
ok: [192.168.0.169]

TASK: [debug msg="{{ ansible_distribution }}-{{ 
ansible_distribution_version }}.yml"] ***
ok: [192.168.0.169] => {
    "msg": "Debian-7.8.yml"
}

PLAY RECAP 
********************************************************************
192.168.0.169              : ok=2    changed=0    unreachable=0    failed=0



I tried similar things setting variables, custom facts, etc. to no avail. 
 Seems like ansible includes first as it does its runs (???)

 

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6f20b3bf-ec4f-4bea-a7d3-c75f0c2f34f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to