From 3268d51d6acda12584a75474094070f972de88b9 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 5 Apr 2017 16:07:38 +0200 Subject: [PATCH] Always run "check tasks" to register variables, even in "check mode" Otherwise Ansible tries to use variables that are unknown because the "register" task wasn't run. --- roles/apache2-php5/tasks/main.yml | 5 +++-- roles/check-mk-agent/tasks/main.yml | 5 +++-- roles/mysql-server/tasks/main.yml | 1 + roles/zabbix-agent/tasks/main.yml | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/apache2-php5/tasks/main.yml b/roles/apache2-php5/tasks/main.yml index 7905049..2f02819 100644 --- a/roles/apache2-php5/tasks/main.yml +++ b/roles/apache2-php5/tasks/main.yml @@ -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: diff --git a/roles/check-mk-agent/tasks/main.yml b/roles/check-mk-agent/tasks/main.yml index d907b27..588bf3b 100644 --- a/roles/check-mk-agent/tasks/main.yml +++ b/roles/check-mk-agent/tasks/main.yml @@ -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 diff --git a/roles/mysql-server/tasks/main.yml b/roles/mysql-server/tasks/main.yml index ccf8984..5bcc9bd 100644 --- a/roles/mysql-server/tasks/main.yml +++ b/roles/mysql-server/tasks/main.yml @@ -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 diff --git a/roles/zabbix-agent/tasks/main.yml b/roles/zabbix-agent/tasks/main.yml index 0118a4f..cc7898c 100644 --- a/roles/zabbix-agent/tasks/main.yml +++ b/roles/zabbix-agent/tasks/main.yml @@ -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 != "") -- 2.39.2