Merge pull request 'Initial release version to AAP' (#5) from testing into main

Reviewed-on: #5
This commit is contained in:
Chris Hammer 2024-02-28 16:47:03 -05:00
commit 7d3a8d8f77
64 changed files with 323 additions and 255 deletions

View File

@ -3,3 +3,4 @@ skip_list:
- yaml[empty-lines]
- yaml[line-length]
- no-changed-when
- galaxy[no-changelog]

3
.drone.env Normal file
View File

@ -0,0 +1,3 @@
export ANSIBLE_LINT_EXCLUSION="--exclude .gitea"
export ANSIBLE_INVENTORY="-i 127.0.0.1, --connection=local"
export ANSIBLE_PLAYBOOK="baseos.yml"

111
.drone.yml Normal file
View File

@ -0,0 +1,111 @@
---
kind: pipeline
type: docker
name: CentOS_9-Ansible-Pipeline
trigger:
branch:
exclude:
- main
event: [push]
steps:
- name: ansible_environment_verify
image: gitea.thezengarden.net/podman/ansible-dev/centos9:release
commands:
- . ./.drone.env
- env
- git log -1
- ansible --version
- ansible-lint --version
- name: ansible_lint
image: gitea.thezengarden.net/podman/ansible-dev/centos9:release
commands:
- . ./.drone.env
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
---
kind: pipeline
type: docker
name: Fedora_39-Ansible-Pipeline
trigger:
branch:
exclude:
- main
event: [push]
steps:
- name: ansible_environment_verify
image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release
commands:
- . ./.drone.env
- env
- git log -1
- ansible --version
- ansible-lint --version
- name: ansible_lint
image: gitea.thezengarden.net/podman/ansible-dev/fedora39:release
commands:
- . ./.drone.env
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
---
kind: pipeline
type: docker
name: Debian_11-Ansible-Pipeline
trigger:
branch:
exclude:
- main
event: [push]
steps:
- name: ansible_environment_verify
image: gitea.thezengarden.net/podman/ansible-dev/debian11:release
commands:
- . ./.drone.env
- env
- git log -1
- ansible --version
- ansible-lint --version
- name: ansible_lint
image: gitea.thezengarden.net/podman/ansible-dev/debian11:release
commands:
- . ./.drone.env
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION
---
kind: pipeline
type: docker
name: Debian_12-Ansible-Pipeline
trigger:
branch:
exclude:
- main
event: [push]
steps:
- name: ansible_environment_verify
image: gitea.thezengarden.net/podman/ansible-dev/debian12:release
commands:
- . ./.drone.env
- env
- git log -1
- ansible --version
- ansible-lint --version
- name: ansible_lint
image: gitea.thezengarden.net/podman/ansible-dev/debian12:release
commands:
- . ./.drone.env
- ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION

View File

@ -0,0 +1,30 @@
name: Ansible Code Pipeline
run-name: ${{ gitea.actor }} is running Ansible Code Pipeline
on:
push:
branches:
- testing
jobs:
Ansible-Development-Pipeline:
strategy:
matrix:
os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian11, ansible-dev-debian12 ]
runs-on: ${{ matrix.os }}
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Ansible Environment Verify
run: |
. ./.drone.env
env
git log -1
ansible --version
ansible-lint --version
- name: Run Ansible-Lint
run: |
. ./.drone.env
ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION

2
ansible.cfg Normal file
View File

@ -0,0 +1,2 @@
[defaults]
roles_path = roles

View File

@ -8,7 +8,7 @@ namespace: jchristianh
name: baseos
# The version of the collection. Must be compatible with semantic versioning
version: 1.0.17
version: 1.0.20
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
@ -16,7 +16,7 @@ readme: README.md
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
# @nicks:irc/im.site#channel'
authors:
- Chris Hammer <chris@thezengarden.net>
- Chris Hammer <chris@thezengarden.net>
### OPTIONAL but strongly recommended
@ -25,8 +25,8 @@ description: A collection of roles to manage your environment.
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
#license:
#- GPL-2.0-or-later
# license:
# - GPL-2.0-or-later
# The path to the license file for the collection. This path is relative to the root of the collection. This key is
# mutually exclusive with 'license'
@ -34,7 +34,8 @@ license_file: 'LICENSE'
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags: []
tags:
- linux
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range

