From 9ecf237ae68e8db01ee6c5f746c3f2e6e1b26805 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Fri, 3 Nov 2023 19:54:46 -0600 Subject: [PATCH 1/9] Refactor check condition syntax --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 4821b4b..be47b03 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,7 +52,7 @@ selection: hold loop: "{{ [heartbeat_package_names] | flatten }}" changed_when: false - when: (ansible_os_family | lower) == 'debian' + when: ansible_os_family == 'Debian' - name: Enable yum package lock community.general.yum_versionlock: From 42376caa694b990eb3bfdd39e0912eea5a15e3ae Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Fri, 3 Nov 2023 20:00:13 -0600 Subject: [PATCH 2/9] Drop stale github action workflow --- .github/workflows/main.yml | 69 -------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 0ff0ab9..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -name: CI - -on: - pull_request: - push: - branches: - - master - schedule: - - cron: "0 5 * * 0" - -defaults: - run: - working-directory: 'nephelaiio.heartbeat' - -jobs: - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Check out the codebase. - uses: actions/checkout@v2 - with: - path: 'nephelaiio.heartbeat' - - - name: Set up Python 3. - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install test dependencies. - run: pip3 install ansible-lint[community,yamllint] - - - name: Lint code. - run: | - ansible-lint . - - molecule: - name: Molecule - runs-on: ubuntu-latest - strategy: - matrix: - image: - - geerlingguy/docker-ubuntu2004-ansible:latest - - geerlingguy/docker-ubuntu1804-ansible:latest - - geerlingguy/docker-ubuntu1604-ansible:latest - - geerlingguy/docker-debian10-ansible:latest - - geerlingguy/docker-centos7-ansible:latest - steps: - - name: Check out the codebase. - uses: actions/checkout@v2 - with: - path: 'nephelaiio.heartbeat' - - - name: Set up Python 3. - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install test dependencies. - run: pip3 install ansible molecule[docker] docker pytest pytest-testinfra - - - name: Run Molecule tests. - run: molecule test - env: - PY_COLORS: '1' - ANSIBLE_FORCE_COLOR: '1' - MOLECULE_DOCKER_IMAGE: ${{ matrix.image }} From 1d8a5c431c4cc215daaf6223a86392a9f612ac2f Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Fri, 3 Nov 2023 20:08:06 -0600 Subject: [PATCH 3/9] Refactor boolean literals --- README.md | 2 +- defaults/main.yml | 6 +++--- molecule/common/prepare.yml | 2 +- molecule/default/molecule.yml | 2 +- molecule/elastic/molecule.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ca310f..6a69010 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Please review the [dependency configuration](/meta/main.yml) for more details - hosts: servers vars: heartbeat_package_state: latest - heartbeat_conf_manage: yes + heartbeat_conf_manage: true heartbeat_conf: heartbeat: monitors: diff --git a/defaults/main.yml b/defaults/main.yml index 937cfd9..b8dae36 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,9 +2,9 @@ heartbeat_package_names: heartbeat-elastic heartbeat_package_state: present heartbeat_package_hold: no -heartbeat_conf_manage: yes +heartbeat_conf_manage: true heartbeat_conf_path: /etc/heartbeat/heartbeat.yml heartbeat_service_name: heartbeat-elastic heartbeat_service_status: started -heartbeat_service_enabled: yes -heartbeat_repo_manage: yes +heartbeat_service_enabled: true +heartbeat_repo_manage: true diff --git a/molecule/common/prepare.yml b/molecule/common/prepare.yml index a865f6d..a39a95e 100644 --- a/molecule/common/prepare.yml +++ b/molecule/common/prepare.yml @@ -4,5 +4,5 @@ tasks: - name: Update apt package cache ansible.builtin.apt: - update_cache: yes + update_cache: true when: ansible_os_family == 'Debian' diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index aaf10e4..8b701a4 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -28,7 +28,7 @@ provisioner: hosts: all: vars: - heartbeat_package_hold: yes + heartbeat_package_hold: true heartbeat_conf: heartbeat: monitors: diff --git a/molecule/elastic/molecule.yml b/molecule/elastic/molecule.yml index 28ae644..303d9f2 100644 --- a/molecule/elastic/molecule.yml +++ b/molecule/elastic/molecule.yml @@ -30,7 +30,7 @@ provisioner: vars: elasticsearch_repo_major_version: 8 elastic_repo_oss: false - heartbeat_package_hold: yes + heartbeat_package_hold: true heartbeat_conf: heartbeat: monitors: From 15b27ca15ccde81cb5c586d9f1416061a2d46a57 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Fri, 3 Nov 2023 20:08:37 -0600 Subject: [PATCH 4/9] Refactor boolean literals --- defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index b8dae36..3ada06e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,7 @@ --- heartbeat_package_names: heartbeat-elastic heartbeat_package_state: present -heartbeat_package_hold: no +heartbeat_package_hold: false heartbeat_conf_manage: true heartbeat_conf_path: /etc/heartbeat/heartbeat.yml heartbeat_service_name: heartbeat-elastic From 257735a4350657f38edf42e1caf4b2473c2a1273 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sat, 4 Nov 2023 11:09:17 -0600 Subject: [PATCH 5/9] Refactor molecule inventory vardefs --- molecule/common/verify.yml | 1 - molecule/default/molecule.yml | 27 +++++++++++++-------------- molecule/elastic/molecule.yml | 31 +++++++++++++++---------------- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/molecule/common/verify.yml b/molecule/common/verify.yml index 14c6787..a25f485 100644 --- a/molecule/common/verify.yml +++ b/molecule/common/verify.yml @@ -39,4 +39,3 @@ retries: 2 delay: 60 until: _output_file.stat.exists - when: diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8b701a4..0e512ee 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -25,20 +25,19 @@ provisioner: defaults: callbacks_enabled: ansible.posix.profile_tasks inventory: - hosts: + group_vars: all: - vars: - heartbeat_package_hold: true - heartbeat_conf: - heartbeat: - monitors: - - type: http - schedule: '*/1 * * * * * *' - urls: - - https://www.google.com - output: - file: - path: /tmp - filename: heartbeat + heartbeat_package_hold: true + heartbeat_conf: + heartbeat: + monitors: + - type: http + schedule: '*/1 * * * * * *' + urls: + - https://www.google.com + output: + file: + path: /tmp + filename: heartbeat verifier: name: ansible diff --git a/molecule/elastic/molecule.yml b/molecule/elastic/molecule.yml index 303d9f2..f446e4f 100644 --- a/molecule/elastic/molecule.yml +++ b/molecule/elastic/molecule.yml @@ -25,22 +25,21 @@ provisioner: defaults: callbacks_enabled: ansible.posix.profile_tasks inventory: - hosts: + group_vars: all: - vars: - elasticsearch_repo_major_version: 8 - elastic_repo_oss: false - heartbeat_package_hold: true - heartbeat_conf: - heartbeat: - monitors: - - type: http - schedule: '*/1 * * * * * *' - urls: - - https://www.google.com - output: - file: - path: /tmp - filename: heartbeat + elasticsearch_repo_major_version: 8 + elastic_repo_oss: false + heartbeat_package_hold: true + heartbeat_conf: + heartbeat: + monitors: + - type: http + schedule: '*/1 * * * * * *' + urls: + - https://www.google.com + output: + file: + path: /tmp + filename: heartbeat verifier: name: ansible From decb1bdc2f70343ec672f99596e2d907c6b13255 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sun, 5 Nov 2023 19:39:57 -0600 Subject: [PATCH 6/9] Add package version check --- .github/workflows/molecule.yml | 4 ++-- Makefile | 2 +- molecule/{default => 7x}/molecule.yml | 0 molecule/{elastic => 8x}/molecule.yml | 0 molecule/common/verify.yml | 7 +++++++ 5 files changed, 10 insertions(+), 3 deletions(-) rename molecule/{default => 7x}/molecule.yml (100%) rename molecule/{elastic => 8x}/molecule.yml (100%) diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 08e2e65..13098d7 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -23,8 +23,8 @@ jobs: strategy: matrix: scenario: - - name: default - - name: elastic + - name: 7x + - name: 8x image: - name: ubuntu2204 command: /lib/systemd/systemd diff --git a/Makefile b/Makefile index 68481e3..f36add1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: all ${MAKECMDGOALS} -MOLECULE_SCENARIO ?= default +MOLECULE_SCENARIO ?= 7x MOLECULE_DOCKER_IMAGE ?= ubuntu2004 GALAXY_API_KEY ?= GITHUB_REPOSITORY ?= $$(git config --get remote.origin.url | cut -d: -f 2 | cut -d. -f 1) diff --git a/molecule/default/molecule.yml b/molecule/7x/molecule.yml similarity index 100% rename from molecule/default/molecule.yml rename to molecule/7x/molecule.yml diff --git a/molecule/elastic/molecule.yml b/molecule/8x/molecule.yml similarity index 100% rename from molecule/elastic/molecule.yml rename to molecule/8x/molecule.yml diff --git a/molecule/common/verify.yml b/molecule/common/verify.yml index a25f485..d840e03 100644 --- a/molecule/common/verify.yml +++ b/molecule/common/verify.yml @@ -13,6 +13,13 @@ msg: "Package {{ _package }} was not deployed" when: _package not in packages + - name: Check package version + ansible.builtin.fail: + msg: "Found unexpected major version '{{ _version[0] }}' expected '{{ elasticsearch_repo_major_version }}'" + vars: + _version: "{{ packages[_package][0].version }}" + when: (_version[0] | string) != (elasticsearch_repo_major_version | string) + - name: Collect service facts ansible.builtin.service_facts: From 9865e7e983f4070753c98a618697aa2a3bd958bb Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sun, 5 Nov 2023 19:40:43 -0600 Subject: [PATCH 7/9] Add missing role to requirements file --- requirements.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.yml b/requirements.yml index d7395f7..288f940 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,3 +1,4 @@ --- roles: + - name: nephelaiio.plugins - name: nephelaiio.elastic_repo From bd480213e4ba975aeb1e1d8b5fa5b5edff9240c5 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sun, 5 Nov 2023 19:41:04 -0600 Subject: [PATCH 8/9] Rollback requirements file changes --- requirements.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.yml b/requirements.yml index 288f940..d7395f7 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,4 +1,3 @@ --- roles: - - name: nephelaiio.plugins - name: nephelaiio.elastic_repo From b1502a54d5c725d0aac5a7a4885e9d68d2f90687 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sun, 5 Nov 2023 19:47:53 -0600 Subject: [PATCH 9/9] Add missing test vardef to 7x scenario --- molecule/7x/molecule.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/molecule/7x/molecule.yml b/molecule/7x/molecule.yml index 0e512ee..6e87c11 100644 --- a/molecule/7x/molecule.yml +++ b/molecule/7x/molecule.yml @@ -27,6 +27,7 @@ provisioner: inventory: group_vars: all: + elasticsearch_repo_major_version: 7 heartbeat_package_hold: true heartbeat_conf: heartbeat: