From 841bfc2eec5afddd96bec902150ddfd97e2d15b8 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Thu, 11 Aug 2022 00:07:24 +1200 Subject: [PATCH] Proper role testing --- defaults/main.yml | 2 ++ meta/main.yml | 3 ++- molecule/default/cleanup.yml | 6 +++--- molecule/default/converge.yml | 6 +++++- molecule/default/molecule.yml | 23 +++++++++++++---------- tasks/Debian.yml | 5 +++++ tasks/RedHat.yml | 5 +++++ tasks/downloads/samba/main.yml | 1 + 8 files changed, 36 insertions(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 648f34e..7bfae32 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -61,3 +61,5 @@ cmk_force_install: false cmk_host_ip: "{{ ansible_host }}" cmk_dl_needs_auth: true + +cmk_debug: True diff --git a/meta/main.yml b/meta/main.yml index 0faa9a5..5aff899 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,7 +1,8 @@ galaxy_info: author: Aaron Guise description: Install checkmk agent with Enterprise Baked Agent - + role_name: check_mk_agent + namespace: cybercinch # If the issue tracker for your role is not on github, uncomment the # next line and provide a value # issue_tracker_url: http://example.com/issue/tracker diff --git a/molecule/default/cleanup.yml b/molecule/default/cleanup.yml index bc20980..790c7a7 100644 --- a/molecule/default/cleanup.yml +++ b/molecule/default/cleanup.yml @@ -14,17 +14,17 @@ - name: Delete Host uri: method: POST - url: http://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=delete_host{{ cmk_auth }} + url: https://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=delete_host{{ cmk_auth }} body: 'request={"hostname":"{{ item.name }}"}' body_format: raw status_code: 200 - no_log: true + no_log: False with_items: "{{ molecule_yml.platforms }}" - name: cmk_apply uri: method: POST - url: http://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=activate_changes&mode=specific{{ cmk_auth }} + url: https://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=activate_changes&mode=specific{{ cmk_auth }} body: 'request={"sites":["{{ cmk_omd_site }}"]}' body_format: raw status_code: 200 \ No newline at end of file diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index caf6aa1..1a8ec9d 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -8,7 +8,11 @@ cmk_omd_site: "{{ lookup('env', 'CMK_OMD_SITE') }}" cmk_username: "{{ lookup('env', 'CMK_USERNAME') }}" cmk_secret: "{{ lookup('env', 'CMK_SECRET') }}" + cmk_download_mode: "{{ lookup('env', 'CMK_DOWNLOAD_MODE') }}" + cmk_download_path: "{{ lookup('env', 'CMK_DOWNLOAD_PATH') }}" + cmk_smb_username: "{{ lookup('env', 'CMK_SMB_USERNAME') }}" + cmk_smb_password: "{{ lookup('env', 'CMK_SMB_PASSWORD') }}" tasks: - name: "Include ansible-role-cmk-agent" include_role: - name: "ansible-role-cmk-agent" + name: "ansi-ansible-role-check-mk-agent" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index ea275b0..b395e6d 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -5,27 +5,30 @@ driver: name: docker platforms: - name: rhel8 - image: guisea/centos8-ansible:latest + image: docker.io/cybercinch/docker-almalinux8-ansible # dockerfile: Centos8-Dockerfile privileged: True - volume_mounts: - - "/sys/fs/cgroup:/sys/fs/cgroup:rw" - command: "/usr/sbin/init" + command: ${MOLECULE_DOCKER_COMMAND:-"/usr/sbin/init"} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw pre_build_image: true - name: rhel7 image: guisea/centos7-ansible:latest # dockerfile: Centos7-Dockerfile privileged: True - volume_mounts: + volumes: - "/sys/fs/cgroup:/sys/fs/cgroup:rw" command: "/usr/sbin/init" pre_build_image: true provisioner: name: ansible + log: True + options: + vvv: True verifier: name: ansible -lint: | - set -e - yamllint . - ansible-lint - flake8 \ No newline at end of file +# lint: | +# set -e +# yamllint . +# ansible-lint +# flake8 \ No newline at end of file diff --git a/tasks/Debian.yml b/tasks/Debian.yml index ea31888..6ce7ec4 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -6,6 +6,11 @@ state: present notify: restart xinetd +- name: Ensure python openssl available + package: + name: python3-openssl,python3-requests + state: present + - name: Fix SeLinux Auto-Updates block: - name: list installed selinux modules diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index 33e1b1f..5739507 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -6,6 +6,11 @@ state: present notify: restart xinetd +- name: Start xinetd + service: + name: xinetd + state: started + - name: Fix SeLinux Auto-Updates block: - name: list installed selinux modules diff --git a/tasks/downloads/samba/main.yml b/tasks/downloads/samba/main.yml index f13f2d5..4e05294 100644 --- a/tasks/downloads/samba/main.yml +++ b/tasks/downloads/samba/main.yml @@ -8,6 +8,7 @@ package: name: "{{ item }}" state: present + become: True with_items: - samba-client - cifs-utils