Hi all,

so far most of our servers were running RHEL 6. We are going to prepare 
some RHEL 7 servers soon and I am now
trying to rewrite our playbooks to be able cope with different releases of 
the same OS.
There is of course the "old" way of doing this like:

- name: Install packages for RHEL6
  ...
  when: ansible_distribution == RedHat and 
ansible_distribution_major_version == "6"

- name: Install packages for RHEL7
  ...
  when: ansible_distribution == RedHat and 
ansible_distribution_major_version == "7"

But I am looking for more "elegant" way of doing it (still with Ansible 1.9 
!!!) like:

- name: gather OS specific variables
  include_vars: "{{ item }}"
  with_items:
  - "{{ ansible_distribution }}/{{ ansible_distribution_major_version}}.yml"
  - common_list_of_packages_for_both_rhel_releases.yml

- name: Install the required packages
  yum: name={{ item }} state=present
  with_items: packages_to_install
  when: packages_to_install is defined
  tags: common

where packages_to_install variable is defined and combined from both files.

I guess it won't work because with_items loop will overwrite the variable 
taken from
"{{ ansible_distribution }}/{{ ansible_distribution_major_version}}.yml"
with values taken from *common_list_of_packages_for_both_rhel_releases.yml*

In ansible 2 we can use jinja2 "combine"  filter but we still use Ansible 
1.9 ....

Is there any elegant way in Ansible 1.9 to merge variables from different 
sources ?

Best regards
P



-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/95398c59-8bd6-4a53-906e-20bf7d320448%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to