Can't dynamically choose module based on version

If the condition is in a when attribute, the module is still
evaluated. If it doesn't exist in the current verison of Ansible
it will blow up.
This commit is contained in:
Jérémy Lecour 2017-02-09 17:36:49 +01:00 committed by Jérémy Lecour
parent aac8e90c21
commit 6ed870e94e

View file

@ -114,7 +114,7 @@
## alert5
- name: "Install alert5 init script"
- name: Install alert5 init script
template:
src: system/init_alert5.j2
dest: /etc/init.d/alert5
@ -122,26 +122,21 @@
mode: "755"
when: evolinux_system_alert5_init
#TODO: switch service/systemd modules with Ansible 2.2+
- name: Enable alert5 init script
service:
name: alert5
enabled: yes
when:
- ansible_version.major == 2
- ansible_version.minor < 2
- evolinux_system_alert5_init
- evolinux_system_alert5_enable
when: evolinux_system_alert5_init and evolinux_system_alert5_enable
- name: Enable alert5 init script
systemd:
name: alert5
daemon_reload: yes
enabled: yes
when:
- ansible_version.major == 2
- ansible_version.minor >= 2
- evolinux_system_alert5_init
- evolinux_system_alert5_enable
# - name: Enable alert5 init script
# systemd:
# name: alert5
# daemon_reload: yes
# enabled: yes
# when: evolinux_system_alert5_init and evolinux_system_alert5_enable
## network interfaces