View File

@ -1,2 +1,2 @@
---
requires_ansible: ">=2.14"
requires_ansible: ">=2.15.0"

View File

@ -1,10 +0,0 @@
---
__project_author : Chris Hammer
__project_email : chris@thezengarden.net
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
__template_header : The Zen Garden
...

View File

@ -2,18 +2,18 @@
- name: Include distribution specific variables or include defaults
block:
- name: Include distribution specific variables
include_vars:
ansible.builtin.include_vars:
file: "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}.yml"
rescue:
- name: Non-supported distribution; using default package set
include_vars:
file: __default_packages.yml
ansible.builtin.include_vars:
file: default_packages.yml
- name: Install EPEL for CentOS hosts - Required for some of our packages
package:
- name: Install EPEL for CentOS hosts - Required for some packages
ansible.builtin.package:
name : epel-release
state : present
when:
@ -21,8 +21,8 @@
- name: Install package set
package:
name : "{{ __base_packages }}"
ansible.builtin.package:
name : "{{ base_packages_package_set }}"
state : present

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- base_packages

View File

@ -1,5 +1,5 @@
---
__base_packages:
base_packages_package_set:
- bc
- bind-utils
- bzip2

View File

@ -1,5 +1,5 @@
---
__base_packages:
base_packages_package_set:
- bc
- bind-utils
- bzip2

View File

@ -1,5 +1,5 @@
---
__base_packages:
base_packages_package_set:
- bc
- bind-utils
- bzip2

View File

@ -1,5 +1,5 @@
---
__base_packages:
base_packages_package_set:
- bc
- bind9utils
- bzip2

View File

@ -5,7 +5,7 @@
# Please adjust accordingly, or include a vars file matching the pattern:
# <ansible_distribution>_<ansible_distribution_major_version>.yml
__base_packages:
base_packages_package_set:
- bc
- bzip2
- file

View File

@ -1,2 +0,0 @@
---
# vars file for base_packages

View File

@ -1,9 +1,9 @@
---
- name: Deploy .bashrc
copy:
ansible.builtin.copy:
src : files/bashrc
dest : /root/.bashrc
mode : 0640
mode : "0640"
...

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- bashrc

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- default_services

View File

@ -1,15 +1,15 @@
---
__project_author : Chris Hammer
__project_email : chris@thezengarden.net
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
etc_hosts_project_author : Chris Hammer
etc_hosts_project_email : chris@thezengarden.net
etc_hosts_project_repo : https://github.com/jchristianh-ansible-collections/baseos
__template_header : The Zen Garden
etc_hosts_template_header : The Zen Garden
__etc_hosts_file : /etc/hosts
__etc_hosts_version : 1.0.0
__etc_hosts_revision : 22314
etc_hosts_etc_hosts_file : /etc/hosts
etc_hosts_etc_hosts_version : 1.0.1
etc_hosts_etc_hosts_revision : 231216
...

View File

@ -1,16 +1,16 @@
---
- name: Set etc_hosts_file if running in Docker
set_fact:
__etc_hosts_file: "{{ __etc_hosts_file }}.docker"
- name: Set etc_hosts_etc_hosts_file if running in Docker
ansible.builtin.set_fact:
etc_hosts_etc_hosts_file: "{{ etc_hosts_etc_hosts_file }}.docker"
when:
- ansible_virtualization_type | regex_search("docker|podman|container")
- name: Deploy {{ __etc_hosts_file }}
template:
- name: Deploy {{ etc_hosts_etc_hosts_file }}
ansible.builtin.template:
src: templates/etc_hosts.j2
dest: "{{ __etc_hosts_file }}"
mode: 0644
dest: "{{ etc_hosts_etc_hosts_file }}"
mode: "0644"
...

View File

@ -1,11 +1,11 @@
###############################################
# {{ __template_header }}
# {{ etc_hosts_template_header }}
###############################################
#
# Configuration : {{ __etc_hosts_file }}
# Template Version : {{ __etc_hosts_version}}-{{ __etc_hosts_revision }}
# Configuration : {{ etc_hosts_etc_hosts_file }}
# Template Version : {{ etc_hosts_etc_hosts_version }}-{{ etc_hosts_etc_hosts_revision }}
#
# {{ __project_author }} ({{ __project_email }})
# {{ etc_hosts_project_author }} ({{ etc_hosts_project_email }})
###############################################
@ -17,13 +17,13 @@
# OUR PERSONAL INFO
#############################################
{{ ansible_default_ipv4.address | default('127.0.0.1') }} {{ ansible_fqdn }} {{ ansible_hostname }} {{ inventory_hostname }}
{{ ansible_default_ipv4.address | default('127.0.0.1') }} {{ ansible_fqdn }} {{ ansible_hostname }} {{ inventory_hostname }}
{% if custom_hosts is defined and custom_hosts != '' %}
{% if etc_hosts_custom_hosts is defined and etc_hosts_custom_hosts != '' %}
# CUSTOM HOSTS:
#############################################
{% for item in custom_hosts %}
{% for item in etc_hosts_custom_hosts %}
{{ item }}
{% endfor %}
{% endif %}

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- etc_hosts

View File

@ -1,46 +1,46 @@
---
- name: restart_syslog_centos_7
service:
- name: Restart_syslog_centos_7
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_centos_8
service:
- name: Restart_syslog_centos_8
ansible.builtin.service:
name : syslog
state : restarted
- name: restart_syslog_centos_9
service:
- name: Restart_syslog_centos_9
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_redhat_8
service:
- name: Restart_syslog_redhat_8
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_redhat_9
service:
- name: Restart_syslog_redhat_9
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_debian_11
service:
- name: Restart_syslog_debian_11
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_debian_12
service:
- name: Restart_syslog_debian_12
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_fedora_35
service:
- name: Restart_syslog_fedora_35
ansible.builtin.service:
name : rsyslog
state : restarted
- name: restart_syslog_fedora_38
service:
- name: Restart_syslog_fedora_38
ansible.builtin.service:
name : rsyslog
state : started

View File

@ -1,9 +1,9 @@
---
- name: Set hostname for host
hostname:
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
notify:
- "restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
...

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- hostname

View File

@ -1,16 +1,5 @@
---
__project_author : Chris Hammer
__project_email : chris@thezengarden.net
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
__template_header : The Zen Garden
__motd_file : /etc/motd
__motd_file_docker : /etc/motd
__motd_version : 1.0.0
__motd_revision : 22318
motd_motd_file : /etc/motd
...

View File

@ -1,27 +1,27 @@
---
- name: Set host IP address or set a default
set_fact:
ansible.builtin.set_fact:
host_ip : "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Install Perl if needed
package:
ansible.builtin.package:
name : perl
state : present
- name: Get system uptime from script
script:
ansible.builtin.script:
cmd : "scripts/get_uptime.pl {{ ansible_uptime_seconds }}"
register : node_uptime
changed_when : false
- name: Update MOTD
template:
ansible.builtin.template:
src : templates/motd.j2
dest : "{{ __motd_file }}"
mode : 0644
dest : "{{ motd_motd_file }}"
mode : "0644"
changed_when : false

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- motd

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- node_status

View File

