12 Commits

Author SHA1 Message Date
584a33172c Merge pull request '1.0.29' (#16) from testing into main
Reviewed-on: #16
2024-03-02 16:31:36 -05:00
3cc31ecb40 v1.0.28
Reviewed-on: #15
2024-03-01 17:00:33 -05:00
665560250f Merge pull request '1.0.27' (#14) from testing into main
Reviewed-on: #14
2024-03-01 10:47:12 -05:00
d25730cb74 Merge pull request '1.0.26' (#13) from testing into main
Reviewed-on: #13
2024-03-01 09:27:34 -05:00
1ad31b8305 Merge pull request 'v1.0.26' (#12) from testing into main
Reviewed-on: #12
2024-03-01 09:26:38 -05:00
bdfa48f95d Merge pull request 'v1.0.25' (#11) from testing into main
Reviewed-on: #11
2024-03-01 08:59:52 -05:00
a29281515b Merge pull request 'v1.0.24' (#10) from testing into main
Reviewed-on: #10
2024-02-29 18:29:44 -05:00
152e7e3815 Merge pull request 'v1.0.23' (#9) from testing into main
Reviewed-on: #9
2024-02-29 18:04:27 -05:00
028bde883e Merge pull request 'Update galaxy.yml for 1.0.22 release' (#8) from testing into main
Reviewed-on: #8
2024-02-29 12:21:18 -05:00
bae88f96a7 Merge pull request 'Add node_status role' (#7) from testing into main
Reviewed-on: #7
2024-02-29 12:20:14 -05:00
d752b8064b Merge pull request 'BaseOS v1.0.21' (#6) from testing into main
Reviewed-on: #6
2024-02-28 20:05:59 -05:00
7d3a8d8f77 Merge pull request 'Initial release version to AAP' (#5) from testing into main
Reviewed-on: #5
2024-02-28 16:47:03 -05:00
22 changed files with 190 additions and 176 deletions

View File

@ -4,5 +4,3 @@ skip_list:
- yaml[line-length] - yaml[line-length]
- no-changed-when - no-changed-when
- galaxy[no-changelog] - galaxy[no-changelog]
- no-free-form
- package-latest

View File

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

@ -7,7 +7,10 @@ on:
jobs: jobs:
Ansible-Development-Pipeline: Ansible-Development-Pipeline:
runs-on: ansible-dev-centos strategy:
matrix:
os: [ ansible-dev-centos9, ansible-dev-fedora39, ansible-dev-debian11, ansible-dev-debian12 ]
runs-on: ${{ matrix.os }}
steps: steps:
- name: Clone repository - name: Clone repository
@ -15,18 +18,13 @@ jobs:
- name: Ansible Environment Verify - name: Ansible Environment Verify
run: | run: |
echo "BUILD HOST: $(cat /etc/hostname)" && echo . ./.drone.env
echo "BUILD USER: $(whoami)" && echo env
echo "PWD: $(pwd)" && echo git log -1
lscpu && echo ansible --version
. ./.ci.env && echo ansible-lint --version
env && echo
git log -1 && echo
ansible --version && echo
ansible-lint --version --offline && echo
- name: Run Ansible-Lint - name: Run Ansible-Lint
run: | run: |
. ./.ci.env . ./.drone.env
ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION ansible-lint --offline --nocolor $ANSIBLE_LINT_EXCLUSION

View File

@ -8,7 +8,7 @@ namespace: jchristianh
name: baseos name: baseos
# The version of the collection. Must be compatible with semantic versioning # The version of the collection. Must be compatible with semantic versioning
version: 1.0.36 version: 1.0.29
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection # The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md readme: README.md

View File

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

View File

@ -1,38 +0,0 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

View File

@ -1,16 +0,0 @@
---
dnf_conf_maintainer : "Chris H."
dnf_conf_maintainer_email : "<chris@thezengarden.net>"
dnf_conf_file : "/etc/dnf/dnf.conf"
dnf_conf_version : 1.0
dnf_conf_revision : 2433621
dnf_conf_fastest_mirror : "False"
dnf_conf_gpg_check : "1"
dnf_conf_max_downloads : 20
...

View File

@ -1,29 +0,0 @@
galaxy_info:
author: Chris Hammer
description: Deploys a standard /etc/dnf/dnf.conf
license: GPL-2.0-or-later
min_ansible_version: "2.14.0"
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

@ -1,11 +0,0 @@
---
- name: Deploy {{ dnf_conf_file }}
ansible.builtin.template:
src: templates/dnf_conf.j2
dest: "{{ dnf_conf_file }}"
mode: "0644"
when:
- "'dnf' in ansible_pkg_mgr"
...

View File

@ -1,19 +0,0 @@
##########################
# The Zen Garden Network #
##########################
#
# Configuration : {{ dnf_conf_file }}
# Template Version : {{ dnf_conf_version}}-{{ dnf_conf_revision }}
#
# {{ dnf_conf_maintainer }} {{ dnf_conf_maintainer_email }}
###############################################
[main]
gpgcheck={{ dnf_conf_gpg_check }}
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
max_parallel_downloads={{ dnf_conf_max_downloads }}
fastestmirror={{ dnf_conf_fastest_mirror }}

View File

@ -3,7 +3,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
etc_hosts_etc_hosts_file: "{{ etc_hosts_etc_hosts_file }}.docker" etc_hosts_etc_hosts_file: "{{ etc_hosts_etc_hosts_file }}.docker"
when: when:
- ansible_virtualization_type is search("docker|podman|container") - ansible_virtualization_type | regex_search("docker|podman|container")
- name: Deploy {{ etc_hosts_etc_hosts_file }} - name: Deploy {{ etc_hosts_etc_hosts_file }}

View File

@ -2,7 +2,7 @@
- name: Use hostname module to set hostname, or failback to command module - name: Use hostname module to set hostname, or failback to command module
when: when:
- not ansible_virtualization_type is search("docker|podman|container") - not ansible_virtualization_type | regex_search("docker|podman|container")
block: block:
- name: Set hostname for host using hostname module - name: Set hostname for host using hostname module
ansible.builtin.hostname: ansible.builtin.hostname:

View File

@ -1,13 +1,13 @@
--- ---
motd_motd_file: /etc/motd motd_motd_file: /etc/motd
motd_host_ip: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" motd_host_ip : "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
motd_host_uptime: "{{ now().replace(microsecond=0) - now().fromtimestamp(now(fmt='%s') | int - ansible_uptime_seconds) }}" motd_host_uptime : "{{ now().replace(microsecond=0) - now().fromtimestamp(now(fmt='%s') | int - ansible_uptime_seconds) }}"
motd_day_filter: "(.* day[s]?),\\s+(\\d+):(\\d+):(\\d+)" motd_day_filter : "(.* day[s]?),\\s+(\\d+):(\\d+):(\\d+)"
motd_nonday_filter: "(\\d+):(\\d+):(\\d+)" motd_nonday_filter : "(\\d+):(\\d+):(\\d+)"
motd_day_filter_repl: "\\1 \\2 hours \\3 minutes" motd_day_filter_repl : "\\1 \\2 hours \\3 minutes"
motd_nonday_filter_repl : "\\1 hours \\2 minutes \\3 seconds" motd_nonday_filter_repl : "\\1 hours \\2 minutes \\3 seconds"
... ...

View File

@ -1,16 +1,24 @@
--- ---
- name: Format uptime using Jinja - name: Format uptime containing days
ansible.builtin.set_fact: ansible.builtin.set_fact:
motd_uptime_formatted: | uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}"
{% if 'day' in motd_host_uptime %} when:
{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }} - "'day' in motd_host_uptime"
{% else %}
{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}
{% endif %} - name: Format uptime not containing days
ansible.builtin.set_fact:
uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}"
when:
- "'day' not in motd_host_uptime"
- name: Update MOTD - name: Update MOTD
ansible.builtin.template: ansible.builtin.template:
src: templates/motd.j2 src : templates/motd.j2
dest: "{{ motd_motd_file }}" dest : "{{ motd_motd_file }}"
mode: "0644" mode : "0644"
changed_when: false changed_when : false
...

View File

@ -16,9 +16,9 @@
Host : {{ inventory_hostname }} Host : {{ inventory_hostname }}
IP : {{ motd_host_ip }} IP : {{ motd_host_ip }}
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] | regex_replace('\\s+', ' ') }} CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] }}
Memory : {{ "{0:0.2f}".format(ansible_memfree_mb/1024) }} GB free of {{ (ansible_memtotal_mb/1024)|round}} GB Memory : {{ "{0:0.2f}".format(ansible_memfree_mb/1024) }} GB free of {{ (ansible_memtotal_mb/1024)|round}} GB
Platform : {{ ansible_distribution }} {{ ansible_distribution_version }} {{ ansible_kernel }} Platform : {{ ansible_distribution }} {{ ansible_distribution_version }} {{ ansible_kernel }}
Up : {{ motd_uptime_formatted | trim }} Up : {{ uptime_formatted }}

View File

@ -1,6 +1,7 @@
--- ---
node_status_host : node-status.thezengarden.net node_status_host : zg-lxut02.thezengarden.net
node_status_user : chris node_status_user : chris
node_status_group : chris node_status_group : chris
node_status_dir : /home/chris/node_status node_status_dir : /home/chris/node_status
node_status_file : status.csv node_status_file : status.csv
node_status_lc : 3

View File

@ -1,31 +1,33 @@
--- ---
- name: Update node status when not running in a container - name: Update node status when not running in a container
when: not ansible_virtualization_type is search("docker|podman|container") when: not ansible_virtualization_type | regex_search("docker|podman|container")
block: block:
- name: Create directory {{ node_status_dir }} - name: Create directory {{ node_status_dir }}
ansible.builtin.file: ansible.builtin.file:
path: "{{ node_status_dir }}" path : "{{ node_status_dir }}"
state: directory state : directory
mode: '0755' mode : '0755'
become: false become : false
run_once: true run_once : true
delegate_to: "{{ node_status_host }}" delegate_to : "{{ node_status_host }}"
- name: Capture system uptime - name: Capture system uptime
ansible.builtin.command : uptime ansible.builtin.command : uptime
register: node_status_sys_uptime register : r_node_status_uptime
changed_when: false changed_when: false
- name: Log node status - name: Log node status
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ node_status_dir }}/{{ node_status_file }}" path : "{{ node_status_dir }}/{{ node_status_file }}"
state: present state : present
regexp: "{{ inventory_hostname }}" regexp : "{{ inventory_hostname }}"
line: "{{ ansible_date_time.epoch }},,{{ inventory_hostname }},,{{ ansible_distribution }} {{ ansible_distribution_version }},,{{ node_status_sys_uptime.stdout }}" line : "{{ ansible_date_time.epoch }},,{{ inventory_hostname }},,{{ ansible_distribution }} {{ ansible_distribution_version }},,{{ r_node_status_uptime.stdout }}"
create: true create : true
mode: '0644' mode : '0644'
owner: "{{ node_status_user }}" owner : "{{ node_status_user }}"
group: "{{ node_status_group }}" group : "{{ node_status_group }}"
delegate_to: "{{ node_status_host }}" delegate_to : "{{ node_status_host }}"
throttle: 1 throttle : 1

