Skip to content

Commit

Permalink
salt: Add the grains_cache option to Salt minions Force the sync of…
Browse files Browse the repository at this point in the history
… the custom set grains. Relates to saltstack/salt#54331
  • Loading branch information
ezekiel-alexrod committed Apr 15, 2024
1 parent b58f98b commit 3d55242
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions salt/metalk8s/node/grains.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Set control_plane_ip grain:
grains.present:
- name: metalk8s:control_plane_ip
- value: {{ control_plane_ip }}
- onchanges_in:
- module: Force sync of planes grains

{%- else %}

Expand All @@ -35,10 +37,21 @@ Set workload_plane_ip grain:
grains.present:
- name: metalk8s:workload_plane_ip
- value: {{ workload_plane_ip }}
- onchanges_in:
- module: Force sync of planes grains

{%- else %}

No workload-plane network interface present on the host:
test.fail_without_changes

{%- endif %}

{%- if control_plane_ip or workload_plane_ip %}

{#- Since we enable grains cache, the cache is not refreshed automatically #}
Force sync of planes grains:
module.run:
- saltutil.sync_grains: []

{%- endif %}
1 change: 1 addition & 0 deletions salt/metalk8s/node/rocky-linux-grains.sls
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Not a Rocky Linux host, no os grain to set:
test.nop

{%- endif %}

2 changes: 2 additions & 0 deletions salt/metalk8s/salt/minion/files/minion-99-metalk8s.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ id: {{ minion_id }}
retry_dns_count: 5
enable_fqdns_grains: false

grains_cache: true

# use new module.run format
use_superseded:
- module.run
Expand Down
1 change: 1 addition & 0 deletions salt/metalk8s/salt/minion/local.sls
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ Configure salt minion for local mode:
- metalk8s: /etc/metalk8s/bootstrap.yaml
retry_dns_count: 3
enable_fqdns_grains: false
grains_cache: true

0 comments on commit 3d55242

Please sign in to comment.