Skip to content

Commit

Permalink
new system requires checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Apr 19, 2024
1 parent d795427 commit 16096f7
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 2 deletions.
1 change: 0 additions & 1 deletion molecule/cloud/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
- name: "Converge"
hosts: all
gather_facts: false
become: false
vars:
netdata_cloud_enable: true
netdata_cloud_claim_token: this-is-a-test-token
Expand Down
6 changes: 6 additions & 0 deletions molecule/local/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: "Converge"
hosts: all
gather_facts: false
roles:
- role: "dgibbs64.netdata"
18 changes: 18 additions & 0 deletions molecule/local/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: "${MOLECULE_IMAGE:-ubuntu2204}"
image: "geerlingguy/docker-${MOLECULE_IMAGE:-ubuntu2204}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: true
pre_build_image: true
cgroupns_mode: host
provisioner:
name: ansible
verifier:
name: ansible
25 changes: 25 additions & 0 deletions molecule/local/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: "Verify"
hosts: all
gather_facts: false
tasks:
- name: "Get service facts"
ansible.builtin.service_facts:

- name: "Check netdata service is started"
ansible.builtin.fail:
msg: "netdata service is not started"
when: "'netdata' in services and services['netdata']['state'] != 'running'"

- name: "Check netdata service is enabled"
ansible.builtin.fail:
msg: "netdata service is not enabled"
when: "'netdata' in services and services['netdata.service']['status'] != 'enabled'"

- name: "Check netdata dashboard port to open"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: started
delay: 5
timeout: 10
1 change: 0 additions & 1 deletion molecule/static-build/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
- name: "Converge"
hosts: all
gather_facts: false
become: false
roles:
- role: "dgibbs64.netdata"
15 changes: 15 additions & 0 deletions tasks/distro-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: "Check if distro or architecture are supported"
ansible.builtin.debug:
msg: "{{ ansible_distribution }} {{ ansible_distribution_version }} on {{ ansible_architecture }} is not supported"
when: >
supported_distros | selectattr("name", "equalto", ansible_os_family) | list | length == 0 or
ansible_distribution_version is version(supported_distros | selectattr("name", "equalto", ansible_os_family) | map(attribute="min_version") | first, "<") or
ansible_architecture not in (supported_distros | selectattr("name", "equalto", ansible_os_family) | map(attribute="supported_architectures", default=[]) | first)
- name: "Skip role if distro or architecture is not supported"
ansible.builtin.meta: end_play
when: >
supported_distros | selectattr("name", "equalto", ansible_os_family) | list | length == 0 or
ansible_distribution_version is version(supported_distros | selectattr("name", "equalto", ansible_os_family) | map(attribute="min_version") | first, "<") or
ansible_architecture not in (supported_distros | selectattr("name", "equalto", ansible_os_family) | map(attribute="supported_architectures", default=[]) | first)
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
ansible.builtin.import_tasks: assert-all.yml
delegate_to: localhost

- name: "Distro Requirements"
ansible.builtin.include_tasks: distro-requirements.yml

- name: "Become block"
become: true
block:
Expand Down
10 changes: 10 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
supported_distros:
- { name: "Amazon", min_version: "2023" }
- { name: "Debian", min_version: "10", supported_architectures: "['x86_64', 'i686', 'aarch64', 'armv7l']" }
- { name: "Fedora", min_version: "35" }
- { name: "Suse", min_version: "15.2" }
- { name: "OracleLinux", min_version: "8" }
- { name: "RedHat", min_version: "9" }
- { name: "CentOS", min_version: "8" }
- { name: "Ubuntu", min_version: "18.04" }

0 comments on commit 16096f7

Please sign in to comment.