Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Fix tags issues #16

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ jobs:
fail-fast: false
matrix:
include:
- distro: debian8
- distro: debian10
- distro: ubuntu1604
ansible-version: '>=2.10, <2.11'
- distro: ubuntu1604
ansible-version: '>=9, <10'
- distro: debian11
- distro: debian12
- distro: ubuntu1804
ansible-version: '>=9, <10'
- distro: ubuntu2004
- distro: ubuntu2204
- distro: ubuntu2404

steps:
- name: Check out the codebase
Expand All @@ -64,8 +66,8 @@ jobs:
python-version: '3.x'

- name: Install test dependencies
run: pip install 'ansible${{ matrix.ansible-version }}' molecule[docker] docker

run: |
pip install 'ansible${{ matrix.ansible-version }}' molecule-plugins[docker] docker
- name: Run Molecule tests
run: |
molecule test
Expand Down
36 changes: 25 additions & 11 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
role = File.basename(File.expand_path(File.dirname(__FILE__)))

boxes = [
{
:name => "ubuntu-1604",
:box => "bento/ubuntu-16.04",
:ip => '10.0.0.12',
:cpu => "50",
:ram => "256"
},
{
:name => "ubuntu-1804",
:box => "bento/ubuntu-18.04",
Expand All @@ -23,14 +16,21 @@ boxes = [
:box => "bento/ubuntu-20.04",
:ip => '10.0.0.14',
:cpu => "50",
:ram => "384"
:ram => "512"
},
{
:name => "debian-8",
:box => "bento/debian-8",
:name => "ubuntu-2204",
:box => "bento/ubuntu-22.04",
:ip => '10.0.0.15',
:cpu => "50",
:ram => "512"
},
{
:name => "ubuntu-2404",
:box => "bento/ubuntu-24.04",
:ip => '10.0.0.16',
:cpu => "50",
:ram => "256"
:ram => "512"
},
{
:name => "debian-10",
Expand All @@ -39,6 +39,20 @@ boxes = [
:cpu => "50",
:ram => "256"
},
{
:name => "debian-11",
:box => "bento/debian-11",
:ip => '10.0.0.19',
:cpu => "50",
:ram => "256"
},
{
:name => "debian-12",
:box => "bento/debian-12",
:ip => '10.0.0.20',
:cpu => "50",
:ram => "384"
},
]

Vagrant.configure("2") do |config|
Expand Down
6 changes: 4 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ galaxy_info:
platforms:
- name: Ubuntu
versions:
- xenial
- bionic
- focal
- jammy
- noble
- name: Debian
versions:
- jessie
- buster
- bullseye
- bookworm
galaxy_tags:
- system
- monitoring
Expand Down
6 changes: 1 addition & 5 deletions molecule/default/collections.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
---
collections:
- name: community.docker
version: '>=1.2.0,<2'
- name: community.general
version: '>=2,<3'
collections: []
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ driver:
name: docker
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu1604}-ansible:latest"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
Expand Down
12 changes: 5 additions & 7 deletions tasks/configure-3.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# tasks file
---
- name: configure | apache htpasswd users

Check warning on line 3 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
community.general.htpasswd:
path: /etc/nagios3/htpasswd.users
name: "{{ item.name }}"
password: "{{ item.password }}"
mode: 0644
mode: '0644'
with_items: "{{ nagios_server_htpasswd_users }}"
tags:
- nagios-server-configure-apache-htpasswd-users

- name: configure | copy cgi file

Check warning on line 13 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/cgi.cfg.j2
dest: /etc/nagios3/cgi.cfg
owner: "{{ nagios_server_default_owner }}"
group: "{{ nagios_server_default_group }}"
# Needed for www-data to read this file
mode: 0644
mode: '0644'
notify: reload nagios-server
tags:
- nagios-server-configure-copy-cgi-file

- name: configure | copy commands file

Check warning on line 25 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/commands.cfg.j2
dest: /etc/nagios3/commands.cfg
Expand All @@ -33,7 +33,7 @@
tags:
- nagios-server-configure-copy-commands-file

- name: configure | copy resource file

Check warning on line 36 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/resource.cfg.j2
dest: /etc/nagios3/resource.cfg
Expand All @@ -44,7 +44,7 @@
tags:
- nagios-server-configure-copy-resource-file

- name: configure | copy contacts files

Check warning on line 47 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/conf.d/contacts_nagios2.cfg.j2
dest: /etc/nagios3/conf.d/contacts_nagios2.cfg
Expand All @@ -55,7 +55,7 @@
tags:
- nagios-server-configure-copy-contacts-files

- name: configure | copy hostextinfo files

Check warning on line 58 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/conf.d/extinfo_nagios2.cfg.j2
dest: /etc/nagios3/conf.d/extinfo_nagios2.cfg
Expand All @@ -66,7 +66,7 @@
tags:
- nagios-server-configure-copy-hostextinfo-files

- name: configure | copy hostgroups files

Check warning on line 69 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/conf.d/hostgroups_nagios2.cfg.j2
dest: /etc/nagios3/conf.d/hostgroups_nagios2.cfg
Expand All @@ -77,7 +77,7 @@
tags:
- nagios-server-configure-copy-hostgroups-files

- name: configure | copy generic service template file

Check warning on line 80 in tasks/configure-3.yml

View workflow job for this annotation

GitHub Actions / Lint

name[casing]

All names should start with an uppercase letter.
ansible.builtin.template:
src: etc/nagios3/conf.d/generic-service_nagios2.cfg.j2
dest: /etc/nagios3/conf.d/generic-service_nagios2.cfg
Expand Down Expand Up @@ -134,8 +134,10 @@
- nagios-server-configure-copy-host-files

- name: configure | check external commands
when: nagios_server_check_external_commands | bool
tags:
- nagios-server-configure-check-external-commands
block:

- name: configure | set command dir permissions
ansible.builtin.file:
path: /var/lib/nagios3/rw
Expand All @@ -154,10 +156,6 @@
line: check_external_commands=1
notify: reload nagios-server

when: nagios_server_check_external_commands | bool
tags:
- nagios-server-configure-check-external-commands

- name: configure | regular expression matching option
ansible.builtin.lineinfile:
path: "{{ nagios_server_etc_nagios3_nagios_file }}"
Expand Down
14 changes: 6 additions & 8 deletions tasks/configure-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
dest: /etc/nagios4/htdigest.users
owner: "{{ nagios_server_default_owner }}"
group: "{{ nagios_server_default_owner }}"
mode: 0644
mode: '0644'
tags:
- nagios-server-configure-apache-htpasswd-users

Expand All @@ -16,7 +16,7 @@
dest: /etc/nagios4/apache2.conf
owner: "{{ nagios_server_default_owner }}"
group: "{{ nagios_server_default_owner }}"
mode: 0644
mode: '0644'
notify: reload nagios-server
tags:
- nagios-server-configure-copy-apache-file
Expand All @@ -28,7 +28,7 @@
owner: "{{ nagios_server_default_owner }}"
group: "{{ nagios_server_default_group }}"
# Needed for www-data to read this file
mode: 0644
mode: '0644'
notify: reload nagios-server
tags:
- nagios-server-configure-copy-cgi-file
Expand Down Expand Up @@ -145,8 +145,10 @@
- nagios-server-configure-copy-services-files

- name: configure | check external commands
when: nagios_server_check_external_commands | bool
tags:
- nagios-server-configure-check-external-commands
block:

- name: configure | set command dir permissions
ansible.builtin.file:
path: /var/lib/nagios4/rw
Expand All @@ -165,10 +167,6 @@
line: check_external_commands=1
notify: reload nagios-server

when: nagios_server_check_external_commands | bool
tags:
- nagios-server-configure-check-external-commands

- name: configure | regular expression matching option
ansible.builtin.lineinfile:
path: "{{ nagios_server_etc_nagios4_nagios_file }}"
Expand Down
22 changes: 12 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,33 @@
- nagios-server
- nagios-server-include-variables

- ansible.builtin.import_tasks: install.yml
- name: install
ansible.builtin.import_tasks: install.yml
tags:
- configuration
- nagios-server
- nagios-server-install

- ansible.builtin.import_tasks: private-keys.yml
- name: private-keys
ansible.builtin.import_tasks: private-keys.yml
tags:
- configuration
- nagios-server
- nagios-server-private-keys

- name: configure
block:
- name: >
ansible.builtin.include_tasks: configure-3.yml
when: nagios_server_major_version is version('3', '=')

- name: >
ansible.builtin.include_tasks: configure-4.yml
when: nagios_server_major_version is version('4', '=')
tags:
- configuration
- nagios-server
- nagios-server-configure
block:
- name: configure 3
ansible.builtin.import_tasks: configure-3.yml
when: nagios_server_major_version is version('3', '=')

- name: configure 4
ansible.builtin.import_tasks: configure-4.yml
when: nagios_server_major_version is version('4', '=')

- name: start and enable service
ansible.builtin.service:
Expand Down
2 changes: 1 addition & 1 deletion tasks/private-keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
state: directory
owner: "{{ item.owner | default('nagios') }}"
group: "{{ item.group | default(item.owner) | default('nagios') }}"
mode: 0700
mode: '0700'
with_items: "{{ nagios_server_private_keys }}"
when: item.state is undefined or item.state == 'present'
tags:
Expand Down
5 changes: 3 additions & 2 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# test file
---
- hosts: localhost
- name: converge
hosts: localhost
connection: local
become: true
pre_tasks:
- name: include vars
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
- name: include tasks
ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml"
ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
5 changes: 3 additions & 2 deletions tests/vagrant.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# test file
---
- hosts: all
- name: converge
hosts: all
remote_user: vagrant
become: true
pre_tasks:
- name: include vars
ansible.builtin.include_vars: "{{ playbook_dir }}/vars/main.yml"
- name: include tasks
ansible.builtin.include_tasks: "{{ playbook_dir }}/tasks/pre.yml"
ansible.builtin.import_tasks: "{{ playbook_dir }}/tasks/pre.yml"
roles:
- ../../
Loading