From 8916f8fa2167abad24cfdd2a9e305160d83a6958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Duchaussois?= Date: Wed, 28 Apr 2021 16:49:16 +0200 Subject: feature: add sensor configuration --- molecule/features/INSTALL.rst | 15 +++++++++ molecule/features/converge.yml | 7 ++++ molecule/features/host_vars/instance-features.yml | 11 +++++++ molecule/features/molecule.yml | 21 ++++++++++++ molecule/features/prepare.yml | 19 +++++++++++ molecule/features/verify.yml | 40 +++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 molecule/features/INSTALL.rst create mode 100644 molecule/features/converge.yml create mode 100644 molecule/features/host_vars/instance-features.yml create mode 100644 molecule/features/molecule.yml create mode 100644 molecule/features/prepare.yml create mode 100644 molecule/features/verify.yml (limited to 'molecule/features') diff --git a/molecule/features/INSTALL.rst b/molecule/features/INSTALL.rst new file mode 100644 index 0000000..c615318 --- /dev/null +++ b/molecule/features/INSTALL.rst @@ -0,0 +1,15 @@ +******* +Delegated driver installation guide +******* + +Requirements +============ + +This driver is delegated to the developer. Up to the developer to implement +requirements. + +Install +======= + +This driver is delegated to the developer. Up to the developer to implement +requirements. diff --git a/molecule/features/converge.yml b/molecule/features/converge.yml new file mode 100644 index 0000000..37f6dea --- /dev/null +++ b/molecule/features/converge.yml @@ -0,0 +1,7 @@ +--- +- name: Converge + hosts: all + tasks: + - name: "Include netdata-straight" + include_role: + name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" diff --git a/molecule/features/host_vars/instance-features.yml b/molecule/features/host_vars/instance-features.yml new file mode 100644 index 0000000..fe33d25 --- /dev/null +++ b/molecule/features/host_vars/instance-features.yml @@ -0,0 +1,11 @@ +netdata_installer: kickstart-static64 +netdata_extra_config: + - name: test user + extra_groups: + - fakegroup + read_files: + - /etc/fakefile.conf + pip_dependencies: + - test-pip-install + apt_dependencies: + - hxtools diff --git a/molecule/features/molecule.yml b/molecule/features/molecule.yml new file mode 100644 index 0000000..ae3d948 --- /dev/null +++ b/molecule/features/molecule.yml @@ -0,0 +1,21 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance-features + image: jrei/systemd-ubuntu:20.04 + privileged: true + command: /lib/systemd/systemd + tmpfs: + - /run + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro +provisioner: + name: ansible + inventory: + links: + host_vars: host_vars/ +verifier: + name: ansible diff --git a/molecule/features/prepare.yml b/molecule/features/prepare.yml new file mode 100644 index 0000000..b4e8439 --- /dev/null +++ b/molecule/features/prepare.yml @@ -0,0 +1,19 @@ +- name: Prepare + hosts: all + tasks: + - name: Update apt cache + apt: + update_cache: yes + become: true + when: ansible_os_family == 'Debian' + - name: Create fakegroup + group: + name: fakegroup + state: present + - name: Create fake conf file + copy: + content: "Test file" + dest: /etc/fakefile.conf + owner: root + group: root + mode: 0600 diff --git a/molecule/features/verify.yml b/molecule/features/verify.yml new file mode 100644 index 0000000..9f64471 --- /dev/null +++ b/molecule/features/verify.yml @@ -0,0 +1,40 @@ +--- +# This is an example playbook to execute Ansible tests. +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Get netdata groups + command: id -Gzn + register: netdata_groups_st + become: true + become_user: netdata + changed_when: false + + - name: Check file access + stat: + path: /etc/fakefile.conf + become: yes + become_user: netdata + register: netdata_stat_st + + - name: Check pip package + command: test-pip-install + become: yes + become_user: netdata + changed_when: false + + - name: Check apt package + command: rot13 + args: + stdin: test + changed_when: false + + - name: Asserts config was applied + assert: + that: + - "'fakegroup' in group_array" + - netdata_can_read + vars: + group_array: "{{ netdata_groups_st.stdout.split('\0') | reject('eq','') | list }}" + netdata_can_read: "{{ netdata_stat_st.stat.readable }}" -- cgit v1.2.3