mirror of
https://github.com/ansible/ansible.git
synced 2026-05-28 04:32:20 -04:00
Merge 6982b99de0 into ba21909655
This commit is contained in:
commit
eba5e573eb
3 changed files with 19 additions and 5 deletions
3
changelogs/fragments/fix_systemd_facts.yml
Normal file
3
changelogs/fragments/fix_systemd_facts.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- facts - add systemd full_version and ensure version is integer
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
import contextlib
|
||||
|
||||
|
||||
from ansible.module_utils.facts.collector import BaseFactCollector
|
||||
from ansible.module_utils.facts.system.service_mgr import ServiceMgrFactCollector
|
||||
|
|
@ -39,9 +41,16 @@ class SystemdFactCollector(BaseFactCollector):
|
|||
if rc != 0:
|
||||
return systemd_facts
|
||||
|
||||
systemd_facts["systemd"] = {
|
||||
"features": str(stdout.split("\n")[1]),
|
||||
"version": int(stdout.split(" ")[1]),
|
||||
}
|
||||
systemd_version = stdout.split(" ")[1]
|
||||
|
||||
systemd_facts["systemd"] = {}
|
||||
systemd_facts["systemd"]["features"] = stdout.split("\n")[1]
|
||||
systemd_facts["systemd"]["full_version"] = str(
|
||||
stdout.split(" ")[2].split(")")[0][1:],
|
||||
)
|
||||
with contextlib.suppress(ValueError):
|
||||
systemd_version = int(systemd_version)
|
||||
|
||||
systemd_facts["systemd"]["version"] = systemd_version
|
||||
|
||||
return systemd_facts
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Show Gathered Facts
|
||||
- name: Show systemd facts
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ ansible_systemd }}"
|
||||
|
||||
|
|
@ -9,3 +9,5 @@
|
|||
- ansible_systemd.version | int > 0
|
||||
- ansible_systemd.version is match('^[1-9][0-9][0-9]$')
|
||||
- ansible_systemd.features | regex_search('(\\+|-)(PAM|AUDIT)') is not none
|
||||
- ansible_systemd.full_version is match('^[1-9][0-9][0-9](.|-|~)|^[1-9][0-9][0-9]$')
|
||||
- (ansible_systemd.full_version | type_debug == 'AnsibleUnsafeText' or ansible_systemd.full_version | type_debug == 'str')
|
||||
|
|
|
|||
Loading…
Reference in a new issue