Skip to content

Commit

Permalink
Merge pull request #4 from Rheinwerk/PT-185097542-ansible-fqcn
Browse files Browse the repository at this point in the history
[#185136309] CI: Nutze Ansible Szenarien / [#185097542] Nutze Ansible FQCN
eifelmicha authored May 11, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents c0a6d65 + 0246463 commit 951849f
Showing 3 changed files with 17 additions and 32 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ jobs:
cmd: yq ".galaxy_info.min_ansible_container_version" ${GITHUB_WORKSPACE}/meta/main.yml

molecule:
name: Molecule for Ansible ${{ matrix.ansible_version }} / ${{ matrix.distro }} / Python ${{ matrix.python_version }}
name: Molecule for Ansible ${{ matrix.ansible_scenario }} / ${{ matrix.distro }} / Python ${{ matrix.python_version }}
runs-on: ubuntu-22.04
continue-on-error: ${{ matrix.experimental }}
needs: lint
@@ -43,27 +43,17 @@ jobs:
matrix:
include:
- distro: ubuntu-20.04
ansible_scenario: ansible_current
test_type: unit
ansible_version: '>=2.9, <2.10'
ansible_compat_version: '<3'
jinja2_version: '<3.1'
molecule_version: '<5'
python_version: '3.8'
experimental: false
- distro: ubuntu-20.04
ansible_scenario: ansible_next
test_type: unit
ansible_version: '>=2.10, <2.11'
ansible_compat_version: '<3'
jinja2_version: '<3.1'
molecule_version: '<5'
python_version: '3.8'
experimental: false
- distro: ubuntu-20.04
test_type: unit
python_version: '3.8'
jinja2_version: '<3.1'
experimental: true
- distro: ubuntu-22.04
ansible_scenario: ansible_latest
test_type: unit
python_version: '3.10'
experimental: true
@@ -72,11 +62,8 @@ jobs:
- uses: Rheinwerk/molecule@v1
with:
distro: ${{ matrix.distro }}
ansible_scenario: ${{ matrix.ansible_scenario }}
test_type: ${{ matrix.test_type }}
ansible_version: ${{ matrix.ansible_version }}
ansible_compat_version: ${{ matrix.ansible_compat_version }}
jinja2_version: ${{ matrix.jinja2_version }}
molecule_version: ${{ matrix.molecule_version }}
python_version: ${{ matrix.python_version }}

release:
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Restart scollector
service:
ansible.builtin.service:
name: scollector
state: restarted
24 changes: 11 additions & 13 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -6,36 +6,35 @@
when: _scollector.apt_repos is defined
block:
- name: Add Repo Signing Keys
apt_key:
ansible.builtin.apt_key:
id: "{{ item.key_id }}"
url: "{{ item.key_url }}"
with_items: "{{ _scollector.apt_repos }}"

- name: Add Apt Repo
apt_repository:
ansible.builtin.apt_repository:
repo: "{{ item.repo_line }}"
state: present
with_items: "{{ _scollector.apt_repos }}"
register: repo_added

- name: Apt Update
apt:
ansible.builtin.apt:
update_cache: yes
when: RW_APT_CACHE_UPDATE is defined or repo_added is changed

- name: Set install_state
set_fact:
ansible.builtin.set_fact:
install_state: latest
when: RW_ENABLE_DOWNLOADS is defined


- name: Install packages # noqa args[module]
apt:
ansible.builtin.apt:
state: "{{ install_state | default('present') }}"
name: "{{ _scollector.packages }}"

- name: Create scollector configuration file
template:
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/{{ item }}"
owner: root
@@ -50,7 +49,7 @@
when: _scollector.external_collectors is defined
block:
- name: Create external collectors directory
file:
ansible.builtin.file:
path: "{{ _scollector.external_collectors.dir }}"
state: directory
owner: root
@@ -61,7 +60,7 @@
when: _scollector.external_collectors.collectors is defined
block:
- name: Create external collectors interval directories
file:
ansible.builtin.file:
path: "{{ _scollector.external_collectors.dir }}/{{ item.interval }}"
state: directory
owner: root
@@ -72,7 +71,7 @@
- Restart scollector

- name: Create external collectors
template:
ansible.builtin.template:
src: "external_collectors/{{ item.template }}"
dest: "{{ _scollector.external_collectors.dir }}/{{ item.interval }}/{{ item.filename }}"
owner: root
@@ -82,18 +81,17 @@
notify:
- Restart scollector


- name: Include external_collectors.metric_metadata announcement
when: _scollector.external_collectors.metric_metadata is defined
block:
- name: Set curl_auth
set_fact:
ansible.builtin.set_fact:
curl_auth: "--user '{{ _scollector.auth.user }}:{{ _scollector.auth.password }}'"
when: _scollector.auth is defined

- name: Announce Meta data of external collector metrics # noqa command-instead-of-module no-changed-when
run_once: True
command: >
ansible.builtin.command: >
curl -w "%{http_code}" {{ curl_auth | default("") }} -H "Content-Type: application/json" -X POST -d '[ { "metric": "{{ item.metric }}", "name": "rate", "value": "{{ item.ratetype }}" }, { "metric": "{{ item.metric }}", "name": "unit", "value": "{{ item.unit }}" }, { "metric": "{{ item.metric }}", "name": "desc", "value": "{{ item.desc | default('') }}" } ]' {{ _scollector.server.protocol | default("https") }}://{{ _scollector.server.ip }}:{{ _scollector.server.port }}/api/metadata/put
register: result
failed_when: result.stdout != "204"

0 comments on commit 951849f

Please sign in to comment.