From c74694eca37f67eb63a5470a8b9155ef6187aab3 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 2 Dec 2024 16:46:33 +0100 Subject: [PATCH 1/5] Fix tags issues --- tasks/main.yml | 4 ++-- tests/test.yml | 2 +- tests/vagrant.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5f39b23..db1d821 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,11 +26,11 @@ - name: configure block: - name: > - ansible.builtin.include_tasks: configure-3.yml + ansible.builtin.import_tasks: configure-3.yml when: nagios_server_major_version is version('3', '=') - name: > - ansible.builtin.include_tasks: configure-4.yml + ansible.builtin.import_tasks: configure-4.yml when: nagios_server_major_version is version('4', '=') tags: - configuration diff --git a/tests/test.yml b/tests/test.yml index df06614..69b9404 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -7,6 +7,6 @@ - name: include vars ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" - name: include tasks - ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ diff --git a/tests/vagrant.yml b/tests/vagrant.yml index a5209fc..0dff732 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -7,6 +7,6 @@ - name: include vars ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml" - name: include tasks - ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml" + ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml" roles: - ../../ From c5ab3bcdcd36d4f97afd29cda8e03ba0f969fb0f Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 2 Dec 2024 16:54:33 +0100 Subject: [PATCH 2/5] Cs fixes --- tasks/configure-3.yml | 8 +++----- tasks/configure-4.yml | 8 +++----- tasks/main.yml | 14 ++++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tasks/configure-3.yml b/tasks/configure-3.yml index 75355b3..7c7fe22 100644 --- a/tasks/configure-3.yml +++ b/tasks/configure-3.yml @@ -134,8 +134,10 @@ - nagios-server-configure-copy-host-files - name: configure | check external commands + when: nagios_server_check_external_commands | bool + tags: + - nagios-server-configure-check-external-commands block: - - name: configure | set command dir permissions ansible.builtin.file: path: /var/lib/nagios3/rw @@ -154,10 +156,6 @@ line: check_external_commands=1 notify: reload nagios-server - when: nagios_server_check_external_commands | bool - tags: - - nagios-server-configure-check-external-commands - - name: configure | regular expression matching option ansible.builtin.lineinfile: path: "{{ nagios_server_etc_nagios3_nagios_file }}" diff --git a/tasks/configure-4.yml b/tasks/configure-4.yml index 367cb05..b745db1 100644 --- a/tasks/configure-4.yml +++ b/tasks/configure-4.yml @@ -145,8 +145,10 @@ - nagios-server-configure-copy-services-files - name: configure | check external commands + when: nagios_server_check_external_commands | bool + tags: + - nagios-server-configure-check-external-commands block: - - name: configure | set command dir permissions ansible.builtin.file: path: /var/lib/nagios4/rw @@ -165,10 +167,6 @@ line: check_external_commands=1 notify: reload nagios-server - when: nagios_server_check_external_commands | bool - tags: - - nagios-server-configure-check-external-commands - - name: configure | regular expression matching option ansible.builtin.lineinfile: path: "{{ nagios_server_etc_nagios4_nagios_file }}" diff --git a/tasks/main.yml b/tasks/main.yml index db1d821..a47feb4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,19 +11,25 @@ - nagios-server - nagios-server-include-variables -- ansible.builtin.import_tasks: install.yml +- name: install + ansible.builtin.import_tasks: install.yml tags: - configuration - nagios-server - nagios-server-install -- ansible.builtin.import_tasks: private-keys.yml +- name: private-keys + ansible.builtin.import_tasks: private-keys.yml tags: - configuration - nagios-server - nagios-server-private-keys - name: configure + tags: + - configuration + - nagios-server + - nagios-server-configure block: - name: > ansible.builtin.import_tasks: configure-3.yml @@ -32,10 +38,6 @@ - name: > ansible.builtin.import_tasks: configure-4.yml when: nagios_server_major_version is version('4', '=') - tags: - - configuration - - nagios-server - - nagios-server-configure - name: start and enable service ansible.builtin.service: From 4aadb6bb8cfe3625a106160c2a8a79dc2af79d8a Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 2 Dec 2024 16:56:15 +0100 Subject: [PATCH 3/5] Cs fixes --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a47feb4..b89b978 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -31,11 +31,11 @@ - nagios-server - nagios-server-configure block: - - name: > + - name: configure 3 ansible.builtin.import_tasks: configure-3.yml when: nagios_server_major_version is version('3', '=') - - name: > + - name: configure 4 ansible.builtin.import_tasks: configure-4.yml when: nagios_server_major_version is version('4', '=') From c5bb33f0c24ffc20c6def9b0e69dd7c84b7d0f04 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 2 Dec 2024 16:59:52 +0100 Subject: [PATCH 4/5] Consistency changes --- .github/workflows/ci.yml | 13 ++++++------ Vagrantfile | 36 ++++++++++++++++++++++---------- meta/main.yml | 6 ++++-- molecule/default/collections.yml | 6 +----- molecule/default/molecule.yml | 2 +- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c735949..70e6297 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,13 +44,14 @@ jobs: fail-fast: false matrix: include: - - distro: debian8 - distro: debian10 - - distro: ubuntu1604 - ansible-version: '>=2.10, <2.11' - - distro: ubuntu1604 + - distro: debian11 + - distro: debian12 - distro: ubuntu1804 + ansible-version: '>=9, <10' - distro: ubuntu2004 + - distro: ubuntu2204 + - distro: ubuntu2404 steps: - name: Check out the codebase @@ -64,8 +65,8 @@ jobs: python-version: '3.x' - name: Install test dependencies - run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker - + run: | + pip install 'ansible${{ matrix.ansible-version }}' molecule-plugins[docker] docker - name: Run Molecule tests run: | molecule test diff --git a/Vagrantfile b/Vagrantfile index 70934e8..e86d32d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,13 +4,6 @@ role = File.basename(File.expand_path(File.dirname(__FILE__))) boxes = [ - { - :name => "ubuntu-1604", - :box => "bento/ubuntu-16.04", - :ip => '10.0.0.12', - :cpu => "50", - :ram => "256" - }, { :name => "ubuntu-1804", :box => "bento/ubuntu-18.04", @@ -23,14 +16,21 @@ boxes = [ :box => "bento/ubuntu-20.04", :ip => '10.0.0.14', :cpu => "50", - :ram => "384" + :ram => "512" }, { - :name => "debian-8", - :box => "bento/debian-8", + :name => "ubuntu-2204", + :box => "bento/ubuntu-22.04", + :ip => '10.0.0.15', + :cpu => "50", + :ram => "512" + }, + { + :name => "ubuntu-2404", + :box => "bento/ubuntu-24.04", :ip => '10.0.0.16', :cpu => "50", - :ram => "256" + :ram => "512" }, { :name => "debian-10", @@ -39,6 +39,20 @@ boxes = [ :cpu => "50", :ram => "256" }, + { + :name => "debian-11", + :box => "bento/debian-11", + :ip => '10.0.0.19', + :cpu => "50", + :ram => "256" + }, + { + :name => "debian-12", + :box => "bento/debian-12", + :ip => '10.0.0.20', + :cpu => "50", + :ram => "384" + }, ] Vagrant.configure("2") do |config| diff --git a/meta/main.yml b/meta/main.yml index ebcb8d3..032e88b 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -10,13 +10,15 @@ galaxy_info: platforms: - name: Ubuntu versions: - - xenial - bionic - focal + - jammy + - noble - name: Debian versions: - - jessie - buster + - bullseye + - bookworm galaxy_tags: - system - monitoring diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml index c3d7e2a..1062b36 100644 --- a/molecule/default/collections.yml +++ b/molecule/default/collections.yml @@ -1,6 +1,2 @@ --- -collections: - - name: community.docker - version: '>=1.2.0,<2' - - name: community.general - version: '>=2,<3' +collections: [] diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8841165..908aaf6 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,7 +5,7 @@ driver: name: docker platforms: - name: instance - image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest" + image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest" command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:rw From d0f2d80edee2c97e9839a9aaf9e97f346d096beb Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 2 Dec 2024 20:33:12 +0100 Subject: [PATCH 5/5] Cs fixes --- .github/workflows/ci.yml | 1 + tasks/configure-3.yml | 4 ++-- tasks/configure-4.yml | 6 +++--- tasks/private-keys.yml | 2 +- tests/test.yml | 3 ++- tests/vagrant.yml | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70e6297..d204d7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: matrix: include: - distro: debian10 + ansible-version: '>=9, <10' - distro: debian11 - distro: debian12 - distro: ubuntu1804 diff --git a/tasks/configure-3.yml b/tasks/configure-3.yml index 7c7fe22..6cb7ab8 100644 --- a/tasks/configure-3.yml +++ b/tasks/configure-3.yml @@ -5,7 +5,7 @@ path: /etc/nagios3/htpasswd.users name: "{{ item.name }}" password: "{{ item.password }}" - mode: 0644 + mode: '0644' with_items: "{{ nagios_server_htpasswd_users }}" tags: - nagios-server-configure-apache-htpasswd-users @@ -17,7 +17,7 @@ owner: "{{ nagios_server_default_owner }}" group: "{{ nagios_server_default_group }}" # Needed for www-data to read this file - mode: 0644 + mode: '0644' notify: reload nagios-server tags: - nagios-server-configure-copy-cgi-file diff --git a/tasks/configure-4.yml b/tasks/configure-4.yml index b745db1..e01e3a5 100644 --- a/tasks/configure-4.yml +++ b/tasks/configure-4.yml @@ -6,7 +6,7 @@ dest: /etc/nagios4/htdigest.users owner: "{{ nagios_server_default_owner }}" group: "{{ nagios_server_default_owner }}" - mode: 0644 + mode: '0644' tags: - nagios-server-configure-apache-htpasswd-users @@ -16,7 +16,7 @@ dest: /etc/nagios4/apache2.conf owner: "{{ nagios_server_default_owner }}" group: "{{ nagios_server_default_owner }}" - mode: 0644 + mode: '0644' notify: reload nagios-server tags: - nagios-server-configure-copy-apache-file @@ -28,7 +28,7 @@ owner: "{{ nagios_server_default_owner }}" group: "{{ nagios_server_default_group }}" # Needed for www-data to read this file - mode: 0644 + mode: '0644' notify: reload nagios-server tags: - nagios-server-configure-copy-cgi-file diff --git a/tasks/private-keys.yml b/tasks/private-keys.yml index c9d7cc9..68bcd2f 100644 --- a/tasks/private-keys.yml +++ b/tasks/private-keys.yml @@ -6,7 +6,7 @@ state: directory owner: "{{ item.owner | default('nagios') }}" group: "{{ item.group | default(item.owner) | default('nagios') }}" - mode: 0700 + mode: '0700' with_items: "{{ nagios_server_private_keys }}" when: item.state is undefined or item.state == 'present' tags: diff --git a/tests/test.yml b/tests/test.yml index 69b9404..35bffb6 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,6 +1,7 @@ # test file --- -- hosts: localhost +- name: converge + hosts: localhost connection: local become: true pre_tasks: diff --git a/tests/vagrant.yml b/tests/vagrant.yml index 0dff732..e355251 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -1,6 +1,7 @@ # test file --- -- hosts: all +- name: converge + hosts: all remote_user: vagrant become: true pre_tasks: