Salt orchestrate pipeline stars based on reactor triggers
Change-Id: I3f8ada34bf7e6e356bf6805d98eb0fa4bd66d8d3
diff --git a/README.rst b/README.rst
index 556c54e..edd6208 100644
--- a/README.rst
+++ b/README.rst
@@ -163,7 +163,7 @@
master:
state_output: changes
-Salt Reactor system configuration
+Salt Reactor system sample
.. code-block:: yaml
@@ -173,6 +173,38 @@
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
-----------
diff --git a/salt/files/_beacon.conf b/salt/files/_beacon.conf
new file mode 100644
index 0000000..9130f45
--- /dev/null
+++ b/salt/files/_beacon.conf
@@ -0,0 +1,3 @@
+{% from "salt/map.jinja" import minion with context %}
+
+beacons: {{ minion.beacon }}
diff --git a/salt/files/provider/_digital_ocean.conf b/salt/files/provider/_digital_ocean.conf
new file mode 100644
index 0000000..6dd3fc0
--- /dev/null
+++ b/salt/files/provider/_digital_ocean.conf
@@ -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 %}
diff --git a/salt/files/provider/_ec2.conf b/salt/files/provider/_ec2.conf
new file mode 100644
index 0000000..1396293
--- /dev/null
+++ b/salt/files/provider/_ec2.conf
@@ -0,0 +1,6 @@
+
+{{ provider_name }}:
+ provider: {{ provider.engine }}
+ {%- if provider.insecure is defined %}
+ insecure: true
+ {%- endif %}
diff --git a/salt/files/provider/_openstack.conf b/salt/files/provider/_openstack.conf
new file mode 100644
index 0000000..89f9904
--- /dev/null
+++ b/salt/files/provider/_openstack.conf
@@ -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 %}
diff --git a/salt/orchestrate/infra_install.sls b/salt/orchestrate/infra_install.sls
new file mode 100644
index 0000000..94a820f
--- /dev/null
+++ b/salt/orchestrate/infra_install.sls
@@ -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
diff --git a/salt/reactor/orchestrate_start.sls b/salt/reactor/orchestrate_start.sls
new file mode 100644
index 0000000..752dc55
--- /dev/null
+++ b/salt/reactor/orchestrate_start.sls
@@ -0,0 +1,5 @@
+
+orchestrate_orchestrate_start:
+ runner.state.orchestrate:
+ - mods: salt://{{ data.data.orchestrate }}
+ - queue: {{ data.data.get('queue', True) }}