Browse Source

Merge branch '20191216133640' into upstream

tags/v1.0.0
Imran Iqbal 5 years ago
parent
commit
059d4f04d5
No account linked to committer's email address
3 changed files with 15 additions and 3 deletions
  1. +8
    -0
      pillar.example
  2. +2
    -1
      salt/formulas.jinja
  3. +5
    -2
      salt/formulas.sls

+ 8
- 0
pillar.example View File

base: base:
- salt-formula - salt-formula
- postfix-formula - postfix-formula
- nginx-formula: # We can also override some options per formula
rev: 'v1.1.0' # Pin a version
- openssh-formula:
rev: '3e01ad8' # or pin a commit id
dev: dev:
- salt-formula - salt-formula
- postfix-formula - postfix-formula
- openssh-formula - openssh-formula
- nginx-formula:
# You can also pull from another location
name: 'https://github.com/another-fork-location/salt-formula.git'
rev: 'feat/feature'
# Likewise for the alternative method (single directory, multiple branches) # Likewise for the alternative method (single directory, multiple branches)
production: production:
- salt-formula - salt-formula

+ 2
- 1
salt/formulas.jinja View File



{%- macro formulas_roots(env) -%} {%- macro formulas_roots(env) -%}
{%- set value = [] -%} {%- set value = [] -%}
{%- for dir in formulas.get(env, []) -%}
{%- for formula in formulas.get(env, []) -%}
{%- set dir = formula | first if formula is mapping else formula %}
{%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%} {%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%}
{%- do value.append('{0}/{1}'.format(basedir, dir)) -%} {%- do value.append('{0}/{1}'.format(basedir, dir)) -%}
{%- endfor -%} {%- endfor -%}

+ 5
- 2
salt/formulas.sls View File

# Loop over all formulas listed in pillar data # Loop over all formulas listed in pillar data
{%- for env, entries in salt['pillar.get']('salt_formulas:list', {}).items() %} {%- for env, entries in salt['pillar.get']('salt_formulas:list', {}).items() %}
{%- for entry in entries %} {%- for entry in entries %}
{%- set f_name = entry | first if entry is mapping else entry %}
{%- set f_opts = entry[f_name] if entry is mapping else {} %}


{%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml %} {%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml %}
{%- set gitdir = '{0}/{1}'.format(basedir, entry) %}
{%- set gitdir = '{0}/{1}'.format(basedir, f_name) %}
{%- set update = formulas_git_opt(env, 'update')|load_yaml %} {%- set update = formulas_git_opt(env, 'update')|load_yaml %}


{%- if formulas_settings.checkout_orig_branch %} {%- if formulas_settings.checkout_orig_branch %}
{%- if gitdir_env not in processed_gitdir_envs %} {%- if gitdir_env not in processed_gitdir_envs %}
{%- do processed_gitdir_envs.append(gitdir_env) %} {%- do processed_gitdir_envs.append(gitdir_env) %}
{%- set options = formulas_opts_for_git_latest(env)|load_yaml %} {%- set options = formulas_opts_for_git_latest(env)|load_yaml %}
{%- do options.update(f_opts) %}
{%- set baseurl = formulas_git_opt(env, 'baseurl')|load_yaml %} {%- set baseurl = formulas_git_opt(env, 'baseurl')|load_yaml %}


{{ gitdir_env }}: {{ gitdir_env }}:
git.latest: git.latest:
- name: {{ baseurl }}/{{ entry }}.git
- name: {{ baseurl }}/{{ f_name }}.git
- target: {{ gitdir }} - target: {{ gitdir }}
{%- for key, value in options.items() %} {%- for key, value in options.items() %}
- {{ key }}: {{ value }} - {{ key }}: {{ value }}

Loading…
Cancel
Save