Skip to content

Commit

Permalink
Merge pull request #5 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
  • Loading branch information
eifelmicha authored May 11, 2023
2 parents 3fd30f5 + 647f36d commit 6d9061d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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
group: root
mode: 0755

- name: Create external collectors interval directories
file:
ansible.builtin.file:
path: "{{ _scollector.external_collectors.dir }}/{{ item.interval }}"
state: directory
owner: root
Expand All @@ -21,7 +21,7 @@
with_items: "{{ _scollector.external_collectors.collectors }}"

- name: Create external collectors
template:
ansible.builtin.template:
src: "/etc/ansible/templates/external_collectors/{{ item.template }}"
dest: "{{ _scollector.external_collectors.dir }}/{{ item.interval }}/{{ item.filename }}"
owner: root
Expand All @@ -30,7 +30,7 @@
with_items: "{{ _scollector.external_collectors.collectors }}"

- name: Create scollector configuration file
template:
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "/{{ item }}"
owner: root
Expand All @@ -43,12 +43,12 @@
when: _scollector.oom_score_adj is defined
block:
- name: Check if SystemD Unit file for scollector exists
stat:
ansible.builtin.stat:
path: /etc/systemd/system/scollector.service
register: stat_scollector_systemd

- name: Set oom score for scollector in systemd
lineinfile:
ansible.builtin.lineinfile:
dest: "/etc/systemd/system/scollector.service"
state: present
regexp: '^OOMScoreAdjust='
Expand All @@ -58,7 +58,7 @@
when: stat_scollector_systemd.stat.exists

- name: Reload service definitions
systemd:
ansible.builtin.systemd:
daemon_reload: yes
when: systemd_reload.changed

Expand All @@ -67,7 +67,7 @@
block:
- name: Announce Meta data of external collector metrics # noqa ignore-errors
run_once: true
uri:
ansible.builtin.uri:
method: POST
url: "{{ _scollector.server.protocol | default('https') }}://{{ _scollector.server.ip }}:{{ _scollector.server.port }}/api/metadata/put"
url_username: "{{ _scollector.auth.user }}"
Expand Down
8 changes: 4 additions & 4 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
become_user: root

pre_tasks:
- file: name="/etc/logrotate.d" state=directory owner="root" group="root" mode="0755"
- file: name="/etc/bosun" state=directory owner="root" group="root" mode="0755"
- file: name="/etc/ansible/templates/external_collectors" state=directory owner="root" group="root" mode="0755"
- copy: content="Nothing here" dest="/etc/ansible/templates/external_collectors/sample_metric.sh.j2" owner="root" group="root" mode="0644"
- ansible.builtin.file: name="/etc/logrotate.d" state=directory owner="root" group="root" mode="0755"
- ansible.builtin.file: name="/etc/bosun" state=directory owner="root" group="root" mode="0755"
- ansible.builtin.file: name="/etc/ansible/templates/external_collectors" state=directory owner="root" group="root" mode="0755"
- ansible.builtin.copy: content="Nothing here" dest="/etc/ansible/templates/external_collectors/sample_metric.sh.j2" owner="root" group="root" mode="0644"
roles:
- ansible-role-update_scollector_config

0 comments on commit 6d9061d

Please sign in to comment.