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

View File

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

View File

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

View File

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