View File

@ -3,7 +3,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.container" resolv_conf_resolv_conf_file: "{{ resolv_conf_resolv_conf_file }}.container"
when: when:
- ansible_virtualization_type is search("docker|podman|container") - ansible_virtualization_type | regex_search("docker|podman|container")
- name: Deploy {{ resolv_conf_resolv_conf_file }} - name: Deploy {{ resolv_conf_resolv_conf_file }}

View File

@ -4,4 +4,4 @@
name : snmpd name : snmpd
state: restarted state: restarted
when: when:
- not ansible_virtualization_type is search("docker|podman|container") - not ansible_virtualization_type | regex_search("docker|podman|container")

View File

@ -1,11 +1,12 @@
--- ---
- name: Deploy and configure SNMP - name: Deploy and configure SNMP
block: block:
- name: Set package name for Debian - name: Set package name for Debian 12
ansible.builtin.set_fact: ansible.builtin.set_fact:
snmpd_conf_snmp_pkg: snmpd snmpd_conf_snmp_pkg: snmpd
when: when:
- ansible_distribution | lower == 'debian' - ansible_distribution | lower == 'debian'
- ansible_distribution_major_version == '12'
- name: Install SNMP - name: Install SNMP
ansible.builtin.package: ansible.builtin.package:

View File

@ -1,21 +1,29 @@
--- ---
- name: Update package cache for Debian hosts - name: Update package cache for Debian hosts
ansible.builtin.apt: apt:
update_cache: true update_cache: true
when: when:
- "'apt' in ansible_pkg_mgr" - ansible_distribution|lower == 'debian'
tags:
- skip_ansible_lint
- name: Update package cache for RHEL/CentOS/Fedora hosts - name: Update package cache for RHEL/CentOS/Fedora hosts
ansible.builtin.dnf: dnf:
update_cache: true update_cache: true
when: when:
- "'dnf' in ansible_pkg_mgr" - (ansible_distribution|lower == 'centos' or
ansible_distribution|lower == 'fedora' or
ansible_distribution|lower == 'redhat')
- ansible_distribution_major_version|int >= 8 - ansible_distribution_major_version|int >= 8
tags:
- skip_ansible_lint
- name: Update all host packages - name: Update all host packages
ansible.builtin.package: name=* state=latest package: name=* state=latest
tags:
- skip_ansible_lint
... ...