]> arthur.barton.de Git - AnsibleRoles.git/commitdiff
Always run "check tasks" to register variables, even in "check mode"
authorAlexander Barton <alex@barton.de>
Wed, 5 Apr 2017 14:07:38 +0000 (16:07 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 5 Apr 2017 14:07:38 +0000 (16:07 +0200)
Otherwise Ansible tries to use variables that are unknown because
the "register" task wasn't run.

roles/apache2-php5/tasks/main.yml
roles/check-mk-agent/tasks/main.yml
roles/mysql-server/tasks/main.yml
roles/zabbix-agent/tasks/main.yml

index 7905049dc20a964485343bfe8fdb7d539069df5e..2f028196796e5006f935618545c7eab508b7b358 100644 (file)
@@ -6,6 +6,7 @@
     - apache
     - packages
   command: dpkg --print-avail php5-apcu
+  check_mode: no
   register: php5_apcu_is_available
   failed_when: php5_apcu_is_available.rc > 1
   changed_when: no
@@ -35,7 +36,7 @@
     name=php5-apcu
   notify:
     - restart "apache2"
-  when: php5_apcu_is_available is defined and php5_apcu_is_available.rc == 0
+  when: php5_apcu_is_available.rc == 0
 
 - name: install "php-apc" cache
   tags:
@@ -46,7 +47,7 @@
     name=apc-php
   notify:
     - restart "apache2"
-  when: php5_apcu_is_available is defined and php5_apcu_is_available.rc != 0
+  when: php5_apcu_is_available.rc != 0
 
 - name: ensure service "apache2" is enabled and running
   tags:
index d907b27e84e4623e5db076ddd35c19b76dbab69d..588bf3bbc6fa055579425119ca22d2bde968d043 100644 (file)
@@ -21,6 +21,7 @@
     - packages
   stat: path=/etc/systemd/system/check_mk.socket
   when: "ansible_distribution_major_version >= '8'"
+  check_mode: no
   register: check_mk_socket_unit
 
 - name: install systemd socket unit files
@@ -34,7 +35,7 @@
     mode=644
     owner=root
     src=check_mk.socket.j2
-  when: "check_mk_socket_unit is defined and check_mk_socket_unit.stat.exists == False and ansible_distribution_major_version >= '8'"
+  when: ansible_distribution_major_version >= '8' and check_mk_socket_unit.stat.exists == False
   notify:
     - reload systemd daemon
 
@@ -49,7 +50,7 @@
     mode=644
     owner=root
     src=check_mk@.service.j2
-  when: "check_mk_socket_unit is defined and check_mk_socket_unit.stat.exists == False and ansible_distribution_major_version >= '8'"
+  when: ansible_distribution_major_version >= '8' and check_mk_socket_unit.stat.exists == False
   notify:
     - reload systemd daemon
 
index ccf898411c735c90e363b157b125687eead0d9b8..5bcc9bdf573a6d318e34cfd2f85582404c85dd98 100644 (file)
@@ -7,6 +7,7 @@
     - fs
   shell: test -d /var/lib/mysql/mysql
   ignore_errors: yes
+  check_mode: no
   register: mysql_server_installed
   changed_when: false
 
index 0118a4f90e0c9b6fd55b2237deaf0bf9426bc471..cc7898c3de363fb2898d821b72cdf359730f1db7 100644 (file)
@@ -7,6 +7,7 @@
     - zabbix
   shell: test -x /usr/sbin/zabbix_agentd
   ignore_errors: yes
+  check_mode: no
   register: zabbix_agent_installed
   changed_when: false
   when: (zabbix_agent_server != "" or zabbix_agent_server_active != "")