mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 03:43:09 +00:00
Merge pull request #17 from gardar/ci/testing
feat: role/collection testing with ansible-test and molecule
This commit is contained in:
commit
5f93f50d00
84 changed files with 465 additions and 977 deletions
2
.config/ansible-lint.yml
Normal file
2
.config/ansible-lint.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
profile: production
|
60
.config/molecule/config.yml
Normal file
60
.config/molecule/config.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
lint: |
|
||||
set -e
|
||||
yamllint -c ${YAMLLINT_CONFIG_FILE} .
|
||||
ansible-lint
|
||||
platforms:
|
||||
- name: almalinux-8
|
||||
image: dokken/almalinux-8
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: centos-7
|
||||
image: dokken/centos-7
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /usr/lib/systemd/systemd
|
||||
- name: centos-stream-8
|
||||
image: dokken/centos-stream-8
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: debian-9
|
||||
image: dokken/debian-9
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: debian-10
|
||||
image: dokken/debian-10
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: debian-11
|
||||
image: dokken/debian-11
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: fedora-30
|
||||
image: dokken/fedora-30
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
- name: ubuntu-18.04
|
||||
image: dokken/ubuntu-18.04
|
||||
pre_build_image: true
|
||||
privileged: true
|
||||
cgroup_parent: docker.slice
|
||||
command: /lib/systemd/systemd
|
||||
verifier:
|
||||
name: testinfra
|
23
.config/yamllint/config.yml
Normal file
23
.config/yamllint/config.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
braces:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
brackets:
|
||||
max-spaces-inside: 1
|
||||
level: error
|
||||
colons:
|
||||
max-spaces-after: -1
|
||||
level: error
|
||||
commas:
|
||||
max-spaces-after: -1
|
||||
level: error
|
||||
empty-lines:
|
||||
max: 3
|
||||
level: error
|
||||
hyphens:
|
||||
level: error
|
||||
line-length:
|
||||
max: 160
|
98
.github/workflows/ansible-ci.yml
vendored
Normal file
98
.github/workflows/ansible-ci.yml
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
---
|
||||
name: Ansible CI
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
ANSIBLE_FORCE_COLOR: true
|
||||
|
||||
jobs:
|
||||
ansible-lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Lint collection
|
||||
uses: ansible/ansible-lint-action@main
|
||||
|
||||
discover-ansible-versions:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
versions: ${{ steps.supported-ansible-versions.outputs.result }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Get Ansible versions that the collection supports
|
||||
id: supported-ansible-versions
|
||||
uses: mikefarah/yq@master
|
||||
with:
|
||||
cmd: yq -o json -I=0 '.requires_ansible | split(",") | .[] |= sub("(.*)", "stable-${1}")' meta/runtime.yml
|
||||
|
||||
ansible-test-sanity:
|
||||
uses: ./.github/workflows/ansible-test-sanity.yml
|
||||
needs:
|
||||
- ansible-lint
|
||||
- discover-ansible-versions
|
||||
with:
|
||||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
||||
|
||||
discover-ansible-tests:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ansible-lint
|
||||
outputs:
|
||||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
||||
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get changed roles
|
||||
id: changed-roles
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
path: "roles"
|
||||
diff_relative: "true"
|
||||
files: "**"
|
||||
dir_names: "true"
|
||||
dir_names_max_depth: "1"
|
||||
since_last_remote_commit: "true"
|
||||
|
||||
- name: Discover role tests
|
||||
if: steps.changed-roles.outputs.any_changed == 'true'
|
||||
id: set-molecule-tests
|
||||
run: |
|
||||
echo tests="[`for role in ${{ steps.changed-roles.outputs.all_changed_and_modified_files }}; do
|
||||
for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -iname "molecule-${role}-*" -printf "%f\n"); do
|
||||
echo '{"test":\"'"${test}"'\","name":\"'"${test#*-}\"'"}';
|
||||
done
|
||||
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Discover integration tests
|
||||
id: set-integration-tests
|
||||
run: |
|
||||
echo tests="[`for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -not -iname "molecule-*" -printf "%f\n"); do
|
||||
echo '{"test":\"'"${test}"'\","name":\"'"${test}\"'"}';
|
||||
done | tr '\n' ',' | sed '$s/,$//'`]" >> $GITHUB_OUTPUT
|
||||
|
||||
ansible-test-molecule:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
needs:
|
||||
- discover-ansible-tests
|
||||
- discover-ansible-versions
|
||||
if: needs.discover-ansible-tests.outputs.molecule-tests != '[]' &&
|
||||
needs.discover-ansible-tests.outputs.molecule-tests != ''
|
||||
with:
|
||||
targets: ${{ needs.discover-ansible-tests.outputs.molecule-tests }}
|
||||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
||||
|
||||
ansible-test-integration:
|
||||
uses: ./.github/workflows/ansible-test-integration.yml
|
||||
needs:
|
||||
- discover-ansible-tests
|
||||
- discover-ansible-versions
|
||||
if:
|
||||
needs.discover-ansible-tests.outputs.integration-tests != '[]' &&
|
||||
needs.discover-ansible-tests.outputs.integration-tests != ''
|
||||
with:
|
||||
targets: ${{ needs.discover-ansible-tests.outputs.integration-tests }}
|
||||
ansible-core-versions: ${{ needs.discover-ansible-versions.outputs.versions }}
|
18
.github/workflows/ansible-lint.yml
vendored
18
.github/workflows/ansible-lint.yml
vendored
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
name: Ansible Lint
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
ANSIBLE_FORCE_COLOR: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Lint roles
|
||||
uses: ansible/ansible-lint-action@main
|
||||
with:
|
||||
path: roles
|
39
.github/workflows/ansible-test-integration.yml
vendored
Normal file
39
.github/workflows/ansible-test-integration.yml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
name: Ansible Integration Test
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
targets:
|
||||
required: true
|
||||
type: string
|
||||
ansible-core-versions:
|
||||
required: false
|
||||
default: '["stable-2.14"]'
|
||||
type: string
|
||||
target-python-versions:
|
||||
required: false
|
||||
default: '["default"]'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
ansible-test-integration:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
targets: ${{ fromJson(inputs.targets) }}
|
||||
ansible-core-versions: ${{ fromJson(inputs.ansible-core-versions) }}
|
||||
target-python-versions: ${{ fromJson(inputs.target-python-versions) }}
|
||||
|
||||
name: "${{ matrix.targets.name }}-${{ matrix.ansible-core-versions }}"
|
||||
steps:
|
||||
- name: "Perform ${{ matrix.targets.test }} integration test with ansible-test"
|
||||
uses: ansible-community/ansible-test-gh-action@release/v1
|
||||
with:
|
||||
ansible-core-version: ${{ matrix.ansible-core-versions }}
|
||||
target-python-version: ${{ matrix.target-python-versions }}
|
||||
controller-python-version: auto
|
||||
docker-image: "--docker-privileged" # Workaround because ansible-test action doesn't support setting privileged flag
|
||||
testing-type: integration
|
||||
target: ${{ matrix.targets.test }}
|
||||
# coverage: never # https://github.com/ansible-community/ansible-test-gh-action/pull/50
|
25
.github/workflows/ansible-test-sanity.yml
vendored
Normal file
25
.github/workflows/ansible-test-sanity.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
name: Ansible Sanity Test
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
ansible-core-versions:
|
||||
required: false
|
||||
default: '["stable-2.14"]'
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
ansible-test-sanity:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
ansible-core-versions: ${{ fromJson(inputs.ansible-core-versions) }}
|
||||
|
||||
name: "sanity-${{ matrix.ansible-core-versions }}"
|
||||
steps:
|
||||
- name: "Perform sanity test with ansible-test"
|
||||
uses: ansible-community/ansible-test-gh-action@release/v1
|
||||
with:
|
||||
ansible-core-version: ${{ matrix.ansible-core-versions }}
|
||||
testing-type: sanity
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
namespace: prometheus
|
||||
name: prometheus
|
||||
version: 0.0.1
|
||||
version: 1.0.0
|
||||
|
||||
readme: README.md
|
||||
authors:
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
---
|
||||
requires_ansible: '>=2.9.10'
|
||||
requires_ansible: "2.9,2.10,2.11,2.12,2.13,2.14"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- alertmanager
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_binary_local_dir: '/tmp/alertmanager-linux-amd64'
|
||||
alertmanager_config_dir: /opt/am/etc
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- alertmanager
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_slack_api_url: "http://example.com"
|
||||
alertmanager_receivers:
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- alertmanager
|
||||
- prometheus.prometheus.alertmanager
|
||||
vars:
|
||||
alertmanager_version: latest
|
||||
alertmanager_slack_api_url: "http://example.com"
|
|
@ -1,35 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
create: ../default/create.yml
|
||||
prepare: ../default/prepare.yml
|
||||
converge: playbook.yml
|
||||
destroy: ../default/destroy.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
- name: Download alertmanager binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/
|
||||
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/\
|
||||
alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
checksum: "sha256:{{ __alertmanager_checksum }}"
|
||||
|
|
|
@ -17,39 +17,27 @@
|
|||
alertmanager_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}"
|
||||
|
||||
- name: Discover latest version
|
||||
ansible.builtin.set_fact:
|
||||
alertmanager_version: "{{ (lookup('url', 'https://api.github.com/repos/prometheus/alertmanager/releases/latest', split_lines=False) |
|
||||
from_json).get('tag_name') | replace('v', '') }}"
|
||||
run_once: true
|
||||
until: alertmanager_version is version('0.0.0', '>=')
|
||||
retries: 10
|
||||
when:
|
||||
- alertmanager_version == "latest"
|
||||
- alertmanager_binary_local_dir | length == 0
|
||||
block:
|
||||
|
||||
- name: Get latest release
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.github.com/repos/prometheus/alertmanager/releases/latest"
|
||||
method: GET
|
||||
return_content: true
|
||||
status_code: 200
|
||||
body_format: json
|
||||
user: "{{ lookup('env', 'GH_USER') | default(omit) }}"
|
||||
password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}"
|
||||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
|
||||
register: _latest_release
|
||||
until: _latest_release.status == 200
|
||||
retries: 5
|
||||
|
||||
- name: "Set alertmanager version to {{ _latest_release.json.tag_name[1:] }}"
|
||||
ansible.builtin.set_fact:
|
||||
alertmanager_version: "{{ _latest_release.json.tag_name[1:] }}"
|
||||
alertmanager_checksum_url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt"
|
||||
|
||||
- name: Get alertmanager binary checksum
|
||||
delegate_to: localhost
|
||||
when:
|
||||
- alertmanager_binary_local_dir | length == 0
|
||||
block:
|
||||
- name: "Get checksum list"
|
||||
ansible.builtin.set_fact:
|
||||
__alertmanager_checksums: "{{ lookup('url', 'https://github.com/prometheus/alertmanager/releases/download/v' + alertmanager_version + '/sha256sums.txt', wantlist=True) | list }}"
|
||||
__alertmanager_checksums: "{{ lookup('url', 'https://github.com/prometheus/alertmanager/releases/download/v' + alertmanager_version +
|
||||
'/sha256sums.txt', wantlist=True) | list }}"
|
||||
run_once: true
|
||||
until: __alertmanager_checksums is search('linux-' + go_arch + '.tar.gz')
|
||||
retries: 10
|
||||
|
||||
- name: "Get checksum for {{ go_arch }}"
|
||||
ansible.builtin.set_fact:
|
||||
|
@ -138,5 +126,6 @@
|
|||
|
||||
- name: "`alertmanager_child_routes` is no longer supported"
|
||||
ansible.builtin.fail:
|
||||
msg: "Please move content of `alertmanager_child_routes` to `alertmanager_route.routes` as the former variable is deprecated and will be removed in future versions."
|
||||
msg: "Please move content of `alertmanager_child_routes` to `alertmanager_route.routes` as the former variable is deprecated
|
||||
and will be removed in future versions."
|
||||
when: alertmanager_child_routes is defined
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- blackbox_exporter
|
||||
- prometheus.prometheus.blackbox_exporter
|
||||
vars:
|
||||
blackbox_exporter_web_listen_address: "127.0.0.1:9000"
|
||||
blackbox_exporter_cli_flags:
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- blackbox_exporter
|
||||
- prometheus.prometheus.blackbox_exporter
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
- name: Download blackbox exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.unarchive:
|
||||
src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/
|
||||
src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/\
|
||||
blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
remote_src: true
|
||||
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/
|
||||
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/\
|
||||
blackbox_exporter"
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
- name: Propagate blackbox exporter binary
|
||||
ansible.builtin.copy:
|
||||
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/
|
||||
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/\
|
||||
blackbox_exporter"
|
||||
dest: "/usr/local/bin/blackbox_exporter"
|
||||
mode: 0750
|
||||
|
@ -56,6 +56,7 @@
|
|||
capability: cap_net_raw+ep
|
||||
state: present
|
||||
when: not ansible_check_mode
|
||||
changed_when: "'molecule-idempotence-notest' not in ansible_skip_tags"
|
||||
|
||||
- name: Check Debug Message
|
||||
ansible.builtin.debug:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- node_exporter
|
||||
- prometheus.prometheus.node_exporter
|
||||
pre_tasks:
|
||||
- name: Create node_exporter cert dir
|
||||
ansible.builtin.file:
|
||||
|
@ -11,13 +11,13 @@
|
|||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mode: u+rwX,g+rwX,o=rX
|
||||
|
||||
- name: Copy cert and key
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: "{{ item.mode | default(0644) }}"
|
||||
mode: "{{ item.mode | default('0644') }}"
|
||||
loop:
|
||||
- src: "/tmp/tls.cert"
|
||||
dest: "{{ node_exporter_tls_server_config.cert_file }}"
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- name: Download node_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/\
|
||||
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
mode: 0644
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- node_exporter
|
||||
- prometheus.prometheus.node_exporter
|
||||
vars:
|
||||
node_exporter_web_listen_address: "127.0.0.1:9100"
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,3 +1,6 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- node_exporter
|
||||
- prometheus.prometheus.node_exporter
|
||||
vars:
|
||||
node_exporter_version: latest
|
|
@ -1,35 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
create: ../default/create.yml
|
||||
prepare: ../default/prepare.yml
|
||||
converge: playbook.yml
|
||||
destroy: ../default/destroy.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
- name: Download node_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/
|
||||
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/\
|
||||
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
checksum: "sha256:{{ node_exporter_checksum }}"
|
||||
checksum: "sha256:{{ __node_exporter_checksum }}"
|
||||
mode: '0644'
|
||||
register: _download_binary
|
||||
until: _download_binary is succeeded
|
||||
|
|
|
@ -71,42 +71,30 @@
|
|||
- skip_ansible_lint
|
||||
|
||||
- name: Discover latest version
|
||||
ansible.builtin.set_fact:
|
||||
node_exporter_version: "{{ (lookup('url', 'https://api.github.com/repos/prometheus/node_exporter/releases/latest', split_lines=False) |
|
||||
from_json).get('tag_name') | replace('v', '') }}"
|
||||
run_once: true
|
||||
until: node_exporter_version is version('0.0.0', '>=')
|
||||
retries: 10
|
||||
when:
|
||||
- node_exporter_version == "latest"
|
||||
- node_exporter_binary_local_dir | length == 0
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
block:
|
||||
- name: Get latest release
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.github.com/repos/prometheus/node_exporter/releases/latest"
|
||||
method: GET
|
||||
return_content: true
|
||||
status_code: 200
|
||||
body_format: json
|
||||
user: "{{ lookup('env', 'GH_USER') | default(omit) }}"
|
||||
password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}"
|
||||
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
|
||||
register: _latest_release
|
||||
until: _latest_release.status == 200
|
||||
retries: 5
|
||||
|
||||
- name: "Set node_exporter version to {{ _latest_release.json.tag_name[1:] }}"
|
||||
ansible.builtin.set_fact:
|
||||
node_exporter_version: "{{ _latest_release.json.tag_name[1:] }}"
|
||||
|
||||
- name: Get node_exporter binary checksum
|
||||
delegate_to: localhost
|
||||
when: node_exporter_binary_local_dir | length == 0
|
||||
block:
|
||||
- name: Get checksum list from github
|
||||
ansible.builtin.set_fact:
|
||||
_checksums: "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + '/sha256sums.txt', wantlist=True) | list }}"
|
||||
__node_exporter_checksums: "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version +
|
||||
'/sha256sums.txt', wantlist=True) | list }}"
|
||||
run_once: true
|
||||
until: __node_exporter_checksums is search('linux-' + go_arch + '.tar.gz')
|
||||
retries: 10
|
||||
|
||||
- name: "Get checksum for {{ go_arch }}"
|
||||
ansible.builtin.set_fact:
|
||||
node_exporter_checksum: "{{ item.split(' ')[0] }}"
|
||||
with_items: "{{ _checksums }}"
|
||||
__node_exporter_checksum: "{{ item.split(' ')[0] }}"
|
||||
with_items: "{{ __node_exporter_checksums }}"
|
||||
when:
|
||||
- "('linux-' + go_arch + '.tar.gz') in item"
|
||||
|
|
1
roles/node_exporter/test-requirements.txt
Normal file
1
roles/node_exporter/test-requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
bcrypt
|
|
@ -90,6 +90,7 @@ prometheus_static_targets_files:
|
|||
- prometheus/targets/*.yml
|
||||
- prometheus/targets/*.json
|
||||
|
||||
# yamllint disable rule:line-length
|
||||
prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
|
||||
- alert: Watchdog
|
||||
expr: vector(1)
|
||||
|
@ -217,3 +218,4 @@ prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
|
|||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
# yamllint enable rule:line-length
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus
|
||||
- prometheus.prometheus.prometheus
|
||||
vars:
|
||||
prometheus_binary_local_dir: '/tmp/prometheus-linux-amd64'
|
||||
prometheus_config_dir: /opt/prom/etc
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus
|
||||
- prometheus.prometheus.prometheus
|
|
@ -1,75 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
# lint: |
|
||||
# set -e
|
||||
# yamllint .
|
||||
# ansible-lint
|
||||
# flake8
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,7 +1,10 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import yaml
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
@ -10,7 +13,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||
@pytest.fixture()
|
||||
def AnsibleDefaults():
|
||||
with open("defaults/main.yml", 'r') as stream:
|
||||
return yaml.load(stream)
|
||||
return yaml.full_load(stream)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dirs", [
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
hosts: all
|
||||
any_errors_fatal: true
|
||||
roles:
|
||||
- prometheus
|
||||
- prometheus.prometheus.prometheus
|
||||
vars:
|
||||
prometheus_version: latest
|
|
@ -1,35 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
create: ../default/create.yml
|
||||
prepare: ../default/prepare.yml
|
||||
converge: playbook.yml
|
||||
destroy: ../default/destroy.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
- reload prometheus
|
||||
|
||||
- name: Configure Prometheus web
|
||||
ansible.builtin.template:
|
||||
ansible.builtin.copy:
|
||||
content: "{{ prometheus_web_config | to_nice_yaml(indent=2, sort_keys=False) }}"
|
||||
dest: "{{ prometheus_config_dir }}/web.yml"
|
||||
force: true
|
||||
|
@ -46,10 +46,9 @@
|
|||
mode: 0640
|
||||
|
||||
- name: Configure prometheus static targets
|
||||
ansible.builtin.template:
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
{{ item.value | to_nice_yaml(indent=2, sort_keys=False) }}
|
||||
lstrip_blocks: true
|
||||
dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml"
|
||||
force: true
|
||||
owner: root
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
- name: Download prometheus binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/
|
||||
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/\
|
||||
prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
|
||||
checksum: "sha256:{{ __prometheus_checksum }}"
|
||||
|
|
|
@ -73,41 +73,29 @@
|
|||
- prometheus_alert_rules != []
|
||||
|
||||
- name: Discover latest version
|
||||
ansible.builtin.set_fact:
|
||||
prometheus_version: "{{ (lookup('url', 'https://api.github.com/repos/prometheus/prometheus/releases/latest', split_lines=False) |
|
||||
from_json).get('tag_name') | replace('v', '') }}"
|
||||
run_once: true
|
||||
until: prometheus_version is version('0.0.0', '>=')
|
||||
retries: 10
|
||||
when:
|
||||
- prometheus_version == "latest"
|
||||
- prometheus_binary_local_dir | length == 0
|
||||
- not prometheus_skip_install
|
||||
block:
|
||||
|
||||
- name: Get latest release
|
||||
ansible.builtin.uri:
|
||||
url: "https://api.github.com/repos/prometheus/prometheus/releases/latest"
|
||||
method: GET
|
||||
return_content: true
|
||||
status_code: 200
|
||||
body_format: json
|
||||
validate_certs: false
|
||||
user: "{{ lookup('env', 'GH_USER') | default(omit) }}"
|
||||
password: "{{ lookup('env', 'GH_TOKEN') | default(omit) }}"
|
||||
no_log: "{{ not lookup('env', 'ANSIBLE_DEBUG') | bool }}"
|
||||
register: _latest_release
|
||||
until: _latest_release.status == 200
|
||||
retries: 5
|
||||
|
||||
- name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}"
|
||||
ansible.builtin.set_fact:
|
||||
prometheus_version: "{{ _latest_release.json.tag_name[1:] }}"
|
||||
|
||||
- name: Get prometheus binary checksum
|
||||
delegate_to: localhost
|
||||
when:
|
||||
- prometheus_binary_local_dir | length == 0
|
||||
- not prometheus_skip_install
|
||||
block:
|
||||
- name: "Get checksum list"
|
||||
ansible.builtin.set_fact:
|
||||
__prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', wantlist=True) | list }}"
|
||||
__prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt',
|
||||
wantlist=True) | list }}"
|
||||
run_once: true
|
||||
until: __prometheus_checksums is search('linux-' + go_arch + '.tar.gz')
|
||||
retries: 10
|
||||
|
||||
- name: "Get checksum for {{ go_arch }}"
|
||||
ansible.builtin.set_fact:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- snmp_exporter
|
||||
- prometheus.prometheus.snmp_exporter
|
||||
vars:
|
||||
__testing_on_travis: true
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- snmp_exporter
|
||||
- prometheus.prometheus.snmp_exporter
|
||||
vars:
|
||||
__testing_on_travis: true
|
||||
snmp_exporter_web_listen_address: "127.0.0.1:9116"
|
|
@ -1,70 +1 @@
|
|||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: bionic
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-18.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: xenial
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:ubuntu-16.04
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: stretch
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-9
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: buster
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:debian-10
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos7
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-7
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
- name: centos8
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:centos-8
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
- name: fedora
|
||||
pre_build_image: true
|
||||
image: quay.io/paulfantom/molecule-systemd:fedora-30
|
||||
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
groups:
|
||||
- python3
|
||||
provisioner:
|
||||
name: ansible
|
||||
playbooks:
|
||||
prepare: prepare.yml
|
||||
converge: playbook.yml
|
||||
inventory:
|
||||
group_vars:
|
||||
python3:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
verifier:
|
||||
name: testinfra
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks: []
|
|
@ -1,6 +1,9 @@
|
|||
import pytest
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import testinfra.utils.ansible_runner
|
||||
import pytest
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
delay: 2
|
||||
notify:
|
||||
- reload snmp exporter
|
||||
when: snmp_exporter_config_file == ""
|
||||
when: not (snmp_exporter_config_file)
|
||||
|
||||
- name: Copy configuration file
|
||||
ansible.builtin.template:
|
||||
|
@ -35,4 +35,4 @@
|
|||
no_log: "{{ 'true' if __testing_on_travis is defined else 'false' }}"
|
||||
notify:
|
||||
- reload snmp exporter
|
||||
when: snmp_exporter_config_file != ""
|
||||
when: (snmp_exporter_config_file)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- name: Download snmp_exporter binary to local folder
|
||||
become: false
|
||||
ansible.builtin.get_url:
|
||||
url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/
|
||||
url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/\
|
||||
snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
|
||||
dest: "/tmp"
|
||||
checksum: "sha256:{{ snmp_exporter_checksum }}"
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
molecule>=3.0.0
|
||||
molecule-docker
|
||||
docker
|
||||
ansible-lint>=3.4.0
|
||||
testinfra>=1.7.0
|
||||
jmespath
|
||||
selinux
|
||||
passlib
|
|
@ -1,10 +1,8 @@
|
|||
# temporarily lock versions of molecule and ansible-compat to avoid a bug:
|
||||
ansible-compat==0.5.0
|
||||
molecule==3.5.2
|
||||
molecule-docker
|
||||
molecule
|
||||
docker
|
||||
ansible-lint>=3.4.0
|
||||
testinfra>=1.7.0
|
||||
ansible-lint
|
||||
pytest-testinfra
|
||||
jmespath
|
||||
selinux
|
||||
passlib
|
||||
yamllint
|
||||
|
|
42
tests/integration/molecule.sh
Executable file
42
tests/integration/molecule.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
targetname=${PWD##*/}
|
||||
role=$(expr "$targetname" : '\w*-\(\w*\)-\w*')
|
||||
role_root="$collection_root/roles/$role"
|
||||
scenario=$(expr "$targetname" : '\w*-\w*-\(\w*\)')
|
||||
ansible_version="$(ansible --version | head -1 | sed 's/[^0-9\.]*//g')"
|
||||
|
||||
# Install package requirements
|
||||
apt -y update
|
||||
apt -y install docker.io
|
||||
|
||||
# Install test requirements from role
|
||||
if [ -f "$role_root/test-requirements.txt" ]; then
|
||||
python -m pip install -r "$role_root/test-requirements.txt"
|
||||
fi
|
||||
# Install test requirements from collection
|
||||
if [ -f "$collection_root/test-requirements.txt" ]; then
|
||||
python -m pip install -r "$collection_root/test-requirements.txt"
|
||||
fi
|
||||
|
||||
# Install ansible version specific requirements
|
||||
if [ "$(printf '%s\n' "2.12" "$ansible_version" | sort -V | head -n1)" = "2.12" ]; then
|
||||
python -m pip install molecule molecule-plugins[docker]
|
||||
else
|
||||
python -m pip install molecule molecule-docker
|
||||
ansible-galaxy collection install community.docker
|
||||
ansible-galaxy collection install -r "$collection_root/requirements.yml"
|
||||
fi
|
||||
|
||||
# Define config locations within collection
|
||||
export MOLECULE_FILE=$collection_root/.config/molecule/config.yml
|
||||
export YAMLLINT_CONFIG_FILE=$collection_root/.config/yamllint/config.yml
|
||||
|
||||
# Unset ansible-test variables that break molecule
|
||||
unset _ANSIBLE_COVERAGE_CONFIG
|
||||
unset ANSIBLE_PYTHON_INTERPRETER
|
||||
|
||||
# Run molecule test
|
||||
cd "$role_root"
|
||||
molecule -c "$collection_root/.config/molecule/config.yml" test -s "$scenario"
|
4
tests/integration/targets/molecule-alertmanager-alternative/runme.sh
Executable file
4
tests/integration/targets/molecule-alertmanager-alternative/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-alertmanager-default/runme.sh
Executable file
4
tests/integration/targets/molecule-alertmanager-default/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-alertmanager-latest/runme.sh
Executable file
4
tests/integration/targets/molecule-alertmanager-latest/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-blackbox_exporter-default/runme.sh
Executable file
4
tests/integration/targets/molecule-blackbox_exporter-default/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-node_exporter-alternative/runme.sh
Executable file
4
tests/integration/targets/molecule-node_exporter-alternative/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-node_exporter-default/runme.sh
Executable file
4
tests/integration/targets/molecule-node_exporter-default/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-node_exporter-latest/runme.sh
Executable file
4
tests/integration/targets/molecule-node_exporter-latest/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-prometheus-alternative/runme.sh
Executable file
4
tests/integration/targets/molecule-prometheus-alternative/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-prometheus-default/runme.sh
Executable file
4
tests/integration/targets/molecule-prometheus-default/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-prometheus-latest/runme.sh
Executable file
4
tests/integration/targets/molecule-prometheus-latest/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-snmp_exporter-alternative/runme.sh
Executable file
4
tests/integration/targets/molecule-snmp_exporter-alternative/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
4
tests/integration/targets/molecule-snmp_exporter-default/runme.sh
Executable file
4
tests/integration/targets/molecule-snmp_exporter-default/runme.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
collection_root=$(pwd | grep -oP ".+\/ansible_collections\/\w+?\/\w+")
|
||||
source "$collection_root/tests/integration/molecule.sh"
|
Loading…
Reference in a new issue