Allow jinja conditionals in package install tasks

When a jinja conditional like this is used to override the package
list:
galera_client_distro_packages:
  - mariadb-client
  - "{{ 'libmariadbclient-dev' if 'repo_all' in group_names else None }}"

Note: I also tried '' instead of None

The task fails because it cannot install a package named ''. It does
not skip the empty string. This makes it impossible to conditionally
install a package with the OSA tasks, because the override cannot be
done using group_vars due to Ansible's variable precedence prioritizing
role vars above group vars.

This change simply allows the package install task to skip empty strings,
enabling the above override.

If this pattern is accepted I intend to implement it across all of OSA's
package install tasks.

Change-Id: Ib88458d7de3f1ef4e14921b01966a79d3919fd9d
This commit is contained in:
Logan V 2016-11-20 11:30:12 -06:00
parent a7c775302e
commit 4d0d568505
2 changed files with 2 additions and 0 deletions

View File

@ -74,5 +74,6 @@
retries: 5
delay: 2
with_items: "{{ galera_client_distro_packages }}"
when: "{{ item | length > 0 }}"
tags:
- galera-client-apt-packages

View File

@ -100,5 +100,6 @@
retries: 5
delay: 2
with_items: "{{ galera_client_distro_packages }}"
when: "{{ item | length > 0 }}"
tags:
- galera-pre-yum-packages