@ -1,20 +1,19 @@
---
__project_author : Chris Hammer
__project_email : chris@thezengarden.net
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
resolv_conf_project_author : Chris Hammer
resolv_conf_project_email : chris@thezengarden.net
resolv_conf_project_repo : https://github.com/jchristianh-ansible-collections/baseos
__template_header : The Zen Garden
resolv_conf_template_header : The Zen Garden
__resolv_conf_file : /etc/resolv.conf
__resolv_conf_file_docker : /etc/resolv.conf.docker
__resolv_conf_version : 1.0.1
__resolv_conf_revision : 221007
resolv_conf_resolv_conf_file : /etc/resolv.conf
resolv_conf_resolv_conf_version : 1.0.1
resolv_conf_resolv_conf_revision : 221007
__search_domain : thezengarden.net
__nameservers :
resolv_conf_search_domain : thezengarden.net
resolv_conf_nameservers :
- 10.10.10.55
- 10.1.1.15

View File

@ -1,15 +1,15 @@
---
- name: Set resolv_conf_file if running in Docker
- name: Set resolv_conf_file if running in container
ansible.builtin.set_fact:
__resolv_conf_file: "{{ __resolv_conf_file_docker }}"
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.docker"
when:
- ansible_virtualization_type | regex_search("docker|podman|container")
- name: Deploy {{ __resolv_conf_file }}
- name: Deploy {{ resolv_conf_resolv_conf_file }}
ansible.builtin.template:
src: templates/resolv_conf.j2
dest: "{{ __resolv_conf_file }}"
dest: "{{ resolv_conf_resolv_conf_file }}"
mode: "0644"

View File

@ -1,15 +1,15 @@
# {{ __template_header }}
# {{ resolv_conf_template_header }}
###############################################
#
# Configuration : {{ __resolv_conf_file }}
# Template Version : {{ __resolv_conf_version}}-{{ __resolv_conf_revision }}
# Configuration : {{ resolv_conf_resolv_conf_file }}
# Template Version : {{ resolv_conf_resolv_conf_version }}-{{ resolv_conf_resolv_conf_revision }}
#
# {{ __project_author }} ({{ __project_email }})
# {{ resolv_conf_project_author }} ({{ resolv_conf_project_email }})
###############################################
search {{ __search_domain }}
{% for item in __nameservers %}
search {{ resolv_conf_search_domain }}
{% for item in resolv_conf_nameservers %}
nameserver {{ item }}
{% endfor %}

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- resolv_conf

View File

@ -1,23 +1,23 @@
---
__project_author : Chris Hammer
__project_email : chris@thezengarden.net
__project_repo : https://github.com/jchristianh-ansible-collections/baseos
snmpd_conf_project_author : Chris Hammer
snmpd_conf_project_email : chris@thezengarden.net
snmpd_conf_project_repo : https://github.com/jchristianh-ansible-collections/baseos
__template_header : The Zen Garden
snmpd_conf_template_header : The Zen Garden
__snmpd_conf_file : /etc/snmp/snmpd.conf
__snmpd_conf_version : 1.0.1
__snmpd_conf_revision : 231210
snmpd_conf_snmpd_conf_file : /etc/snmp/snmpd.conf
snmpd_conf_snmpd_conf_version : 1.0.1
snmpd_conf_snmpd_conf_revision : 231210
__snmp_pkg : net-snmp
snmpd_conf_snmp_pkg : net-snmp
__snmpd_location : 'Newport News, VA'
__snmpd_contact_name : 'Chris Hammer'
__snmpd_contact_email : '<chris@thezengarden.net>'
snmpd_conf_snmpd_location : 'Newport News, VA'
snmpd_conf_snmpd_contact_name : 'Chris Hammer'
snmpd_conf_snmpd_contact_email : '<chris@thezengarden.net>'
...

View File

