From 28c4921182f45fe0f16796bbb496b1d95016f316 Mon Sep 17 00:00:00 2001 From: Erik Berg Date: Sun, 30 Jun 2024 05:28:41 +0200 Subject: [PATCH] Update Use of Molecule (#1303) --- .github/workflows/agent.yml | 3 -- molecule/default/collections.yml | 4 ++ molecule/default/create.docker.yml | 47 +++++++++++++++++++ molecule/default/destroy.docker.yml | 27 +++++++++++ molecule/requirements.txt | 18 +++---- .../zabbix_agent_tests/common/collections.yml | 4 ++ .../zabbix_agent_tests/common/molecule.yml | 17 +++++-- .../common/playbooks/create.yml | 25 ++++++++++ .../common/playbooks/destroy.yml | 20 ++++++++ molecule/zabbix_javagateway/molecule.yml | 19 ++++++-- molecule/zabbix_javagateway/prepare.yml | 1 + molecule/zabbix_proxy/destroy.yml | 23 --------- molecule/zabbix_proxy/molecule.yml | 17 +++++-- molecule/zabbix_proxy/prepare.yml | 43 +---------------- molecule/zabbix_repo/destroy.yml | 23 --------- molecule/zabbix_repo/molecule.yml | 17 +++++-- molecule/zabbix_repo/prepare.yml | 1 + molecule/zabbix_server/destroy.yml | 23 --------- molecule/zabbix_server/molecule.yml | 17 +++++-- molecule/zabbix_server/prepare.yml | 43 +---------------- molecule/zabbix_web/destroy.yml | 23 --------- molecule/zabbix_web/molecule.yml | 16 ++++--- molecule/zabbix_web/prepare.yml | 45 +----------------- 23 files changed, 220 insertions(+), 256 deletions(-) create mode 100644 molecule/default/collections.yml create mode 100644 molecule/default/create.docker.yml create mode 100644 molecule/default/destroy.docker.yml create mode 100644 molecule/zabbix_agent_tests/common/collections.yml create mode 100644 molecule/zabbix_agent_tests/common/playbooks/create.yml create mode 100644 molecule/zabbix_agent_tests/common/playbooks/destroy.yml delete mode 100644 molecule/zabbix_proxy/destroy.yml delete mode 100644 molecule/zabbix_repo/destroy.yml delete mode 100644 molecule/zabbix_server/destroy.yml delete mode 100644 molecule/zabbix_web/destroy.yml diff --git a/.github/workflows/agent.yml b/.github/workflows/agent.yml index 546f814fa..a3f6b1629 100644 --- a/.github/workflows/agent.yml +++ b/.github/workflows/agent.yml @@ -58,9 +58,6 @@ jobs: python -m pip install --upgrade pip pip install -r molecule/requirements.txt - - name: Install ansible.netcommon collection - run: ansible-galaxy collection install ansible.netcommon - - name: Build the collection run: | # Pin versions to speed up CI diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml new file mode 100644 index 000000000..3b6b63fdf --- /dev/null +++ b/molecule/default/collections.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: community.docker + version: ">=3.0.0" diff --git a/molecule/default/create.docker.yml b/molecule/default/create.docker.yml new file mode 100644 index 000000000..19bf77729 --- /dev/null +++ b/molecule/default/create.docker.yml @@ -0,0 +1,47 @@ +--- +- name: Create + hosts: localhost + connection: local + + gather_facts: false + + pre_tasks: + - name: Create network + community.docker.docker_network: + name: zabbix + + tasks: + - name: Create OS container(s) + community.docker.docker_container: + state: started + recreate: true + name: "{{ item.name }}" + image: "{{ item.image }}" + privileged: "{{ item.privileged | default(omit) }}" + command: "{{ item.command | default(omit) }}" + networks: "{{ item.networks | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + cgroupns_mode: "{{ item.cgroupns_mode | default(omit) }}" + loop: "{{ molecule_yml.platforms }}" + + - name: Create database container(s) + community.docker.docker_container: + name: "{{ item.name }}-db" + image: "{{ _container[_db_type].image }}" + state: started + recreate: true + networks: + - name: zabbix + env: "{{ _container[_db_type].env }}" + loop: "{{ molecule_yml.platforms }}" + when: item.groups | intersect(_database_groups) + vars: + _database_groups: ['mysql', 'pgsql'] + _db_type: "{{ item.groups | intersect(_database_groups) | first }}" + _container: + mysql: + image: "mysql:8.0" + env: { MYSQL_ROOT_PASSWORD: changeme } + pgsql: + image: "postgres:13" + env: { POSTGRES_PASSWORD: changeme } diff --git a/molecule/default/destroy.docker.yml b/molecule/default/destroy.docker.yml new file mode 100644 index 000000000..9989ef939 --- /dev/null +++ b/molecule/default/destroy.docker.yml @@ -0,0 +1,27 @@ +--- +- name: Destroy + hosts: localhost + connection: local + + gather_facts: false + + tasks: + - name: Destroy OS container(s) + community.docker.docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(True) }}" + loop: "{{ molecule_yml.platforms }}" + + - name: Destroy database container(s) + community.docker.docker_container: + name: "{{ item.name }}-db" + state: absent + force_kill: true + loop: "{{ molecule_yml.platforms }}" + + post_tasks: + - name: Destroy network + community.docker.docker_network: + name: zabbix + state: absent diff --git a/molecule/requirements.txt b/molecule/requirements.txt index 814a46a91..710d96414 100644 --- a/molecule/requirements.txt +++ b/molecule/requirements.txt @@ -1,13 +1,7 @@ # Install CI dependencies for the Zabbix Roles -#ansible==8.0.0 # commented out to avoid installing collections in site-packages/ansible_collections -ansible-compat==3.0.0 -ansible-core==2.15.11 -docker==6.1.3 -molecule<5 -molecule-docker @ git+https://github.com/ansible-community/molecule-docker@main -netaddr==1.2.1 -pytest==7.2.1 -pytest-testinfra==7.0.0 -ipaddr==2.2.0 -ipaddress==1.0.23 -requests==2.31.0 +ansible-core<2.17 +docker +molecule>=6,<24.7.0 +netaddr>=1.2.1 +pytest<8 # newer versions require python>=3.8 +pytest-testinfra<9 # newer versions require python>=3.9 diff --git a/molecule/zabbix_agent_tests/common/collections.yml b/molecule/zabbix_agent_tests/common/collections.yml new file mode 100644 index 000000000..3b6b63fdf --- /dev/null +++ b/molecule/zabbix_agent_tests/common/collections.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: community.docker + version: ">=3.0.0" diff --git a/molecule/zabbix_agent_tests/common/molecule.yml b/molecule/zabbix_agent_tests/common/molecule.yml index 4df8d8219..3dff8972f 100644 --- a/molecule/zabbix_agent_tests/common/molecule.yml +++ b/molecule/zabbix_agent_tests/common/molecule.yml @@ -1,6 +1,12 @@ --- +dependency: + name: galaxy + enabled: true + options: + requirements-file: common/collections.yml + driver: - name: docker + name: default platforms: - name: zabbix-agent-${MY_MOLECULE_CONTAINER:-centos} @@ -20,15 +26,18 @@ platforms: provisioner: name: ansible playbooks: + create: ../../common/playbooks/create.yml prepare: ../../common/playbooks/prepare.yml converge: ../../common/playbooks/converge.yml + destroy: ../../common/playbooks/destroy.yml env: ANSIBLE_REMOTE_TMP: /tmp/ - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../../../roles inventory: group_vars: all: + ansible_connection: community.docker.docker zabbix_agent_server: 192.168.3.33 zabbix_agent_serveractive: 192.168.3.33 zabbix_agent_listenip: 0.0.0.0 @@ -42,6 +51,7 @@ provisioner: zabbix_agent_version: 6.4 v60: zabbix_agent_version: 6.0 + scenario: test_sequence: - dependency @@ -56,5 +66,6 @@ scenario: - verify - cleanup - destroy + verifier: name: testinfra diff --git a/molecule/zabbix_agent_tests/common/playbooks/create.yml b/molecule/zabbix_agent_tests/common/playbooks/create.yml new file mode 100644 index 000000000..6838c2990 --- /dev/null +++ b/molecule/zabbix_agent_tests/common/playbooks/create.yml @@ -0,0 +1,25 @@ +--- +- name: Create + hosts: localhost + connection: local + + gather_facts: false + + pre_tasks: + - name: Create network + community.docker.docker_network: + name: zabbix + + tasks: + - name: "Create OS container" + community.docker.docker_container: + state: started + recreate: true + name: "{{ item.name }}" + image: "{{ item.image }}" + privileged: "{{ item.privileged | default(omit) }}" + command: "{{ item.command | default(omit) }}" + networks: "{{ item.networks | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + cgroupns_mode: "{{ item.cgroupns_mode | default(omit) }}" + loop: "{{ molecule_yml.platforms }}" diff --git a/molecule/zabbix_agent_tests/common/playbooks/destroy.yml b/molecule/zabbix_agent_tests/common/playbooks/destroy.yml new file mode 100644 index 000000000..a0ac54e58 --- /dev/null +++ b/molecule/zabbix_agent_tests/common/playbooks/destroy.yml @@ -0,0 +1,20 @@ +--- +- name: Destroy + hosts: localhost + connection: local + + gather_facts: false + + tasks: + - name: Destroy OS container(s) + community.docker.docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(True) }}" + loop: "{{ molecule_yml.platforms }}" + + post_tasks: + - name: Destroy network + community.docker.docker_network: + name: zabbix + state: absent diff --git a/molecule/zabbix_javagateway/molecule.yml b/molecule/zabbix_javagateway/molecule.yml index 7fd63247c..f6e316e3b 100644 --- a/molecule/zabbix_javagateway/molecule.yml +++ b/molecule/zabbix_javagateway/molecule.yml @@ -1,9 +1,15 @@ --- +dependency: + name: galaxy + enabled: true + options: + requirements-file: molecule/default/collections.yml + driver: - name: docker + name: default platforms: - - name: zabbix-server-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} + - name: zabbix-jgw-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest privileged: true pre_build_image: true @@ -15,14 +21,19 @@ platforms: cgroupns_mode: host groups: - ${MY_MOLECULE_VERSION:-v70} + provisioner: name: ansible + playbooks: + create: ../default/create.docker.yml + destroy: ../default/destroy.docker.yml env: - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../roles inventory: group_vars: all: + ansible_connection: community.docker.docker zabbix_repo_apt_priority: 1 zabbix_repo_yum_gpg_check: 1 v70: diff --git a/molecule/zabbix_javagateway/prepare.yml b/molecule/zabbix_javagateway/prepare.yml index 9546668b9..983479b9d 100644 --- a/molecule/zabbix_javagateway/prepare.yml +++ b/molecule/zabbix_javagateway/prepare.yml @@ -1,6 +1,7 @@ --- - name: Prepare hosts: all + pre_tasks: - name: "Installing packages on CentOS" ansible.builtin.yum: diff --git a/molecule/zabbix_proxy/destroy.yml b/molecule/zabbix_proxy/destroy.yml deleted file mode 100644 index 7ef374be5..000000000 --- a/molecule/zabbix_proxy/destroy.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(True) }}" - with_items: "{{ molecule_yml.platforms }}" - - - name: Destroy 3rd party instance(s) - docker_container: - name: "{{ item.name }}-db" - state: absent - force_kill: true - loop: "{{ molecule_yml.platforms }}" diff --git a/molecule/zabbix_proxy/molecule.yml b/molecule/zabbix_proxy/molecule.yml index d8023a9ea..216902726 100644 --- a/molecule/zabbix_proxy/molecule.yml +++ b/molecule/zabbix_proxy/molecule.yml @@ -1,6 +1,13 @@ --- +dependency: + name: galaxy + enabled: true + options: + requirements-file: molecule/default/collections.yml + driver: - name: docker + name: default + platforms: - name: zabbix-proxy-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest @@ -18,12 +25,16 @@ platforms: provisioner: name: ansible + playbooks: + create: ../default/create.docker.yml + destroy: ../default/destroy.docker.yml env: - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../roles inventory: group_vars: all: + ansible_connection: community.docker.docker zabbix_repo_apt_priority: 1 zabbix_repo_yum_gpg_check: 1 v70: diff --git a/molecule/zabbix_proxy/prepare.yml b/molecule/zabbix_proxy/prepare.yml index bdb8b0175..2c16628b8 100644 --- a/molecule/zabbix_proxy/prepare.yml +++ b/molecule/zabbix_proxy/prepare.yml @@ -1,49 +1,8 @@ --- -- name: Prepare - hosts: localhost - connection: local - pre_tasks: - - name: "Create MySQL Container" - docker_container: - name: "{{ item.name }}-db" - image: mysql:8.0 - state: started - recreate: true - networks: - - name: zabbix - env: - MYSQL_ROOT_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"mysql" in item.groups' - - - name: "Create postgresql Container" - docker_container: - name: "{{ item.name }}-db" - image: postgres:13 - state: started - recreate: true - networks: - - name: zabbix - env: - POSTGRES_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"pgsql" in item.groups' - - name: Prepare hosts: all - tasks: - - name: "Create group for imaginary host" - add_host: - name: imaginary-host - groups: - - mysql - - postgresql - changed_when: false + tasks: - name: "Installing packages on CentOS" ansible.builtin.yum: name: diff --git a/molecule/zabbix_repo/destroy.yml b/molecule/zabbix_repo/destroy.yml deleted file mode 100644 index 7ef374be5..000000000 --- a/molecule/zabbix_repo/destroy.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(True) }}" - with_items: "{{ molecule_yml.platforms }}" - - - name: Destroy 3rd party instance(s) - docker_container: - name: "{{ item.name }}-db" - state: absent - force_kill: true - loop: "{{ molecule_yml.platforms }}" diff --git a/molecule/zabbix_repo/molecule.yml b/molecule/zabbix_repo/molecule.yml index c000230a1..04d2cb03e 100644 --- a/molecule/zabbix_repo/molecule.yml +++ b/molecule/zabbix_repo/molecule.yml @@ -1,6 +1,13 @@ --- +dependency: + name: galaxy + enabled: true + options: + requirements-file: molecule/default/collections.yml + driver: - name: docker + name: default + platforms: - name: zabbix-repo-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest @@ -17,12 +24,16 @@ platforms: provisioner: name: ansible + playbooks: + create: ../default/create.docker.yml + destroy: ../default/destroy.docker.yml env: - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../roles inventory: group_vars: all: + ansible_connection: community.docker.docker zabbix_repo_apt_priority: 1 zabbix_repo_yum_gpg_check: 1 v70: diff --git a/molecule/zabbix_repo/prepare.yml b/molecule/zabbix_repo/prepare.yml index 528b89291..b9dc1bbb2 100644 --- a/molecule/zabbix_repo/prepare.yml +++ b/molecule/zabbix_repo/prepare.yml @@ -1,6 +1,7 @@ --- - name: Prepare hosts: all + tasks: - name: "Apt update" ansible.builtin.shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" diff --git a/molecule/zabbix_server/destroy.yml b/molecule/zabbix_server/destroy.yml deleted file mode 100644 index 7ef374be5..000000000 --- a/molecule/zabbix_server/destroy.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(True) }}" - with_items: "{{ molecule_yml.platforms }}" - - - name: Destroy 3rd party instance(s) - docker_container: - name: "{{ item.name }}-db" - state: absent - force_kill: true - loop: "{{ molecule_yml.platforms }}" diff --git a/molecule/zabbix_server/molecule.yml b/molecule/zabbix_server/molecule.yml index 2cd27796b..7cb4b2890 100644 --- a/molecule/zabbix_server/molecule.yml +++ b/molecule/zabbix_server/molecule.yml @@ -1,6 +1,13 @@ --- +dependency: + name: galaxy + enabled: true + options: + requirements-file: molecule/default/collections.yml + driver: - name: docker + name: default + platforms: - name: zabbix-server-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest @@ -18,12 +25,16 @@ platforms: provisioner: name: ansible + playbooks: + create: ../default/create.docker.yml + destroy: ../default/destroy.docker.yml env: - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../roles inventory: group_vars: all: + ansible_connection: community.docker.docker zabbix_repo_apt_priority: 1 zabbix_repo_yum_gpg_check: 1 v70: diff --git a/molecule/zabbix_server/prepare.yml b/molecule/zabbix_server/prepare.yml index 48d65405c..0ea40b4c9 100644 --- a/molecule/zabbix_server/prepare.yml +++ b/molecule/zabbix_server/prepare.yml @@ -1,49 +1,8 @@ --- -- name: Prepare - hosts: localhost - connection: local - pre_tasks: - - name: "Create MySQL Container" - docker_container: - name: "{{ item.name }}-db" - image: mysql:8.0 - state: started - recreate: true - networks: - - name: zabbix - env: - MYSQL_ROOT_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"mysql" in item.groups' - - - name: "Create postgresql Container" - docker_container: - name: "{{ item.name }}-db" - image: postgres:13 - state: started - recreate: true - networks: - - name: zabbix - env: - POSTGRES_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"pgsql" in item.groups' - - name: Prepare hosts: all - tasks: - - name: "Create group for imaginary host" - add_host: - name: imaginary-host - groups: - - mysql - - postgresql - changed_when: false + tasks: - name: "Installing packages on CentOS" ansible.builtin.yum: name: diff --git a/molecule/zabbix_web/destroy.yml b/molecule/zabbix_web/destroy.yml deleted file mode 100644 index 7ef374be5..000000000 --- a/molecule/zabbix_web/destroy.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" - vars: - molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" - molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}" - tasks: - - name: Destroy molecule instance(s) - docker_container: - name: "{{ item.name }}" - state: absent - force_kill: "{{ item.force_kill | default(True) }}" - with_items: "{{ molecule_yml.platforms }}" - - - name: Destroy 3rd party instance(s) - docker_container: - name: "{{ item.name }}-db" - state: absent - force_kill: true - loop: "{{ molecule_yml.platforms }}" diff --git a/molecule/zabbix_web/molecule.yml b/molecule/zabbix_web/molecule.yml index c60aff9ac..df472e86d 100644 --- a/molecule/zabbix_web/molecule.yml +++ b/molecule/zabbix_web/molecule.yml @@ -3,12 +3,12 @@ dependency: name: galaxy enabled: true options: - ignore-certs: true - ignore-errors: true + requirements-file: molecule/default/collections.yml role-file: molecule/zabbix_web/requirements.yml driver: - name: docker + name: default + platforms: - name: zabbix-web-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest @@ -27,13 +27,17 @@ platforms: provisioner: name: ansible + playbooks: + create: ../default/create.docker.yml + destroy: ../default/destroy.docker.yml env: - ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix - ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles + # https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724 + ANSIBLE_ROLES_PATH: ../../roles inventory: group_vars: all: - zabbix_api_server_url: zabbix-web-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} + ansible_connection: community.docker.docker + zabbix_api_server_url: zabbix-web-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8} zabbix_repo_apt_priority: 1 zabbix_repo_yum_gpg_check: 1 v70: diff --git a/molecule/zabbix_web/prepare.yml b/molecule/zabbix_web/prepare.yml index d67205a69..5be6bc1f8 100644 --- a/molecule/zabbix_web/prepare.yml +++ b/molecule/zabbix_web/prepare.yml @@ -1,49 +1,8 @@ --- -- name: Prepare - hosts: localhost - connection: local - pre_tasks: - - name: "Create MySQL Container" - docker_container: - name: "{{ item.name }}-db" - image: mysql:8.0 - state: started - recreate: true - networks: - - name: zabbix - env: - MYSQL_ROOT_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"mysql" in item.groups' - - - name: "Create postgresql Container" - docker_container: - name: "{{ item.name }}-db" - image: postgres:13 - state: started - recreate: true - networks: - - name: zabbix - env: - POSTGRES_PASSWORD: changeme - no_log: true - with_items: "{{ molecule_yml.platforms }}" - when: - - '"pgsql" in item.groups' - - name: Prepare hosts: all - pre_tasks: - - name: "Create group for imaginary host" - add_host: - name: imaginary-host - groups: - - mysql - - postgresql - changed_when: false + pre_tasks: - name: "Installing packages on CentOS" ansible.builtin.yum: name: @@ -175,5 +134,5 @@ ansible.builtin.file: path: "{{ item }}" state: absent - with_items: + loop: - /var/www/html/index.html