Browse Source

Salt reactor features refactoring

Change-Id: Ifac3f5e03099e8190db0a3af62a7be1f762f87be
pull/56/head
Adam Tengler 7 years ago
parent
commit
62188969cc
17 changed files with 66 additions and 32 deletions
  1. +2
    -1
      README.rst
  2. +3
    -0
      _modules/saltkey.py
  3. +0
    -6
      salt/orchestrate/key_create.sls
  4. +0
    -6
      salt/orchestrate/key_remove.sls
  5. +0
    -0
      salt/orchestrate/reactor/infra_install.sls
  6. +13
    -0
      salt/orchestrate/reactor/key_create.sls
  7. +11
    -0
      salt/orchestrate/reactor/key_remove.sls
  8. +1
    -0
      salt/orchestrate/reactor/master_update.sls
  9. +1
    -0
      salt/orchestrate/reactor/node_install.sls
  10. +2
    -1
      salt/reactor/infra_install.sls
  11. +7
    -8
      salt/reactor/key_create.sls
  12. +6
    -8
      salt/reactor/key_remove.sls
  13. +1
    -0
      salt/reactor/minion_start.sls
  14. +2
    -1
      salt/reactor/node_install.sls
  15. +2
    -1
      salt/reactor/orchestrate_start.sls
  16. +9
    -0
      salt/reactor_sls/key_create.sls
  17. +6
    -0
      salt/reactor_sls/key_remove.sls

+ 2
- 1
README.rst View File

@@ -231,7 +231,8 @@ Event to trigger the key creation

.. code-block:: bash

salt-call event.send 'salt/key/create' "{'node_name': 'id-of-minion', 'orch_post_create': 'kubernetes/orchestrate/compute_install.sls'}"
salt-call event.send 'salt/key/create' \
> "{'node_id': 'id-of-minion', 'node_host': '172.16.10.100', 'orch_post_create': 'kubernetes.orchestrate.compute_install', 'post_create_pillar': {'node_name': 'id-of-minion'}}"

.. note::


+ 3
- 0
_modules/saltkey.py View File

