From bbc374b56ea0a324d926184cfb8c666190005756 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Fri, 3 May 2024 09:56:52 -0400 Subject: [PATCH] add logic in orch --- salt/manager/tools/sbin/so-minion | 16 +++++++------- salt/orch/deploy_newnode.sls | 36 +++++++++++++++++++++++++++++++ salt/orch/deploy_searchnode.sls | 16 -------------- 3 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 salt/orch/deploy_newnode.sls delete mode 100644 salt/orch/deploy_searchnode.sls diff --git a/salt/manager/tools/sbin/so-minion b/salt/manager/tools/sbin/so-minion index 8a34ddca0..3f8adfa31 100755 --- a/salt/manager/tools/sbin/so-minion +++ b/salt/manager/tools/sbin/so-minion @@ -607,20 +607,20 @@ function updateMineAndApplyStates() { # tell the minion to populate the mine with data from mine_functions which is populated during setup # this only needs to happen on non managers since they handle this during setup # and they need to wait for ca creation to update the mine - updateMine - checkMine "network.ip_addrs" + #updateMine + #checkMine "network.ip_addrs" # apply the elasticsearch state to the manager if a new searchnode was added - if [[ "$NODETYPE" == "SEARCHNODE" || "$NODETYPE" == "HEAVYNODE" ]]; then + #if [[ "$NODETYPE" == "SEARCHNODE" || "$NODETYPE" == "HEAVYNODE" ]]; then # calls so-common and set_minionid sets MINIONID to local minion id - set_minionid + set_minionid #salt $MINIONID state.apply elasticsearch queue=True --async # salt $MINIONID state.apply soc queue=True --async # $MINIONID is the minion id of the manager and $MINION_ID is the target node or the node being configured - salt-run state.orch orch.deploy_searchnode pillar="{'setup': {'manager': $MINIONID, 'searchnode': $MINION_ID }}" - else + salt-run state.orch orch.deploy_newnode pillar="{'setup': {'manager': $MINIONID, 'newnode': $MINION_ID }}" + #else # run this async so the cli doesn't wait for a return - salt "$MINION_ID" state.highstate --async queue=True - fi + # salt "$MINION_ID" state.highstate --async queue=True + #fi } function setupMinionFiles() { diff --git a/salt/orch/deploy_newnode.sls b/salt/orch/deploy_newnode.sls new file mode 100644 index 000000000..94ed86723 --- /dev/null +++ b/salt/orch/deploy_newnode.sls @@ -0,0 +1,36 @@ +{% set MANAGER = salt['pillar.get']('setup:manager') %} +{% set NEWNODE = salt['pillar.get']('setup:newnode') %} + +{{NEWNODE}}_update_mine: + salt.function: + - name: mine.update + - tgt: {{ NEWNODE }} + - retry: + attempts: 24 + interval: 5 + +{% if NEWNODE.split('_')|last in ['searchnode', 'heavynode'] %} +manager_run_es_soc: + salt.state: + - tgt: {{ MANAGER }} + - sls: + - elasticsearch + - soc + - kwarg: + queue: True + - retry: + attempts: 30 + interval: 10 + - require: + - salt: new_node_update_mine +{% endif %} + +{{NEWNODE}}_run_highstate: + salt.state: + - tgt: {{ NEWNODE }} + - highstate: True + - kwarg: + queue: True + - retry: + attempts: 30 + interval: 10 diff --git a/salt/orch/deploy_searchnode.sls b/salt/orch/deploy_searchnode.sls deleted file mode 100644 index f36f02511..000000000 --- a/salt/orch/deploy_searchnode.sls +++ /dev/null @@ -1,16 +0,0 @@ -{% set MANAGER = salt['pillar.get']('setup:manager') %} -{% set SEARCHNODE = salt['pillar.get']('setup:searchnode') %} - -manager_run_es_soc: - salt.state: - - tgt: {{ MANAGER }} - - sls: - - elasticsearch - - soc - -searchnode_run_highstate: - salt.state: - - tgt: {{ SEARCHNODE }} - - highstate: True - - require: - - salt: manager_run_es_soc