Update project - add molecule

This commit is contained in:
2021-05-19 12:07:32 +12:00
parent 7619781008
commit c9619afbf7
7 changed files with 96 additions and 23 deletions

6
.ansible-lint Normal file
View File

@@ -0,0 +1,6 @@
# .ansible-lint
skip_list:
- role-name
- package-latest
warn_list: # or 'skip_list' to silence them completely
- package-latest # Package installs should not use latest

43
.gitignore vendored Normal file
View File

@@ -0,0 +1,43 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,ansible
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,ansible
### Ansible ###
*.retry
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# .cache dir for molecule
.cache
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,ansible
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

View File

@@ -2,18 +2,25 @@
dependency:
name: galaxy
driver:
name: docker
name: podman
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-"/usr/sbin/init"}
command: ${MOLECULE_DOCKER_COMMAND:-""}
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
privileged: true
privileged: ${MOLECULE_PRIV:-false}
pre_build_image: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -17,7 +17,9 @@
- default.yml
- include: main_rh.yml
when: ansible_os_family == 'RedHat'
when: >
ansible_os_family == 'RedHat' or
ansible_os_family == 'Rocky'
- include: main_deb.yml
when: ansible_os_family == 'Debian'
@@ -37,7 +39,7 @@
mode={{ rsyslog_file_mode }}
notify:
- restart rsyslog
when: rsyslog_os_supported == True
when: rsyslog_os_supported
- name: remove existing (custom/additional) configurations
tags:
@@ -46,7 +48,7 @@
file:
state: absent
path: "{{ rsyslog_include_path }}/"
when: purge_config == True
when: purge_config
- name: create additional configuration directory
tags:
@@ -58,7 +60,7 @@
group={{ rsyslog_file_group }}
mode={{ rsyslog_file_mode }}
state=directory
when: rsyslog_os_supported == True
when: rsyslog_os_supported
- name: setup default additional configuration
tags:
@@ -66,7 +68,7 @@
- files
template: >
src=rsyslog.snippet.conf.j2
dest={{ rsyslog_include_path }}/{{item.name}}.conf
dest={{ rsyslog_include_path }}/{{ item.name }}.conf
owner={{ rsyslog_file_owner }}
group={{ rsyslog_file_group }}
mode={{ rsyslog_file_mode }}
@@ -85,7 +87,9 @@
- '*.* /var/log/uncategorized.log'
notify:
- restart rsyslog
when: rsyslog_default_config == "True" and rsyslog_os_supported == True
when: >
rsyslog_default_config and
rsyslog_os_supported
- name: setup additional configurations
tags:
@@ -93,7 +97,7 @@
- files
template: >
src=rsyslog.snippet.conf.j2
dest={{ rsyslog_include_path }}/{{item.name}}.conf
dest={{ rsyslog_include_path }}/{{ item.name }}.conf
owner={{ rsyslog_file_owner }}
group={{ rsyslog_file_group }}
mode={{ rsyslog_file_mode }}
@@ -101,7 +105,7 @@
- "{{ items }}"
notify:
- restart rsyslog
when: rsyslog_os_supported == True
when: rsyslog_os_supported
- name: Reload systemd
systemd:
@@ -112,5 +116,4 @@
- rsyslog
- configuration
service: name={{ rsyslog_service_name }} enabled=yes state=started
when: rsyslog_os_supported == True
when: rsyslog_os_supported

View File

@@ -7,5 +7,7 @@
tags:
- rsyslog
- packages
pacman: pkg={{item}} state=installed
pacman:
pkg: '{{ rsyslog_package_names }}'
state: installed
with_items: '{{ rsyslog_package_names }}'

View File

@@ -3,23 +3,29 @@
- name: Import Adiscon rsyslog Key for apt
apt_key: keyserver=keys.gnupg.net id=AEF0CF8E state=present
when: use_repo == True and ansible_distribution == 'Debian'
when: >
use_repo and
ansible_distribution == 'Debian'
## TODO: v8-stable for debian wheezy only available at this time, sanitize selection
## http://www.rsyslog.com/debian-repository/
- name: Enable Adiscon rsyslog apt repo
apt_repository: repo='deb http://debian.adiscon.com/v8-stable wheezy/' state=present filename='rsyslog' update_cache='yes'
when: use_repo == True and ansible_distribution == 'Debian'
when: >
use_repo and
ansible_distribution == 'Debian'
## TODO: v8-stable/v7-stable available, for "ubuntu versions not yet reached end of life".. sanitize selection
## http://www.rsyslog.com/ubuntu-repository/
- name: Enable Adiscon rsyslog apt repo
apt_repository: repo='ppa:adiscon/v{{ repo_releasever }}-stable'
when: use_repo == True and ansible_distribution == 'Ubuntu'
when: >
use_repo and
ansible_distribution == 'Ubuntu'
- name: install packages for Debian
tags:
- rsyslog
- packages
apt: pkg={{item}} state=installed update_cache=yes
apt: pkg={{ item }} state=installed update_cache=yes
with_items: '{{ rsyslog_package_names }}'

View File

@@ -13,18 +13,24 @@
- rsyslog
- packages
rpm_key: key=http://rpms.adiscon.com/RPM-GPG-KEY-Adiscon state=present
when: adiscon_gpg_key.stat.exists == False and use_repo == True
when: >
not adiscon_gpg_key.stat.exists and
use_repo
- name: Enable Adiscon rsyslog yum repo
tags:
- rsyslog
- packages
template: src=rsyslog.yum.repo.j2 dest=/etc/yum.repos.d/rsyslog.repo
when: use_repo == True
template:
src: rsyslog.yum.repo.j2
dest: /etc/yum.repos.d/rsyslog.repo
mode: 0644
when: use_repo
- name: install packages for RHEL
tags:
- rsyslog
- packages
yum: pkg={{item}} state=latest
with_items: '{{ rsyslog_package_names }}'
package:
name: '{{ rsyslog_package_names }}'
state: latest