From 6a092d33d76fd2a535abae7b07f622f19da9437c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 31 May 2022 07:17:48 +0200 Subject: [PATCH] setup ci --- .ansible-lint.yml | 4 ++++ .drone.yml | 16 ++++++++++++++++ .envrc.sample | 18 ++++++++++++++++++ .yamllint.yml | 16 ++++++++++++++++ meta/main.yml | 5 +++-- molecule/default/molecule.yml | 9 +++++++-- requirements.txt | 4 ++++ 7 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 .ansible-lint.yml create mode 100644 .drone.yml create mode 100644 .envrc.sample create mode 100755 .yamllint.yml create mode 100644 requirements.txt diff --git a/.ansible-lint.yml b/.ansible-lint.yml new file mode 100644 index 0000000..25636f8 --- /dev/null +++ b/.ansible-lint.yml @@ -0,0 +1,4 @@ +--- +skip_list: + - fqcn-builtins + - experimental diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..c6f7df0 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,16 @@ +---- +kind: pipeline +name: default +steps: + - name: integration test + image: python:3.9-buster + environment: + REMOTE_USER: molecule + HCLOUD_TOKEN: + from_secret: HCLOUD_TOKEN + commands: + - apt update && apt install -y pwgen + - mkdir -p /root/.ansible/roles && ln -sr . /root/.ansible/roles/autonomic.netdata + - export INSTANCE_UUID=$(pwgen 8 1) + - pip install -r requirements.txt + - molecule test diff --git a/.envrc.sample b/.envrc.sample new file mode 100644 index 0000000..8a266bf --- /dev/null +++ b/.envrc.sample @@ -0,0 +1,18 @@ +# Your username that you use for accounts on our machines. +export REMOTE_USER= +export ANSIBLE_USER=$REMOTE_USER + +# The path to our pass credentials store +export PASSWORD_STORE_DIR= + +# The Hetzner Cloud API token for managing our instances +# Uncomment the prod/test line below depending on what you're doing +# export HCLOUD_TOKEN=$(pass show logins/hetzner/prod/api_key) +# export HCLOUD_TOKEN=$(pass show logins/hetzner/test/api_key) +export HCLOUD_TOKEN=$(pass show logins/hetzner/cicd/api_key) + +# For molecule role testing +export INSTANCE_UUID=$RANDOM + +# So molecule will show credentials in the logs +export MOLECULE_NO_LOG=False diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100755 index 0000000..456c99c --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,16 @@ +--- +extends: default + +yaml-files: + - "*.yaml" + - "*.yml" + +ignore: | + .venv + .drone.yml + +rules: + line-length: disable + braces: + max-spaces-inside: 1 + level: error diff --git a/meta/main.yml b/meta/main.yml index d6f09ca..b2e6c92 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,9 +2,10 @@ dependencies: [] galaxy_info: + role_name: netdata + namespace: autonomic author: autonomic - description: | - Install and configure Netdata how we need it. + description: Install and configure Netdata how we need it. company: Autonomic license: GPLv3 min_ansible_version: 2.9 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 915192b..9db0756 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -1,18 +1,23 @@ --- dependency: name: galaxy + driver: name: hetznercloud + platforms: - name: "autonomic.netdata-${INSTANCE_UUID}" server_type: "cx11" image: "debian-10" + provisioner: name: ansible + lint: | set -e - yamllint -c ../../.yamllint.yml . - ansible-lint -c ../../.ansible-lint.yml . + yamllint -c .yamllint.yml . + ansible-lint --exclude .drone.yml -c .ansible-lint.yml . + scenario: test_sequence: - lint diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7d6c96a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ansible-lint==6.0.0 +ansible==5.4.0 +molecule-hetznercloud==1.3.0 +molecule==3.6.1