simplify highstate rerun when node_data pillar empty

This commit is contained in:
Josh Patterson
2025-03-25 19:44:38 -04:00
parent 79388af645
commit 55c815cae8
6 changed files with 30 additions and 53 deletions

View File

@@ -1,7 +1,26 @@
# This state sends an event to the salt-master event bus
# The event will be caught by the reactor and trigger the mine_update orchestration
send_mine_update_event:
module.run:
- name: event.send
- tag: salt/minion/{{grains.id}}/mine_update
{# may be able to use this method if we can figure out multi state run failure - https://github.com/saltstack/salt/issues/66929 #}
# Get the minion ID from the pillar
{% set MINION_ID = grains.id %}
# Run mine.update on all minions
mine.update.update_mine_all_minions:
salt.function:
- name: mine.update
- tgt: '*'
- batch: 50
- retry:
attempts: 3
interval: 1
# Run highstate on the original minion
# we can use concurrent on this highstate because no other highstate would be running when this is called
mine.update.run_highstate_on_{{ MINION_ID }}:
salt.state:
- tgt: {{ MINION_ID }}
- highstate: True
- concurrent: True
- require:
- salt: mine.update.update_mine_all_minions

View File

@@ -1,21 +0,0 @@
# Get the minion ID from the pillar
{% set MINION_ID = salt['pillar.get']('minion_id') %}
# Run mine.update on all minions
update_mine_all_minions:
salt.function:
- name: mine.update
- tgt: '*'
- batch: 50
- retry:
attempts: 3
interval: 1
# Run highstate on the original minion
run_highstate_on_original_minion:
salt.state:
- tgt: {{ MINION_ID }}
- highstate: True
- queue: True
- require:
- salt: update_mine_all_minions

View File

@@ -1,8 +0,0 @@
# This reactor triggers the mine_update orchestration when it receives a mine_update event
trigger_mine_update_orchestration:
runner.state.orchestrate:
- args:
- mods: orch.mine_update
- pillar:
minion_id: {{ data['id'] }}

View File

@@ -3,7 +3,6 @@
include:
- salt.minion
- salt.master.reactor_config_mine_update
hold_salt_master_package:
module.run:

View File

@@ -1,13 +0,0 @@
reactor_config_hypervisor:
file.managed:
- name: /etc/salt/master.d/reactor_mine_update.conf
- contents: |
reactor:
- 'salt/minion/*/mine_update':
- salt://reactor/mine_update.sls
- group: root
- mode: 644
- makedirs: True
- watch_in:
- service: salt_master_service
- order: last

View File

@@ -17,12 +17,17 @@ base:
- schedule
- logrotate
'not G@saltversion:{{saltversion}}':
'I@node_data:False and ( *_manager* or *_eval or *_import or *_standalone )':
- match: compound
- salt.minion
- mine.update
'not G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound
- salt.minion-state-apply-test
- salt.minion
'* and G@saltversion:{{saltversion}}':
'* and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound
- salt.minion
- patch.os.schedule
@@ -33,10 +38,6 @@ base:
- docker
- docker_clean
'*_manager* or *_standalone or *_eval or *_import and I@node_data:False':
- match: compound
- mine.update
'*_eval and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound
- salt.master