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 35b0422
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 49 deletions.
34 changes: 21 additions & 13 deletions molecule/absent/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
hosts: all
gather_facts: false
tasks:
- name: "Get service facts"
ansible.builtin.service_facts:
- name: "Check if /tmp/unsupported_distro file exists"
ansible.builtin.stat:
path: "/tmp/unsupported_distro"
register: unsupported_distro_file

- name: "Check netdata service is stopped"
ansible.builtin.fail:
msg: "Netdata service is started"
when: "'netdata' in services and services['netdata']['state'] == 'started'"
- name: "Verify"
when: not unsupported_distro_file.stat.exists
block:
- name: "Get service facts"
ansible.builtin.service_facts:

- name: "Check netdata dashboard port to closed"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: stopped
delay: 5
timeout: 10
- name: "Check netdata service is stopped"
ansible.builtin.fail:
msg: "Netdata service is started"
when: "'netdata' in services and services['netdata']['state'] == 'started'"

- name: "Check netdata dashboard port to closed"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: stopped
delay: 5
timeout: 10
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
42 changes: 25 additions & 17 deletions molecule/cloud/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@
hosts: all
gather_facts: false
tasks:
- name: "Get service facts"
ansible.builtin.service_facts:
- name: "Check if /tmp/unsupported_distro file exists"
ansible.builtin.stat:
path: "/tmp/unsupported_distro"
register: unsupported_distro_file

- 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: "Verify"
when: not unsupported_distro_file.stat.exists
block:
- name: "Get service facts"
ansible.builtin.service_facts:

- 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 service is started"
ansible.builtin.fail:
msg: "netdata service is not started"
when: "'netdata' in services and services['netdata']['state'] != 'running'"

- name: "Check netdata dashboard port to closed"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: stopped
delay: 5
timeout: 10
- 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 closed"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: stopped
delay: 5
timeout: 10
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
32 changes: 32 additions & 0 deletions molecule/local/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- name: "Verify"

Check failure on line 1 in molecule/local/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

yaml[document-start]

Missing document start "---"

Check warning on line 1 in molecule/local/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

1:1 [document-start] missing document start "---"
hosts: all
gather_facts: false
tasks:
- name: "Check if /tmp/unsupported_distro file exists"
ansible.builtin.stat:
path: "/tmp/unsupported_distro"
register: unsupported_distro_file

- name: "Verify"
when: not unsupported_distro_file.stat.exists
block:
- 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"
42 changes: 25 additions & 17 deletions molecule/static-build/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@
hosts: all
gather_facts: false
tasks:
- name: "Get service facts"
ansible.builtin.service_facts:
- name: "Check if /tmp/unsupported_distro file exists"
ansible.builtin.stat:
path: "/tmp/unsupported_distro"
register: unsupported_distro_file

- 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: "Verify"
when: not unsupported_distro_file.stat.exists
block:
- name: "Get service facts"
ansible.builtin.service_facts:

- 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 service is started"
ansible.builtin.fail:
msg: "netdata service is not started"
when: "'netdata' in services and services['netdata']['state'] != 'running'"

- name: "Check netdata dashboard port to open"
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: "19999"
state: started
delay: 5
timeout: 10
- 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
26 changes: 26 additions & 0 deletions tasks/distro-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: "Check if distro or architecture are supported"
ansible.builtin.set_fact:
distro_supported: false
when: >
supported_distros | selectattr("name", "equalto", ansible_distribution) | list | length == 0 or
ansible_distribution_version is version(supported_distros | selectattr("name", "equalto", ansible_distribution) | map(attribute="min_version") | first, "<") or
ansible_architecture not in (supported_distros | selectattr("name", "equalto", ansible_distribution) | map(attribute="supported_architectures", default=[]) | first)
- name: "Check if distro or architecture are supported"
ansible.builtin.debug:
msg: "{{ ansible_distribution }} {{ ansible_distribution_version }} on {{ ansible_architecture }} is not supported"
when: distro_supported is false

# For molecule testing only
- name: "Create file if distro is not supported"
ansible.builtin.copy:
dest: "/tmp/unsupported_distro"
content: "unsupported"
mode: "0644"
no_log: true
when: distro_supported is false and "molecule-notest" in ansible_skip_tags

- name: "Skip role if distro or architecture is not supported"
ansible.builtin.meta: end_play
when: distro_supported is false
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
13 changes: 13 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
supported_distros:
- { name: "AlmaLinux", min_version: "8", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "Amazon", min_version: "2023", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "CentOS", min_version: "7", supported_architectures: "['x86_64']" }
- { name: "Debian", min_version: "10", supported_architectures: "['x86_64', 'i686', 'aarch64', 'armv7l']" }
- { name: "Fedora", min_version: "37", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "openSUSE Leap", min_version: "15.4", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "openSUSE Tumbleweed", min_version: "", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "OracleLinux", min_version: "8", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "RedHat", min_version: "8", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "Suse", min_version: "15.2", supported_architectures: "['x86_64', 'aarch64']" }
- { name: "Ubuntu", min_version: "20.04", supported_architectures: "['x86_64', 'i686', 'armv7l']" }

0 comments on commit 35b0422

Please sign in to comment.