.. literalinclude:: tests/pillar/master_single_reclass.sls | .. literalinclude:: tests/pillar/master_single_reclass.sls | ||||
:language: yaml | :language: yaml | ||||
Salt master with Architect ENC metadata backend | |||||
.. code-block:: yaml | |||||
salt: | |||||
master: | |||||
enabled: true | |||||
pillar: | |||||
engine: architect | |||||
project: project-name | |||||
host: architect-api | |||||
port: 8181 | |||||
username: salt | |||||
password: password | |||||
Salt master with multiple ext_pillars | Salt master with multiple ext_pillars | ||||
.. literalinclude:: tests/pillar/master_single_extpillars.sls | .. literalinclude:: tests/pillar/master_single_extpillars.sls | ||||
host: 127.0.0.1 | host: 127.0.0.1 | ||||
port: 9999 | port: 9999 | ||||
Salt engine definition for saltgraph metadata collector | Salt engine definition for saltgraph metadata collector | ||||
.. code-block:: yaml | .. code-block:: yaml | ||||
password: salt | password: salt | ||||
database: salt | database: salt | ||||
Salt engine definition for Architect service | |||||
.. code-block:: yaml | |||||
salt: | |||||
master: | |||||
engine: | |||||
architect: | |||||
engine: architect | |||||
project: project-name | |||||
host: architect-api | |||||
port: 8181 | |||||
username: salt | |||||
password: password | |||||
Salt engine definition for sending events from docker events | Salt engine definition for sending events from docker events | ||||
.. code-block:: yaml | .. code-block:: yaml |
# -*- coding: utf-8 -*- | |||||
""" | |||||
Salt engine for intercepting state jobs and forwarding to the Architect | |||||
service. | |||||
""" | |||||
# Import python libs | |||||
from __future__ import absolute_import | |||||
import json | |||||
import logging | |||||
# Import salt libs | |||||
import salt.utils.event | |||||
import salt.utils.http | |||||
log = logging.getLogger(__name__) | |||||
def start(project='default', | |||||
host='127.0.0.1', | |||||
port=8181, | |||||
username=None, | |||||
password=None): | |||||
''' | |||||
Listen to state jobs events and forward Salt states | |||||
''' | |||||
url = "{}://{}:{}/salt/{}/event/{}".format('http', | |||||
host, | |||||
port, | |||||
'v1', | |||||
project) | |||||
target_functions = ['state.sls', 'state.apply', 'state.highstate'] | |||||
if __opts__['__role'] == 'master': | |||||
event_bus = salt.utils.event.get_master_event(__opts__, | |||||
__opts__['sock_dir'], | |||||
listen=True) | |||||
else: | |||||
event_bus = salt.utils.event.get_event( | |||||
'minion', | |||||
transport=__opts__['transport'], | |||||
opts=__opts__, | |||||
sock_dir=__opts__['sock_dir'], | |||||
listen=True) | |||||
log.info('Salt Architect engine initialised') | |||||
while True: | |||||
event = event_bus.get_event() | |||||
if event and event.get('fun', None) in target_functions: | |||||
is_test_run = 'test=true' in [arg.lower() for arg in event.get('fun_args', [])] | |||||
if not is_test_run: | |||||
data = salt.utils.http.query(url=url, | |||||
method='POST', | |||||
decode=False, | |||||
data=json.dumps(event)) | |||||
if 'OK' in data.get('body', ''): | |||||
log.info("Architect Engine request to '{}'" | |||||
" was successful".format(url)) | |||||
else: | |||||
log.warning("Problem with Architect Engine" | |||||
" request to '{}' ({})".format(url, data)) |
{% from "salt/map.jinja" import master with context %} | |||||
project: {{ master.pillar.project }} | |||||
host: {{ master.pillar.host }} | |||||
port: {{ master.pillar.port }} | |||||
{%- if master.pillar.username is defined %} | |||||
username: {{ master.pillar.username }} | |||||
password: {{ master.pillar.password }} | |||||
{%- endif %} |
- {{ master.pillar.get('salt', {}).get('path', '/srv/salt/pillar') }} | - {{ master.pillar.get('salt', {}).get('path', '/srv/salt/pillar') }} | ||||
{%- endif %} | {%- endif %} | ||||
{%- if master.pillar.engine == 'architect' %} | |||||
ext_pillar: | |||||
- cmd_yaml: 'architect-salt-pillar %s' | |||||
master_tops: | |||||
ext_nodes: architect-salt-top | |||||
{%- endif %} | |||||
{%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined) %} | {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined) %} | ||||
reclass: &reclass | reclass: &reclass |
{%- endif %} | {%- endif %} | ||||
{%- elif master.pillar.engine == 'architect' %} | |||||
salt_pillar_architect_package: | |||||
pip.installed: | |||||
- name: architect-client | |||||
salt_pillar_architect_package_config_dir: | |||||
file.directory: | |||||
- name: /etc/architect | |||||
salt_pillar_architect_package_config_file: | |||||
file.managed: | |||||
- name: /etc/architect/client.yml | |||||
- source: salt://salt/files/architect.yml | |||||
- user: root | |||||
- template: jinja | |||||
- require: | |||||
- file: salt_pillar_architect_package_config_dir | |||||
{%- elif master.pillar.engine == 'reclass' %} | {%- elif master.pillar.engine == 'reclass' %} | ||||
include: | include: |