@ -1,40 +1,35 @@
---
- name: Include distribution specific variables or include defaults
block:
- name: Include distribution specific variables
include_vars:
file: "{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}.yml"
rescue:
- name: Non-supported distribution; using default package set
include_vars:
file: __default_packages.yml
- name: Deploy and configure SNMP
block:
- name: Set package name for Debian 12
ansible.builtin.set_fact:
snmpd_conf_snmp_pkg: snmpd
when:
- ansible_distribution | lower == 'debian'
- ansible_distribution_major_version == '12'
- name: Install SNMP
package:
name: "{{ __snmp_pkg }}"
ansible.builtin.package:
name: "{{ snmpd_conf_snmp_pkg }}"
state: present
- name: Ensure /etc/snmp directory is present
file:
ansible.builtin.file:
path: /etc/snmp
state: directory
mode: "0755"
- name: Deploy snmpd.conf
template:
ansible.builtin.template:
src: templates/snmpd_conf.j2
dest: "{{ __snmpd_conf_file }}"
mode: 0644
dest: "{{ snmpd_conf_snmpd_conf_file }}"
mode: "0644"
notify: Restart_SNMPd
rescue:
- name: Unable to deploy SNMP
debug:
ansible.builtin.debug:
msg: "Unable to deploy SNMP to {{ inventory_hostname }}."

View File

@ -1,11 +1,11 @@
###############################################
# {{ __template_header }}
# {{ snmpd_conf_template_header }}
###############################################
#
# Configuration : {{ __snmpd_conf_file }}
# Template Version : {{ __snmpd_conf_version}}-{{ __snmpd_conf_revision }}
# Configuration : {{ snmpd_conf_snmpd_conf_file }}
# Template Version : {{ snmpd_conf_snmpd_conf_version }}-{{ snmpd_conf_snmpd_conf_revision }}
#
# {{ __project_author }} ({{ __project_email }})
# {{ snmpd_conf_project_author }} ({{ snmpd_conf_project_email }})
###############################################
@ -33,6 +33,6 @@ access MyRWGroup "" any noauth exact all all none
###############################################################################
# System contact information
#
syslocation {{ __snmpd_location }}
syscontact {{ __snmpd_contact_name }} {{ __snmpd_contact_email }}
syslocation {{ snmpd_conf_snmpd_location }}
syscontact {{ snmpd_conf_snmpd_contact_name }} {{ snmpd_conf_snmpd_contact_email }}
# -----------------------------------------------------------------------------

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- snmpd_conf

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: net-snmp
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: net-snmp
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: net-snmp
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: net-snmp
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: snmpd
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: snmpd
...

View File

@ -1,5 +0,0 @@
---
__snmp_pkg: net-snmp
...

4
roles/testing/README.md Normal file
View File

@ -0,0 +1,4 @@
Role Name
=========
A simple role to say hello to the world.

View File

@ -0,0 +1,29 @@
galaxy_info:
author: Chris Hammer
description: Simple default role to say hello world.
license: GPL-2.0-or-later
min_ansible_version: "2.14"
platforms:
- name: Fedora
versions:
- all
- name: EL
versions:
- "8"
- "9"
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View File

@ -0,0 +1,7 @@
---
- name: Hello World.
ansible.builtin.debug:
msg: Hello world.
...

View File

@ -1,7 +1,7 @@
---
- name: Update package cache for Debian hosts
apt:
update_cache: yes
update_cache: true
when:
- ansible_distribution|lower == 'debian'
tags:
@ -10,7 +10,7 @@
- name: Update package cache for RHEL/CentOS/Fedora hosts
dnf:
update_cache: yes
update_cache: true
when:
- (ansible_distribution|lower == 'centos' or
ansible_distribution|lower == 'fedora' or

View File

@ -1,2 +0,0 @@
localhost

View File

@ -1,5 +0,0 @@
---
- hosts: localhost
remote_user: root
roles:
- roles/update_all_packages

14
tests/unit-test.yml Normal file
View File

@ -0,0 +1,14 @@
---
- name: Test the role provided in extra_vars
hosts: all
become: false
gather_facts: true
tasks:
- name: Include role to test
ansible.builtin.include_role:
name: "{{ __test_role | default('testing') }}"
...