From b2300e8ba82f26c5bff8c72d16535584926bf26e Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Sat, 2 Mar 2024 16:30:55 -0500 Subject: [PATCH] Add vars for replace filter --- galaxy.yml | 2 +- roles/motd/defaults/main.yml | 2 ++ roles/motd/tasks/main.yml | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/galaxy.yml b/galaxy.yml index 37131e2..ab530ff 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -8,7 +8,7 @@ namespace: jchristianh name: baseos # The version of the collection. Must be compatible with semantic versioning -version: 1.0.28 +version: 1.0.29 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/roles/motd/defaults/main.yml b/roles/motd/defaults/main.yml index 8efa069..036a7f6 100644 --- a/roles/motd/defaults/main.yml +++ b/roles/motd/defaults/main.yml @@ -7,5 +7,7 @@ motd_host_uptime : "{{ now().replace(microsecond=0) - now().fromtimestamp(now( 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" ... diff --git a/roles/motd/tasks/main.yml b/roles/motd/tasks/main.yml index 24144be..3b841d9 100644 --- a/roles/motd/tasks/main.yml +++ b/roles/motd/tasks/main.yml @@ -1,14 +1,14 @@ --- - name: Format uptime containing days ansible.builtin.set_fact: - uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_day_filter, '\\1 \\2 hours \\3 minutes') }}" + uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_day_filter, motd_day_filter_repl) }}" when: - "'day' in motd_host_uptime" - name: Format uptime not containing days ansible.builtin.set_fact: - uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_nonday_filter, '\\1 hours \\2 minutes \\3 seconds') }}" + uptime_formatted: "{{ motd_host_uptime | regex_replace(motd_nonday_filter, motd_nonday_filter_repl) }}" when: - "'day' not in motd_host_uptime"