Compare commits

...

30 Commits
1.0.23 ... main

Author SHA1 Message Date
824a2ec1ec Merge pull request '1.0.34' (#21) from testing into main
Reviewed-on: #21
2024-03-21 11:44:03 -04:00
18a389df0f Fix exceptions for better, more concise, functionality
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-21 11:42:58 -04:00
9c66f1952b Merge pull request '1.0.33' (#20) from testing into main
Reviewed-on: #20
2024-03-21 10:32:11 -04:00
ead6752bab MOTD CPU spacing fix
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-21 10:31:10 -04:00
aadb25069d Merge pull request '1.0.32' (#19) from testing into main
Reviewed-on: #19
2024-03-12 15:30:43 -04:00
d3d87d3847 Galaxy version bump
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-12 15:29:35 -04:00
6341afd154 Update node_status_host; retiring zg-lxut02.thezengarden.net
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-12 15:28:03 -04:00
7734a8c457 Merge pull request '1.0.31' (#18) from testing into main
Reviewed-on: #18
2024-03-03 20:34:10 -05:00
67423daa30 Optimization for MOTD
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-03 20:33:25 -05:00
63ac9d6e4f 1.0.30
Reviewed-on: #17
2024-03-03 19:55:22 -05:00
277b96c064 Exception for dnf based hosts
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-03 19:54:21 -05:00
2dd3b234f5 Ansible Lint fixes
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-03 18:32:18 -05:00
c31b4cdd62 Add initial dnf_conf role
Some checks failed
continuous-integration/drone/push Build is failing
2024-03-03 18:29:41 -05:00
584a33172c Merge pull request '1.0.29' (#16) from testing into main
Reviewed-on: #16
2024-03-02 16:31:36 -05:00
b2300e8ba8 Add vars for replace filter
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-02 16:30:55 -05:00
3cc31ecb40 v1.0.28
Reviewed-on: #15
2024-03-01 17:00:33 -05:00
db75e69d99 Update motd role to no longer require Perl dependancy or script
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 16:59:32 -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
d737b08719 Nix hostname for containers; v1.0.27
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 10:46: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
f7e878ce39 1.0.26
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 09:27:20 -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
2cacd15d59 Fixes and 1.0.26
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 09:25:44 -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
c104223bc0 Version bump to 1.0.25
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 08:59:27 -05:00
78c47af393 Add loop for updates
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-01 08:54:46 -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
df89b4306f Add loop_control; Fix hostname for containers; Fix Ansible compat; Update baseos collection to 1.0.24
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-29 18:29:00 -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
a927a26546 Re-work node_status
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-29 18:03:25 -05:00
26 changed files with 160 additions and 97 deletions

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

38
roles/dnf_conf/README.md Normal file
View File

@ -0,0 +1,38 @@
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

@ -0,0 +1,16 @@
---
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

@ -0,0 +1,29 @@
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

@ -0,0 +1,11 @@
---
- 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

@ -0,0 +1,19 @@
##########################
# 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

@ -6,7 +6,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -1,6 +1,8 @@
---
- name: Use hostname module to set hostname, or failback to command module
when:
- not ansible_virtualization_type | regex_search("docker|podman|container")
block:
- name: Set hostname for host using hostname module
ansible.builtin.hostname:
@ -9,32 +11,8 @@
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
rescue:
- name: Ensure hostname package is present
ansible.builtin.package:
name: hostname
state: present
- name: Set hostname file if running in container
ansible.builtin.set_fact:
hostname_hostname_file: "{{ hostname_hostname_file }}.container"
when:
- ansible_virtualization_type | regex_search("docker|podman|container")
- name: Add entry into hostname file
ansible.builtin.lineinfile:
path: "{{ hostname_hostname_file }}"
line: "{{ inventory_hostname }}"
state: present
create: true
mode: '0644'
- name: Update hostname from /etc/hostname
ansible.builtin.command:
cmd: "hostname -F {{ hostname_hostname_file }}"
notify:
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
when:
- not ansible_virtualization_type | regex_search("docker|podman|container")
- name: Unable to set hostname
ansible.builtin.debug:
msg: "Unable to set hostname for {{ ansible_hostname }} to {{ inventory_hostname }}."
...

View File

@ -1,5 +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_uptime : "{{ now().replace(microsecond=0) - now().fromtimestamp(now(fmt='%s') | int - ansible_uptime_seconds) }}"
motd_day_filter : "(.* day[s]?),\\s+(\\d+):(\\d+):(\\d+)"
motd_nonday_filter : "(\\d+):(\\d+):(\\d+)"
motd_day_filter_repl : "\\1 \\2 hours \\3 minutes"
motd_nonday_filter_repl : "\\1 hours \\2 minutes \\3 seconds"
...

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -1,21 +0,0 @@
#!/usr/bin/perl
use strict;
my $seconds = shift;
my $string = sprintf "%02d::%02d::%02d::%02d", (gmtime($seconds))[7,2,1,0];
# days [0] :: hours [1] :: mins [2] :: seconds [3]
my @ups = split(/::/, $string);
my $return_uptime = "";
my $i = 0;
for (@ups) { $ups[$i] =~ s/^0//g; $i++; }
$return_uptime .= "$ups[0] days " if $ups[0] != 0;
$return_uptime .= "$ups[1] hours " if $ups[1] != 0;
$return_uptime .= "$ups[2] minutes " if $ups[2] != 0;
# $return_uptime .= "$ups[3] seconds" if $ups[3] != 0;
print "$return_uptime\n";

View File

@ -1,20 +1,12 @@
---
- name: Set host IP address or set a default
- name: Format uptime using Jinja
ansible.builtin.set_fact:
host_ip : "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
- name: Install Perl if needed
ansible.builtin.package:
name : perl
state : present
- name: Get system uptime from script
ansible.builtin.script:
cmd : "scripts/get_uptime.pl {{ ansible_uptime_seconds }}"
register : node_uptime
changed_when : false
uptime_formatted: |
{% if 'day' in motd_host_uptime %}
{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}
{% else %}
{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}
{% endif %}
- name: Update MOTD
@ -26,4 +18,3 @@
...

View File

@ -14,11 +14,11 @@
|___/
Host : {{ ansible_fqdn }}
IP : {{ host_ip }}
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] }}
Host : {{ inventory_hostname }}
IP : {{ motd_host_ip }}
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] | regex_replace('\\s+', ' ') }}
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 }}
Up : {{ node_uptime.stdout }}
Up : {{ uptime_formatted | trim }}

View File

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

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -29,4 +29,5 @@
owner : "{{ node_status_user }}"
group : "{{ node_status_group }}"
delegate_to : "{{ node_status_host }}"
loop: "{{ range(0, node_status_count) | list }}"
throttle : 1

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

@ -4,7 +4,7 @@ galaxy_info:
license: GPL-2.0-or-later
min_ansible_version: "2.14"
min_ansible_version: "2.14.0"
platforms:
- name: Fedora

View File

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