update mine instead of failing highstate if no node_data

This commit is contained in:
Josh Patterson
2025-03-24 19:49:24 -04:00
parent 0fe3038802
commit 8f40b66e3b
6 changed files with 58 additions and 13 deletions

View File

@@ -24,6 +24,7 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if node_types %}
node_data: node_data:
{% for node_type, host_values in node_types.items() %} {% for node_type, host_values in node_types.items() %}
{% for hostname, details in host_values.items() %} {% for hostname, details in host_values.items() %}
@@ -33,3 +34,6 @@ node_data:
role: {{node_type}} role: {{node_type}}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% else %}
node_data: False
{% endif %}

7
salt/mine/update.sls Normal file
View File

@@ -0,0 +1,7 @@
# 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

21
salt/orch/mine_update.sls Normal file
View File

@@ -0,0 +1,21 @@
# 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

@@ -0,0 +1,8 @@
# 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,6 +3,7 @@
include: include:
- salt.minion - salt.minion
- salt.master.reactor_config_mine_update
hold_salt_master_package: hold_salt_master_package:
module.run: module.run:

View File

@@ -22,7 +22,11 @@ base:
- salt.minion-state-apply-test - salt.minion-state-apply-test
- salt.minion - salt.minion
'* and G@saltversion:{{saltversion}}': '*_eval or *_manager* or *_standalone or *_import and I@node_data:False':
- match: compound
- mine.update
'* and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.minion - salt.minion
- patch.os.schedule - patch.os.schedule
@@ -33,7 +37,7 @@ base:
- docker - docker
- docker_clean - docker_clean
'*_sensor and G@saltversion:{{saltversion}}': '*_sensor and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- sensor - sensor
- ssl - ssl
@@ -49,7 +53,7 @@ base:
- elasticfleet.install_agent_grid - elasticfleet.install_agent_grid
- stig - stig
'*_eval and G@saltversion:{{saltversion}}': '*_eval and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.master - salt.master
- sensor - sensor
@@ -81,7 +85,7 @@ base:
- utility - utility
- elasticfleet - elasticfleet
'*_manager and G@saltversion:{{saltversion}}': '*_manager and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.master - salt.master
- ca - ca
@@ -112,7 +116,7 @@ base:
- stig - stig
- kafka - kafka
'*_standalone and G@saltversion:{{saltversion}}': '*_standalone and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.master - salt.master
- sensor - sensor
@@ -148,7 +152,7 @@ base:
- stig - stig
- kafka - kafka
'*_searchnode and G@saltversion:{{saltversion}}': '*_searchnode and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- firewall - firewall
- ssl - ssl
@@ -161,7 +165,7 @@ base:
- stig - stig
- kafka - kafka
'*_managersearch and G@saltversion:{{saltversion}}': '*_managersearch and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.master - salt.master
- ca - ca
@@ -192,7 +196,7 @@ base:
- stig - stig
- kafka - kafka
'*_heavynode and G@saltversion:{{saltversion}}': '*_heavynode and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- sensor - sensor
- ssl - ssl
@@ -211,7 +215,7 @@ base:
- elasticfleet.install_agent_grid - elasticfleet.install_agent_grid
- elasticagent - elasticagent
'*_import and G@saltversion:{{saltversion}}': '*_import and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- salt.master - salt.master
- sensor - sensor
@@ -239,7 +243,7 @@ base:
- zeek - zeek
- elasticfleet - elasticfleet
'*_receiver and G@saltversion:{{saltversion}}': '*_receiver and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- ssl - ssl
- sensoroni - sensoroni
@@ -251,7 +255,7 @@ base:
- kafka - kafka
- stig - stig
'*_idh and G@saltversion:{{saltversion}}': '*_idh and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- ssl - ssl
- sensoroni - sensoroni
@@ -260,7 +264,7 @@ base:
- elasticfleet.install_agent_grid - elasticfleet.install_agent_grid
- idh - idh
'*_fleet and G@saltversion:{{saltversion}}': '*_fleet and G@saltversion:{{saltversion}} and not I@node_data:False':
- match: compound - match: compound
- ssl - ssl
- sensoroni - sensoroni
@@ -272,7 +276,7 @@ base:
- elasticfleet.install_agent_grid - elasticfleet.install_agent_grid
- schedule - schedule
'*_desktop and G@saltversion:{{saltversion}}': '*_desktop and G@saltversion:{{saltversion}} and not I@node_data:False':
- ssl - ssl
- sensoroni - sensoroni
- telegraf - telegraf