Skip to content

Commit 8baed6d

Browse files
committed
Make Ansible in dconf_db_up_to_date idempotent
This change will make the Ansible remediation for rule dconf_db_up_to_date idempotent. The solution is inspired by OVAL check in this rule. The Ansible remediation will update the dconf database only if some key file is newer than the database. Resolves: https://issues.redhat.com/browse/OPENSCAP-6229
1 parent 13d291b commit 8baed6d

File tree

1 file changed

+20
-1
lines changed
  • linux_os/guide/system/software/gnome/dconf_db_up_to_date/ansible

1 file changed

+20
-1
lines changed

linux_os/guide/system/software/gnome/dconf_db_up_to_date/ansible/shared.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@
33
# strategy = unknown
44
# complexity = low
55
# disruption = medium
6-
- name: "Run dconf update"
6+
7+
{{% macro check_db_is_up_to_date(db_name) %}}
8+
- name: "{{{ rule_title }}} - Get database modification time for {{{ db_name }}}"
9+
ansible.builtin.stat:
10+
path: '/etc/dconf/db/{{{ db_name }}}'
11+
register: '{{{ db_name }}}_db'
12+
13+
- name: "{{{ rule_title }}} - Get keyfiles for {{{ db_name }}}"
14+
ansible.builtin.find:
15+
paths: '/etc/dconf/db/{{{ db_name }}}.d/'
16+
register: '{{{ db_name }}}_keyfiles'
17+
18+
- name: "{{{ rule_title }}} - Run dconf update for {{{ db_name }}}"
719
ansible.builtin.command:
820
cmd: dconf update
21+
when: "not {{{ db_name }}}_db.stat.exists or {{{ db_name }}}_keyfiles.files | length > 0 and {{{ db_name }}}_keyfiles.files | map(attribute='mtime') | max > {{{ db_name }}}_db.stat.mtime"
22+
{{% endmacro %}}
23+
24+
{{{ check_db_is_up_to_date(dconf_gdm_dir.split(".")[0]) }}}
25+
{{% if dconf_gdm_dir.split(".")[0] != "local" %}}
26+
{{{ check_db_is_up_to_date("local") }}}
27+
{{% endif %}}

0 commit comments

Comments
 (0)