Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
584a33172c | |||
b2300e8ba8 | |||
3cc31ecb40 | |||
db75e69d99 | |||
665560250f | |||
d737b08719 | |||
d25730cb74 | |||
f7e878ce39 | |||
1ad31b8305 | |||
2cacd15d59 | |||
bdfa48f95d | |||
c104223bc0 | |||
78c47af393 | |||
a29281515b | |||
df89b4306f | |||
152e7e3815 | |||
a927a26546 | |||
028bde883e | |||
baa7af81ea | |||
bae88f96a7 | |||
884ac0bf4d |
@ -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.21
|
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
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
---
|
---
|
||||||
requires_ansible: ">=2.15.0"
|
requires_ansible: ">=2.14.0"
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -6,7 +6,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- 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:
|
||||||
|
- 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:
|
||||||
@ -9,32 +11,8 @@
|
|||||||
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
- "Restart_syslog_{{ ansible_distribution | lower }}_{{ ansible_distribution_major_version }}"
|
||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
- name: Ensure hostname package is present
|
- name: Unable to set hostname
|
||||||
ansible.builtin.package:
|
ansible.builtin.debug:
|
||||||
name: hostname
|
msg: "Unable to set hostname for {{ ansible_hostname }} to {{ inventory_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")
|
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -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"
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -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";
|
|
@ -1,20 +1,16 @@
|
|||||||
---
|
---
|
||||||
- name: Set host IP address or set a default
|
- name: Format uptime containing days
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
host_ip : "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
|
uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}"
|
||||||
|
when:
|
||||||
|
- "'day' in motd_host_uptime"
|
||||||
|
|
||||||
|
|
||||||
- name: Install Perl if needed
|
- name: Format uptime not containing days
|
||||||
ansible.builtin.package:
|
ansible.builtin.set_fact:
|
||||||
name : perl
|
uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}"
|
||||||
state : present
|
when:
|
||||||
|
- "'day' not in motd_host_uptime"
|
||||||
|
|
||||||
- name: Get system uptime from script
|
|
||||||
ansible.builtin.script:
|
|
||||||
cmd : "scripts/get_uptime.pl {{ ansible_uptime_seconds }}"
|
|
||||||
register : node_uptime
|
|
||||||
changed_when : false
|
|
||||||
|
|
||||||
|
|
||||||
- name: Update MOTD
|
- name: Update MOTD
|
||||||
@ -26,4 +22,3 @@
|
|||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
|___/
|
|___/
|
||||||
|
|
||||||
|
|
||||||
Host : {{ ansible_fqdn }}
|
Host : {{ inventory_hostname }}
|
||||||
IP : {{ host_ip }}
|
IP : {{ motd_host_ip }}
|
||||||
CPU : {{ ansible_processor_vcpus }} x {{ ansible_processor[2] }}
|
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 : {{ node_uptime.stdout }}
|
Up : {{ uptime_formatted }}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
---
|
---
|
||||||
# defaults file for node_status
|
node_status_host : zg-lxut02.thezengarden.net
|
||||||
|
node_status_user : chris
|
||||||
|
node_status_group : chris
|
||||||
|
node_status_dir : /home/chris/node_status
|
||||||
|
node_status_file : status.csv
|
||||||
|
node_status_lc : 3
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for node_status
|
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -1,2 +1,33 @@
|
|||||||
---
|
---
|
||||||
# tasks file for node_status
|
- name: Update node status when not running in a container
|
||||||
|
when: not ansible_virtualization_type | regex_search("docker|podman|container")
|
||||||
|
block:
|
||||||
|
- name: Create directory {{ node_status_dir }}
|
||||||
|
ansible.builtin.file:
|
||||||
|
path : "{{ node_status_dir }}"
|
||||||
|
state : directory
|
||||||
|
mode : '0755'
|
||||||
|
become : false
|
||||||
|
run_once : true
|
||||||
|
delegate_to : "{{ node_status_host }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Capture system uptime
|
||||||
|
ansible.builtin.command : uptime
|
||||||
|
register : r_node_status_uptime
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
|
||||||
|
- name: Log node status
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path : "{{ node_status_dir }}/{{ node_status_file }}"
|
||||||
|
state : present
|
||||||
|
regexp : "{{ inventory_hostname }}"
|
||||||
|
line : "{{ ansible_date_time.epoch }},,{{ inventory_hostname }},,{{ ansible_distribution }} {{ ansible_distribution_version }},,{{ r_node_status_uptime.stdout }}"
|
||||||
|
create : true
|
||||||
|
mode : '0644'
|
||||||
|
owner : "{{ node_status_user }}"
|
||||||
|
group : "{{ node_status_group }}"
|
||||||
|
delegate_to : "{{ node_status_host }}"
|
||||||
|
throttle : 1
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for node_status
|
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
@ -4,7 +4,7 @@ galaxy_info:
|
|||||||
|
|
||||||
license: GPL-2.0-or-later
|
license: GPL-2.0-or-later
|
||||||
|
|
||||||
min_ansible_version: "2.14"
|
min_ansible_version: "2.14.0"
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora
|
- name: Fedora
|
||||||
|
Reference in New Issue
Block a user