Skip to content

Commit

Permalink
Add ability to get confirmation on event
Browse files Browse the repository at this point in the history
Currently salt doesn't allow to get confirmation on minion upon
successfull reactor execution on event. However there can be issues with
reactor in salt 2017.7 [1] or reactor register state can fail if pillar
failed to render, so node registration confirmation maybe needed. In order
to enable this functionality add node_confirm_registration parameter to
event data with value true.

[1] saltstack/salt#47539
Change-Id: I1abc4fdf172e018dcdb48abcf61532fb51ad3660
Related-Prod: https://mirantis.jira.com/browse/PROD-21463
  • Loading branch information
mkarpin committed Aug 7, 2018
1 parent 1ad4760 commit a82b3e8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.rst
Expand Up @@ -108,6 +108,22 @@ Event to trigger the node classification

Both actions will use the minion ID as the node_name to be updated.

Confirmation of node classification

Currently salt doesn't allow to get confirmation on minion upon successfull reactor execution on event. However there can be issues
with reactor in salt 2017.7 (https://github.com/saltstack/salt/issues/47539) or reactor register state can fail if pillar failed
to render, so node registration confirmation maybe needed. In order to enable this functionality add node_confirm_registration parameter to
event data with value true:

.. code-block:: bash
salt-call event.send 'reclass/minion/classify' "{'node_master_ip': '$config_host', 'node_ip': '${node_ip}', 'node_domain': '$node_domain', 'node_cluster': '$node_cluster', 'node_hostname': '$node_hostname', 'node_os': '$node_os', node_confirm_registration: true}"
Then on minion side execute:
salt-call mine.get 'salt:master' ${minion_id}_classified pillar
If true is returned than registration has passed successfully
Event to trigger the node declassification

.. code-block:: bash
Expand Down
14 changes: 14 additions & 0 deletions reclass/orchestrate/reactor/node_register.sls
Expand Up @@ -19,3 +19,17 @@ regenerate_all_nodes:
- queue: True
- require:
- salt: classify_node_{{ node_name }}

{% if node_data.get('node_confirm_registration', False) | to_bool %}
confirm_node_classification_{{ node_name }}:
salt.function:
- tgt: 'salt:master'
- tgt_type: pillar
- name: mine.send
- arg:
- '{{ node_name }}_classified'
- 'mine_function=cmd.shell'
- 'echo true'
- require:
- salt: regenerate_all_nodes
{% endif %}
12 changes: 12 additions & 0 deletions reclass/orchestrate/reactor/node_unregister.sls
Expand Up @@ -8,3 +8,15 @@ unregister_node_{{ node_name }}:
- queue: True
- pillar:
node_name: {{ node_name }}

{% if salt['mine.get']('salt:master', node_name + '_classified', 'pillar') %}
confirm_node_unregistration_{{ node_name }}:
salt.function:
- tgt: 'salt:master'
- tgt_type: pillar
- name: mine.delete
- arg:
- '{{ node_name }}_classified'
- require:
- salt: unregister_node_{{ node_name }}
{% endif %}

0 comments on commit a82b3e8

Please sign in to comment.