From ba37378172d35f31cfbde988d471ac11a5f63dd8 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 23 Jan 2024 22:18:47 +0100 Subject: [PATCH 1/2] check_mode: Prevent get_url from being always changed. --- molecule/zabbix_agent_tests/common/playbooks/prepare.yml | 1 + roles/zabbix_agent/molecule/with-server/prepare.yml | 1 + roles/zabbix_agent/tasks/Debian.yml | 1 + roles/zabbix_javagateway/tasks/Debian.yml | 1 + roles/zabbix_proxy/tasks/Debian.yml | 1 + roles/zabbix_server/tasks/Debian.yml | 1 + roles/zabbix_web/tasks/Debian.yml | 1 + 7 files changed, 7 insertions(+) diff --git a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml index cf1100aab..5d781d0ef 100644 --- a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml +++ b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml @@ -47,6 +47,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/roles/zabbix_agent/molecule/with-server/prepare.yml b/roles/zabbix_agent/molecule/with-server/prepare.yml index 582006d4e..d02eb559e 100644 --- a/roles/zabbix_agent/molecule/with-server/prepare.yml +++ b/roles/zabbix_agent/molecule/with-server/prepare.yml @@ -75,6 +75,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/roles/zabbix_agent/tasks/Debian.yml b/roles/zabbix_agent/tasks/Debian.yml index 6ded0ba03..931e8f4db 100644 --- a/roles/zabbix_agent/tasks/Debian.yml +++ b/roles/zabbix_agent/tasks/Debian.yml @@ -65,6 +65,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_javagateway/tasks/Debian.yml b/roles/zabbix_javagateway/tasks/Debian.yml index 4c4cff06d..7cdd5bc94 100644 --- a/roles/zabbix_javagateway/tasks/Debian.yml +++ b/roles/zabbix_javagateway/tasks/Debian.yml @@ -46,6 +46,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_proxy/tasks/Debian.yml b/roles/zabbix_proxy/tasks/Debian.yml index 8e27e7d27..97aafb2fb 100644 --- a/roles/zabbix_proxy/tasks/Debian.yml +++ b/roles/zabbix_proxy/tasks/Debian.yml @@ -71,6 +71,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_server/tasks/Debian.yml b/roles/zabbix_server/tasks/Debian.yml index ccfe6f121..f03b46f2b 100644 --- a/roles/zabbix_server/tasks/Debian.yml +++ b/roles/zabbix_server/tasks/Debian.yml @@ -70,6 +70,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_web/tasks/Debian.yml b/roles/zabbix_web/tasks/Debian.yml index ae1c7de26..a1ced5f81 100644 --- a/roles/zabbix_web/tasks/Debian.yml +++ b/roles/zabbix_web/tasks/Debian.yml @@ -88,6 +88,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" + when: not ansible_check_mode # Because get_url always has changed status ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" From 5b70ed0a28c3440e5493cf920f18189a002385db Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Tue, 23 Jan 2024 22:31:23 +0100 Subject: [PATCH 2/2] Improved comments --- molecule/zabbix_agent_tests/common/playbooks/prepare.yml | 2 +- roles/zabbix_agent/molecule/with-server/prepare.yml | 2 +- roles/zabbix_agent/tasks/Debian.yml | 2 +- roles/zabbix_javagateway/tasks/Debian.yml | 2 +- roles/zabbix_proxy/tasks/Debian.yml | 2 +- roles/zabbix_server/tasks/Debian.yml | 2 +- roles/zabbix_web/tasks/Debian.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml index 5d781d0ef..2ad8efa3f 100644 --- a/molecule/zabbix_agent_tests/common/playbooks/prepare.yml +++ b/molecule/zabbix_agent_tests/common/playbooks/prepare.yml @@ -47,7 +47,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/roles/zabbix_agent/molecule/with-server/prepare.yml b/roles/zabbix_agent/molecule/with-server/prepare.yml index d02eb559e..e95cc9ad7 100644 --- a/roles/zabbix_agent/molecule/with-server/prepare.yml +++ b/roles/zabbix_agent/molecule/with-server/prepare.yml @@ -75,7 +75,7 @@ hosts: docker tasks: - name: "Download Docker CE repo file" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: https://download.docker.com/linux/centos/docker-ce.repo dest: /etc/yum.repos.d/docker-ce.repo diff --git a/roles/zabbix_agent/tasks/Debian.yml b/roles/zabbix_agent/tasks/Debian.yml index 931e8f4db..014e490b2 100644 --- a/roles/zabbix_agent/tasks/Debian.yml +++ b/roles/zabbix_agent/tasks/Debian.yml @@ -65,7 +65,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_javagateway/tasks/Debian.yml b/roles/zabbix_javagateway/tasks/Debian.yml index 7cdd5bc94..74ad4cf75 100644 --- a/roles/zabbix_javagateway/tasks/Debian.yml +++ b/roles/zabbix_javagateway/tasks/Debian.yml @@ -46,7 +46,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_proxy/tasks/Debian.yml b/roles/zabbix_proxy/tasks/Debian.yml index 97aafb2fb..31029ee18 100644 --- a/roles/zabbix_proxy/tasks/Debian.yml +++ b/roles/zabbix_proxy/tasks/Debian.yml @@ -71,7 +71,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_server/tasks/Debian.yml b/roles/zabbix_server/tasks/Debian.yml index f03b46f2b..5bd1be77f 100644 --- a/roles/zabbix_server/tasks/Debian.yml +++ b/roles/zabbix_server/tasks/Debian.yml @@ -70,7 +70,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}" diff --git a/roles/zabbix_web/tasks/Debian.yml b/roles/zabbix_web/tasks/Debian.yml index a1ced5f81..ffd12a367 100644 --- a/roles/zabbix_web/tasks/Debian.yml +++ b/roles/zabbix_web/tasks/Debian.yml @@ -88,7 +88,7 @@ (ansible_distribution == "Debian" and ansible_distribution_major_version < "12") - name: "Debian | Download gpg key" - when: not ansible_check_mode # Because get_url always has changed status + when: not ansible_check_mode # Because get_url always has changed status in check_mode. ansible.builtin.get_url: url: http://repo.zabbix.com/zabbix-official-repo.key dest: "{{ zabbix_gpg_key }}"