@@ -32,6 +32,9 @@ def key_create(id_, host, force=False):
'''
Generates minion keypair, accepts it on master and injects it to minion via SSH.

:param id_: expected minion ID of target node
:param host: IP address or resolvable hostname/FQDN of target node

CLI Examples:

.. code-block:: bash

+ 0
- 6
salt/orchestrate/key_create.sls View File

@@ -1,6 +0,0 @@
{%- set node_name = salt['pillar.get']('node_name') %}

key_create_{{ node_name }}:
salt.wheel:
- name: key.gen_accept
- id_: {{ node_name }}

+ 0
- 6
salt/orchestrate/key_remove.sls View File

@@ -1,6 +0,0 @@
{%- set node_name = salt['pillar.get']('node_name') %}

key_create_{{ node_name }}:
salt.wheel:
- name: key.delete
- match: {{ node_name }}

salt/orchestrate/infra_install.sls → salt/orchestrate/reactor/infra_install.sls View File


+ 13
- 0
salt/orchestrate/reactor/key_create.sls View File

@@ -0,0 +1,13 @@
{%- set node_id = salt['pillar.get']('node_id') %}
{%- set node_host = salt['pillar.get']('node_host') %}

linux_state_all_nodes:
salt.state:
- tgt: 'salt:master'
- tgt_type: pillar
- sls: salt.reactor_sls.key_create
- queue: True
- pillar:
node_id: {{ node_id }}
node_host: {{ node_host }}


+ 11
- 0
salt/orchestrate/reactor/key_remove.sls View File

@@ -0,0 +1,11 @@
{%- set node_id = salt['pillar.get']('node_id') %}

linux_state_all_nodes:
salt.state:
- tgt: 'salt:master'
- tgt_type: pillar
- sls: salt.reactor_sls.key_remove
- queue: True
- pillar:
node_id: {{ node_id }}


salt/orchestrate/master_update.sls → salt/orchestrate/reactor/master_update.sls View File

@@ -14,3 +14,4 @@ reclass_state_config_nodes
- queue: True
- require:
- salt: salt_state_config_node


salt/orchestrate/node_install.sls → salt/orchestrate/reactor/node_install.sls View File

@@ -21,3 +21,4 @@ misc_states:
- queue: True
- require:
- salt: salt_state


+ 2
- 1
salt/reactor/infra_install.sls View File

@@ -1,5 +1,6 @@

orchestrate_infra_install:
runner.state.orchestrate:
- mods: salt://salt/orchestrate/infra_install.sls
- mods: salt.orchestrate.reactor.infra_install
- queue: True


+ 7
- 8
salt/reactor/key_create.sls View File

@@ -3,27 +3,26 @@

orchestrate_node_key_pre_create:
runner.state.orchestrate:
- mods: salt://{{ data.data.orch_pre_create }}
- mods: {{ data.data.orch_pre_create }}
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
- pillar: {{ data.data.get('orch_pre_create_pillar', {}) }}

{% endif %}

node_key_create:
runner.state.orchestrate:
- mods: salt://salt/orchestrate/key_create.sls
- mods: salt.orchestrate.reactor.key_create
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
node_id: {{ data.data['node_id'] }}
node_host: {{ data.data['node_host'] }}

{% if data.data.orch_post_create is defined %}

orchestrate_node_key_post_create:
runner.state.orchestrate:
- mods: salt://{{ data.data.orch_post_create }}
- mods: {{ data.data.orch_post_create }}
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
- pillar: {{ data.data.get('orch_post_create_pillar', {}) }}

{% endif %}

+ 6
- 8
salt/reactor/key_remove.sls View File

@@ -3,27 +3,25 @@

orchestrate_node_key_pre_remove:
runner.state.orchestrate:
- mods: salt://{{ data.data.orch_pre_remove }}
- mods: {{ data.data.orch_pre_remove }}
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
- pillar: {{ data.data.get('orch_pre_remove_pillar', {}) }}

{% endif %}

node_key_remove:
runner.state.orchestrate:
- mods: salt://salt/orchestrate/key_remove.sls
- mods: salt.orchestrate.reactor.key_remove.sls
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
node_id: {{ data.data['node_id'] }}

{% if data.data.orch_post_remove is defined %}

orchestrate_node_key_post_remove:
runner.state.orchestrate:
- mods: salt://{{ data.data.orch_post_remove }}
- mods: {{ data.data.orch_post_remove }}
- queue: True
- pillar:
node_name: {{ data.data['node_name'] }}
- pillar: {{ data.data.get('orch_post_remove_pillar', {}) }}

{% endif %}

+ 1
- 0
salt/reactor/minion_start.sls View File

@@ -8,3 +8,4 @@ minion_refresh_pillar:
local.saltutil.refresh_pillar:
- tgt: {{ data.id }}
- queue: True


+ 2
- 1
salt/reactor/node_install.sls View File

@@ -1,7 +1,8 @@

orchestrate_node_install:
runner.state.orchestrate:
- mods: salt://salt/orchestrate/node_install.sls
- mods: salt.reactor.orchestrate.node_install
- queue: True
- pillar:
event_originator: {{ data.id }}


+ 2
- 1
salt/reactor/orchestrate_start.sls View File

@@ -1,5 +1,6 @@

orchestrate_orchestrate_run:
runner.state.orchestrate:
- mods: salt://{{ data.data.orchestrate }}
- mods: {{ data.data.orchestrate }}
- queue: {{ data.data.get('queue', True) }}


+ 9
- 0
salt/reactor_sls/key_create.sls View File

@@ -0,0 +1,9 @@
{%- set node_id = salt['pillar.get']('node_id') %}
{%- set node_host = salt['pillar.get']('node_host') %}

key_create_{{ node_id }}:
module.run:
saltkey.key_create:
- id_: {{ node_id }}
- host: {{ node_host }}


+ 6
- 0
salt/reactor_sls/key_remove.sls View File

@@ -0,0 +1,6 @@
{%- set node_id = salt['pillar.get']('node_id') %}

key_create_{{ node_id }}:
salt.wheel:
- name: key.delete
- match: {{ node_id }}

Loading…
Cancel
Save