Hi Vince, Jonathan's approach is also valid. Just replace "include" with "include_vars" and it will work.
The group_by approach is pretty neat as it doesn't produce the pesky "skipping" entries in the run output. A useful read on precedence: http://docs.ansible.com/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable Cheers, Dan. On Tuesday, 24 March 2015 19:19:31 UTC+1, Vince Skahan wrote: > > 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/f305484e-b59d-4e5f-aeb5-666e1597c7ee%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
