Browse Source

Salt orchestrate pipeline stars based on reactor triggers

Change-Id: I3f8ada34bf7e6e356bf6805d98eb0fa4bd66d8d3
pull/54/head
Ales Komarek 7 years ago
parent
commit
5c58de3f46
7 changed files with 133 additions and 1 deletions
  1. +33
    -1
      README.rst
  2. +3
    -0
      salt/files/_beacon.conf
  3. +9
    -0
      salt/files/provider/_digital_ocean.conf
  4. +6
    -0
      salt/files/provider/_ec2.conf
  5. +34
    -0
      salt/files/provider/_openstack.conf
  6. +43
    -0
      salt/orchestrate/infra_install.sls
  7. +5
    -0
      salt/reactor/orchestrate_start.sls

+ 33
- 1
README.rst View File

@@ -163,7 +163,7 @@ Configure verbosity of state output (used for `salt` command)
master:
state_output: changes

Salt Reactor system configuration
Salt Reactor system sample

.. code-block:: yaml

@@ -173,6 +173,38 @@ Salt Reactor system configuration
salt/minion/*/start:
- salt://reactor/minion-started.sls

Run any orchestration pipeline from custom event

.. code-block:: yaml

salt:
master:
reactor:
salt/orchestrate/start:
- salt://salt/reactor/orchestrate_start.sls

Sample event to trigger the basic orchestration pipeline

.. code-block:: bash

salt-call event.send 'salt/orchestrate/start' "{'orchestrate': 'salt/orchestrate/infra_install.sls'}

Classify node from custom event

.. code-block:: yaml

salt:
master:
reactor:
reclass/minion/classify:
- salt://reclass/reactor/node_register.sls

Sample event to trigger the classification

.. 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'}"


Salt syndic
-----------

+ 3
- 0
salt/files/_beacon.conf View File

@@ -0,0 +1,3 @@
{% from "salt/map.jinja" import minion with context %}

beacons: {{ minion.beacon }}

+ 9
- 0
salt/files/provider/_digital_ocean.conf View File

@@ -0,0 +1,9 @@

{{ provider_name }}:
provider: {{ provider.engine }}
{%- if provider.insecure is defined %}
insecure: true
{%- endif %}
{#- location: {{ provider.region }} #}
personal_access_token: {{ provider.api_key }}
{%- endif %}

+ 6
- 0
salt/files/provider/_ec2.conf View File

@@ -0,0 +1,6 @@

{{ provider_name }}:
provider: {{ provider.engine }}
{%- if provider.insecure is defined %}
insecure: true
{%- endif %}

+ 34
- 0
salt/files/provider/_openstack.conf View File

@@ -0,0 +1,34 @@

{{ provider_name }}:
provider: {{ provider.engine }}
{%- if provider.insecure is defined %}
insecure: true
{%- endif %}
identity_url: '{{ provider.identity_url }}'
{%- if provider.compute_name is defined %}
compute_name: {{ provider.get('compute_name', 'nova') }}
{%- endif %}
protocol: ipv4
compute_region: {{ provider.region }}
tenant: {{ provider.tenant }}
user: {{ provider.user }}
{%- if provider.api_key is defined %}
apikey: {{ provider.api_key }}
{%- elif provider.password is defined %}
password: {{ provider.password }}
{%- endif %}
ssh_key_name: salt-cloud
ssh_key_file: /root/.ssh/id_rsa
ssh_interface: {{ provider.get('interface', 'private') }}_ips
networks:
- fixed:
{%- for net in provider.fixed_networks %}
- {{ net }}
{%- endfor %}
- floating:
{%- for net in provider.floating_networks %}
- {{ net }}
{%- endfor %}
{%- if provider.ignore_cidr is defined %}
ignore_cidr: {{ provider.ignore_cidr }}
{%- endif %}

+ 43
- 0
salt/orchestrate/infra_install.sls View File

@@ -0,0 +1,43 @@

salt_state_config_node:
salt.state:
- tgt: 'salt:master'
- tgt_type: pillar
- sls: salt.master
- queue: True

reclass_state_config_nodes
salt.state:
- tgt: 'reclass:storage'
- tgt_type: pillar
- sls: reclass
- queue: True
- requires:
- salt: salt_state_config_node

linux_state_all_nodes:
salt.state:
- tgt: 'linux:system'
- tgt_type: pillar
- sls: linux
- queue: True
- requires:
- salt: reclass_state_config_nodes

salt_state_all_nodes:
salt.state:
- tgt: 'salt:minion'
- tgt_type: pillar
- sls: salt.minion
- queue: True
- requires:
- salt: linux_state_all_nodes

ntp_ssh_state_all_nodes:
salt.state:
- tgt: 'salt:minion'
- tgt_type: pillar
- sls: ntp,openssh
- queue: True
- requires:
- salt: salt_state_all_nodes

+ 5
- 0
salt/reactor/orchestrate_start.sls View File

@@ -0,0 +1,5 @@

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

Loading…
Cancel
Save