feat: start collectd role
This commit is contained in:
23
roles/collectd/molecule/default/INSTALL.rst
Normal file
23
roles/collectd/molecule/default/INSTALL.rst
Normal file
@@ -0,0 +1,23 @@
|
||||
*********************************
|
||||
Vagrant driver installation guide
|
||||
*********************************
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
* Vagrant
|
||||
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
|
||||
|
||||
Install
|
||||
=======
|
||||
|
||||
Please refer to the `Virtual environment`_ documentation for installation best
|
||||
practices. If not using a virtual environment, please consider passing the
|
||||
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||
|
||||
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ pip install 'molecule_vagrant'
|
20
roles/collectd/molecule/default/converge.yml
Normal file
20
roles/collectd/molecule/default/converge.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Converge
|
||||
become: yes
|
||||
hosts: all
|
||||
vars:
|
||||
- collectd_network_server: testvagrant
|
||||
- collectd_network_server: 192.168.2.240
|
||||
- collectd_network_port: 25826
|
||||
|
||||
pre_tasks:
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
- name: set hostname
|
||||
hostname:
|
||||
name: vagrantcollectd
|
||||
tasks:
|
||||
- name: "Include collectd"
|
||||
include_role:
|
||||
name: "collectd"
|
19
roles/collectd/molecule/default/molecule.yml
Normal file
19
roles/collectd/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: virtualbox
|
||||
platforms:
|
||||
- name: Debian
|
||||
box: "debian/bullseye64"
|
||||
pre_build_image: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
verifier:
|
||||
name: testinfra
|
||||
options:
|
||||
sudo: true
|
||||
v: 3
|
22
roles/collectd/molecule/default/tests/conftest.py
Normal file
22
roles/collectd/molecule/default/tests/conftest.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""PyTest Fixtures."""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
"""Run tests only when under molecule with testinfra installed."""
|
||||
try:
|
||||
import testinfra
|
||||
except ImportError:
|
||||
pytest.skip("Test requires testinfra", allow_module_level=True)
|
||||
if "MOLECULE_INVENTORY_FILE" in os.environ:
|
||||
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||
).get_hosts("all")
|
||||
else:
|
||||
pytest.skip(
|
||||
"Test should run only from inside molecule.", allow_module_level=True
|
||||
)
|
18
roles/collectd/molecule/default/tests/test_default.py
Normal file
18
roles/collectd/molecule/default/tests/test_default.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""Role testing files using testinfra."""
|
||||
import pytest
|
||||
|
||||
def test_installed_packages(host):
|
||||
collectd = host.package("collectd-core")
|
||||
assert collectd.is_installed
|
||||
|
||||
def test_config(host):
|
||||
collectd_config = host.file("/etc/collectd/collectd.conf")
|
||||
assert collectd_config.exists
|
||||
|
||||
dtypes = host.file("/usr/share/collectd/types.db")
|
||||
assert dtypes.exists
|
||||
|
||||
def test_service(host):
|
||||
collectd = host.service("collectd")
|
||||
assert collectd.is_enabled
|
||||
assert collectd.is_running
|
10
roles/collectd/molecule/default/verify.yml
Normal file
10
roles/collectd/molecule/default/verify.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
# This is an example playbook to execute Ansible tests.
|
||||
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Example assertion
|
||||
assert:
|
||||
that: true
|
Reference in New Issue
Block a user