Browse Source

Merge pull request #421 from noelmcloughlin/metastate

feat(formula): add metastate per community convention
tags/v1.2.0
Imran Iqbal 4 years ago
parent
commit
718f5c7558
No account linked to committer's email address
6 changed files with 74 additions and 12 deletions
  1. +7
    -0
      docs/README.rst
  2. +11
    -0
      pillar.example
  3. +6
    -0
      salt/defaults.yaml
  4. +30
    -0
      salt/init.sls
  5. +8
    -0
      salt/pkgrepo/init.sls
  6. +12
    -12
      salt/standalone.sls

+ 7
- 0
docs/README.rst View File

.. contents:: .. contents::
:local: :local:


``salt``
^^^^^^^^

*Meta-state (This is a state that includes other states)*.

This calls all runable states based on configured pillar data.

``salt.minion`` ``salt.minion``
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^



+ 11
- 0
pillar.example View File

# salt master config # salt master config
master_config_use_TOFS: true master_config_use_TOFS: true
master: master:
standalone: false
fileserver_backend: fileserver_backend:
- git - git
- s3fs - s3fs
minion_config_use_TOFS: true minion_config_use_TOFS: true
minion: minion:


# standalone setup
master_type: false # see init.sls & standalone.sls

# single master setup # single master setup
master: salt master: salt


- test.ping - test.ping
- saltutil.find_job - saltutil.find_job


# init.sls skips salt.api and salt.syndic states
# unless those dicts are populated with something
api:
somekey: somevalue
syndic:
somekey: somevalue

# salt cloud config # salt cloud config
cloud: cloud:
master: salt master: salt

+ 6
- 0
salt/defaults.yaml View File

salt_api: salt-api salt_api: salt-api
salt_ssh: salt-ssh salt_ssh: salt-ssh


pkgrepo: '' # see osfamilymap
ssh_roster: {} # see pillar data

python_git: python-git python_git: python-git
python_dulwich: python-dulwich python_dulwich: python-dulwich


master: master:
gitfs_provider: gitpython gitfs_provider: gitpython
minion:
master_type: true # see init.sls & standalone.sls


gitfs: gitfs:
dulwich: dulwich:
maps: salt://salt/files/cloud.maps.d maps: salt://salt/files/cloud.maps.d


salt_formulas: salt_formulas:
list: {} # via pillar data
checkout_orig_branch: false checkout_orig_branch: false
git_opts: git_opts:
default: default:

+ 30
- 0
salt/init.sls View File

# -*- coding: utf-8 -*-
# vim: ft=sls

include:
- salt.pkgrepo
{%- if salt.config.get('salt_formulas:list') %}
- salt.formulas
{%- endif %}
{%- if salt.config.get('salt:master')|length > 1 %}
- salt.master
{%- endif %}
{%- if salt.config.get('salt:cloud')|length > 1 %}
- salt.cloud
{%- endif %}
{%- if salt.config.get('salt:ssh_roster') %}
- salt.ssh
{%- endif %}
{%- if salt.config.get('salt:minion')|length > 1 %}
{%- if salt.config.get('salt:minion:master_type') %}
- salt.minion
{%- else %}
- salt.standalone
{%- endif %}
{%- endif %}
{%- if salt.config.get('salt:api') %}
- salt.api
{%- endif %}
{%- if salt.config.get('salt:syndic') %}
- salt.syndic
{%- endif %}

+ 8
- 0
salt/pkgrepo/init.sls View File

# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "salt/map.jinja" import salt_settings with context %}

{%- if salt_settings.pkgrepo %}

include: include:
- .{{ grains['os_family']|lower }} - .{{ grains['os_family']|lower }}

{%- endif %}

+ 12
- 12
salt/standalone.sls View File

{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{% from "salt/map.jinja" import salt_settings with context %} {% from "salt/map.jinja" import salt_settings with context %}


salt-minion:
{% if salt_settings.install_packages %}
salt-minion-standalone:
{% if salt_settings.install_packages %}
pkg.installed: pkg.installed:
- name: {{ salt_settings.salt_minion }} - name: {{ salt_settings.salt_minion }}
{%- if salt_settings.version is defined %}
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }} - version: {{ salt_settings.version }}
{%- endif %}
{% endif %}
{%- endif %}
{% endif %}
file.recurse: file.recurse:
- name: {{ salt_settings.config_path }}/minion.d - name: {{ salt_settings.config_path }}/minion.d
- template: jinja - template: jinja
- exclude_pat: _* - exclude_pat: _*
- context: - context:
standalone: True standalone: True
{%- if salt_settings.minion.master_type is defined and salt_settings.minion.master_type == 'disable' %}
{%- if not salt_settings.minion.master_type %}
service.running: service.running:
- enable: True - enable: True
{%- else %}
{%- else %}
service.dead: service.dead:
- enable: False - enable: False
{%- endif %}
{%- endif %}
- name: {{ salt_settings.minion_service }} - name: {{ salt_settings.minion_service }}
- require: - require:
{% if salt_settings.install_packages %}
- pkg: salt-minion
{% endif %}
- file: salt-minion
{% if salt_settings.install_packages %}
- pkg: salt-minion-standalone
{% endif %}
- file: salt-minion-standalone


# clean up old _defaults.conf file if they have it around # clean up old _defaults.conf file if they have it around
remove-old-standalone-conf-file: remove-old-standalone-conf-file:

Loading…
Cancel
Save