From d1cbec3fe25fbf62ec1015274bfab259a62cd149 Mon Sep 17 00:00:00 2001 From: Thomas Larsen Date: Mon, 8 Feb 2016 13:45:09 +0000 Subject: [PATCH 1/2] Added support for downloading formulas from multiple baseurls into the same environment. --- pillar.example | 12 +++++++----- salt/formulas.jinja | 4 +++- salt/formulas.sls | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pillar.example b/pillar.example index 614cc7d..f2511db 100644 --- a/pillar.example +++ b/pillar.example @@ -160,9 +160,11 @@ salt_formulas: # List of formulas to enable in each environment list: base: - - salt-formula - - postfix-formula + https://github.com/saltstack-formulas: + - salt-formula + - postfix-formula dev: - - salt-formula - - postfix-formula - - openssh-formula + https://github.com/saltstack-formulas + - salt-formula + - postfix-formula + - openssh-formula diff --git a/salt/formulas.jinja b/salt/formulas.jinja index 2a466a2..123c88c 100644 --- a/salt/formulas.jinja +++ b/salt/formulas.jinja @@ -16,10 +16,12 @@ {%- macro formulas_roots(env) -%} {%- set value = [] -%} -{%- for dir in formulas.get(env, []) -%} +{%- for repo,f_name in formulas.get(env, {}).items() -%} +{%- for dir in f_name -%} {%- set basedir = formulas_git_opt(env, 'basedir')|load_yaml -%} {%- do value.append('{0}/{1}'.format(basedir, dir)) -%} {%- endfor -%} +{%- endfor -%} {{ value|yaml }} {%- endmacro -%} diff --git a/salt/formulas.sls b/salt/formulas.sls index b433bb5..a58cc4f 100644 --- a/salt/formulas.sls +++ b/salt/formulas.sls @@ -4,7 +4,8 @@ {% from "salt/formulas.jinja" import formulas_git_opt with context %} # Loop over all formulas listed in pillar data -{% for env, entries in salt['pillar.get']('salt_formulas:list', {}).items() %} +{% for env, elements in salt['pillar.get']('salt_formulas:list', {}).items() %} +{% for baseurl, entries in elements.items() %} {% for entry in entries %} {% set basedir = formulas_git_opt(env, 'basedir')|load_yaml %} @@ -26,7 +27,6 @@ {% if gitdir not in processed_gitdirs %} {% do processed_gitdirs.append(gitdir) %} {% set options = formulas_git_opt(env, 'options')|load_yaml %} -{% set baseurl = formulas_git_opt(env, 'baseurl')|load_yaml %} {{ gitdir }}: git.latest: - name: {{ baseurl }}/{{ entry }}.git @@ -43,3 +43,4 @@ {% endfor %} {% endfor %} +{% endfor %} From bbeacc4ace14342f5bbd37c1230a4d72178d1b19 Mon Sep 17 00:00:00 2001 From: Thomas Larsen Date: Mon, 8 Feb 2016 14:01:47 +0000 Subject: [PATCH 2/2] Fixed typo in `pillar.example` --- pillar.example | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pillar.example b/pillar.example index f2511db..0198dff 100644 --- a/pillar.example +++ b/pillar.example @@ -135,9 +135,6 @@ salt_formulas: # environment, if an option is missing in a given environment, the # value from "default" is used instead. default: - # URL where the formulas git repositories are downloaded from - # it will be suffixed with .git - baseurl: https://github.com/saltstack-formulas # Directory where Git repositories are downloaded basedir: /srv/formulas # Update the git repository to the latest version (False by default) @@ -164,7 +161,7 @@ salt_formulas: - salt-formula - postfix-formula dev: - https://github.com/saltstack-formulas + https://github.com/saltstack-formulas: - salt-formula - postfix-formula - openssh-formula