Skip to content

Commit

Permalink
Revert "Update Use of Molecule (ansible-collections#1303)"
Browse files Browse the repository at this point in the history
This reverts commit 28c4921.
  • Loading branch information
eb4x committed Jul 7, 2024
1 parent 88513a7 commit 8e146f4
Show file tree
Hide file tree
Showing 23 changed files with 256 additions and 220 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ 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
Expand Down
4 changes: 0 additions & 4 deletions molecule/default/collections.yml

This file was deleted.

47 changes: 0 additions & 47 deletions molecule/default/create.docker.yml

This file was deleted.

27 changes: 0 additions & 27 deletions molecule/default/destroy.docker.yml

This file was deleted.

18 changes: 12 additions & 6 deletions molecule/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Install CI dependencies for the Zabbix Roles
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
#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
4 changes: 0 additions & 4 deletions molecule/zabbix_agent_tests/common/collections.yml

This file was deleted.

17 changes: 3 additions & 14 deletions molecule/zabbix_agent_tests/common/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
---
dependency:
name: galaxy
enabled: true
options:
requirements-file: common/collections.yml

driver:
name: default
name: docker

platforms:
- name: zabbix-agent-${MY_MOLECULE_CONTAINER:-centos}
Expand All @@ -26,18 +20,15 @@ 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/
# https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724
ANSIBLE_ROLES_PATH: ../../../../roles
ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/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
Expand All @@ -51,7 +42,6 @@ provisioner:
zabbix_agent_version: 6.4
v60:
zabbix_agent_version: 6.0

scenario:
test_sequence:
- dependency
Expand All @@ -66,6 +56,5 @@ scenario:
- verify
- cleanup
- destroy

verifier:
name: testinfra
25 changes: 0 additions & 25 deletions molecule/zabbix_agent_tests/common/playbooks/create.yml

This file was deleted.

20 changes: 0 additions & 20 deletions molecule/zabbix_agent_tests/common/playbooks/destroy.yml

This file was deleted.

19 changes: 4 additions & 15 deletions molecule/zabbix_javagateway/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
---
dependency:
name: galaxy
enabled: true
options:
requirements-file: molecule/default/collections.yml

driver:
name: default
name: docker

platforms:
- name: zabbix-jgw-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_CONTAINER:-rockylinux8}
- name: zabbix-server-${MY_MOLECULE_VERSION:-v70}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8}
image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest
privileged: true
pre_build_image: true
Expand All @@ -21,19 +15,14 @@ platforms:
cgroupns_mode: host
groups:
- ${MY_MOLECULE_VERSION:-v70}

provisioner:
name: ansible
playbooks:
create: ../default/create.docker.yml
destroy: ../default/destroy.docker.yml
env:
# https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724
ANSIBLE_ROLES_PATH: ../../roles
ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
all:
ansible_connection: community.docker.docker
zabbix_repo_apt_priority: 1
zabbix_repo_yum_gpg_check: 1
v70:
Expand Down
1 change: 0 additions & 1 deletion molecule/zabbix_javagateway/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Prepare
hosts: all

pre_tasks:
- name: "Installing packages on CentOS"
ansible.builtin.yum:
Expand Down
23 changes: 23 additions & 0 deletions molecule/zabbix_proxy/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- 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 }}"
17 changes: 3 additions & 14 deletions molecule/zabbix_proxy/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
---
dependency:
name: galaxy
enabled: true
options:
requirements-file: molecule/default/collections.yml

driver:
name: default

name: docker
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
Expand All @@ -25,16 +18,12 @@ platforms:

provisioner:
name: ansible
playbooks:
create: ../default/create.docker.yml
destroy: ../default/destroy.docker.yml
env:
# https://github.com/ansible/molecule/issues/4015#issuecomment-1680859724
ANSIBLE_ROLES_PATH: ../../roles
ANSIBLE_COLLECTIONS_PATHS: $HOME/.ansible/collections/ansible_collections/community/zabbix
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
all:
ansible_connection: community.docker.docker
zabbix_repo_apt_priority: 1
zabbix_repo_yum_gpg_check: 1
v70:
Expand Down
43 changes: 42 additions & 1 deletion molecule/zabbix_proxy/prepare.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
---
- name: Prepare
hosts: all
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

- name: "Installing packages on CentOS"
ansible.builtin.yum:
name:
Expand Down
23 changes: 23 additions & 0 deletions molecule/zabbix_repo/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- 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 }}"
Loading

0 comments on commit 8e146f4

Please sign in to comment.