Skip to content

Commit f8969c2

Browse files
authored
Merge pull request #13997 from jan-cerny/dconf_idem
Make Ansible in dconf_db_up_to_date idempotent
2 parents 7ba3c6a + 8baed6d commit f8969c2

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)