Compare commits
1 commit
db1b940729
...
a6ded2eb42
Author | SHA1 | Date | |
---|---|---|---|
|
a6ded2eb42 |
8 changed files with 49 additions and 38 deletions
|
@ -1,17 +1,18 @@
|
||||||
|
{%- set branches=salt.cmd.shell('git ls-remote https://git.actcur.com/actcur/salt.git | grep -o -P "(?<=refs/heads/).*" | grep -Pv "(^temp$)|(^history$)"').split('\n') -%}
|
||||||
|
branches:
|
||||||
|
saltmaster:
|
||||||
|
{%- for branch in branches %}
|
||||||
|
- {{branch}}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
git:
|
git:
|
||||||
salt:
|
{%- for branch in branches %}
|
||||||
|
salt_{{branch}}:
|
||||||
repo: "ssh://gitea@git.actcur.com:5022/actcur/salt.git"
|
repo: "ssh://gitea@git.actcur.com:5022/actcur/salt.git"
|
||||||
path: "/srv/salt/prod"
|
path: "/srv/salt/{{branch}}"
|
||||||
branch: "master"
|
branch: "{{branch}}"
|
||||||
key: "git_actcur"
|
key: "git_actcur"
|
||||||
force: true
|
force: {{ "True" if (branch == "prod" or branch == "qual") else "false" }}
|
||||||
email: "actcur@actcur.com"
|
|
||||||
name: "Actaeus Curabitur"
|
|
||||||
salt_dev:
|
|
||||||
repo: "ssh://gitea@git.actcur.com:5022/actcur/salt.git"
|
|
||||||
path: "/srv/salt/dev"
|
|
||||||
branch: "dev"
|
|
||||||
key: "git_actcur"
|
|
||||||
force: true
|
|
||||||
email: "actcur@actcur.com"
|
email: "actcur@actcur.com"
|
||||||
name: "Actaeus Curabitur"
|
name: "Actaeus Curabitur"
|
||||||
|
{%- endfor %}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
prod:
|
{%- set envs=salt.cmd.shell('ls /srv/salt/').split('\n') -%}
|
||||||
'*':
|
{%- for env in envs %}
|
||||||
- roles
|
{{env}}:
|
||||||
- servers
|
|
||||||
dev:
|
|
||||||
'*':
|
'*':
|
||||||
- roles
|
- roles
|
||||||
- servers
|
- servers
|
||||||
|
{%- endfor %}
|
||||||
|
|
|
@ -3,17 +3,17 @@ git fetch --all;
|
||||||
|
|
||||||
#copy dev to history to ensure we don't lose changes if something goes wrong
|
#copy dev to history to ensure we don't lose changes if something goes wrong
|
||||||
git checkout history;
|
git checkout history;
|
||||||
git reset --hard dev;
|
git reset --hard qual;
|
||||||
git push --force;
|
git push --force;
|
||||||
|
|
||||||
#merge to master
|
#merge to master
|
||||||
git checkout -B master origin/master;
|
git checkout -B prod origin/master;
|
||||||
git merge --squash dev;
|
git merge --squash qual;
|
||||||
git commit -am "$cm";
|
git commit -am "$cm";
|
||||||
git push;
|
git push;
|
||||||
|
|
||||||
#clean dev
|
#clean dev
|
||||||
git checkout dev;
|
git checkout qual;
|
||||||
git reset --hard master;
|
git reset --hard prod;
|
||||||
git push --force;
|
git push --force;
|
||||||
git reset --hard origin/dev;
|
git reset --hard origin/qual;
|
|
@ -1,5 +1,4 @@
|
||||||
{%- set os=grains['os'] -%}
|
{%- set os=grains['os'] -%}
|
||||||
|
|
||||||
salt-master:
|
salt-master:
|
||||||
{%- if os=="CentOS" or os=="RedHat" %}
|
{%- if os=="CentOS" or os=="RedHat" %}
|
||||||
pkg.installed: []
|
pkg.installed: []
|
||||||
|
@ -19,6 +18,7 @@ salt-master:
|
||||||
- user: root
|
- user: root
|
||||||
- group: root
|
- group: root
|
||||||
- mode: 644
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
|
||||||
/srv/salt/prod/states/pillars:
|
/srv/salt/prod/states/pillars:
|
||||||
file.symlink:
|
file.symlink:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{%- set envs=salt.cmd.shell('ls /srv/salt/').split('\n') -%}
|
||||||
##### Primary configuration settings #####
|
##### Primary configuration settings #####
|
||||||
##########################################
|
##########################################
|
||||||
# This configuration file is used to manage the behavior of the Salt Master.
|
# This configuration file is used to manage the behavior of the Salt Master.
|
||||||
|
@ -422,12 +423,10 @@ state_output: terse
|
||||||
# - /srv/salt/prod/states
|
# - /srv/salt/prod/states
|
||||||
#
|
#
|
||||||
file_roots:
|
file_roots:
|
||||||
base:
|
{%- for env in envs %}
|
||||||
- /srv/salt/prod/states
|
{{env}}:
|
||||||
prod:
|
- /srv/salt/{{env}}/states
|
||||||
- /srv/salt/prod/states
|
{%- endfor %}
|
||||||
dev:
|
|
||||||
- /srv/salt/dev/states
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# When using multiple environments, each with their own top file, the
|
# When using multiple environments, each with their own top file, the
|
||||||
|
@ -439,7 +438,11 @@ file_roots:
|
||||||
# To specify the order in which environments are merged, set the ordering
|
# To specify the order in which environments are merged, set the ordering
|
||||||
# in the env_order option. Given a conflict, the last matching value will
|
# in the env_order option. Given a conflict, the last matching value will
|
||||||
# win.
|
# win.
|
||||||
env_order: ['base', 'dev', 'prod']
|
env_order: [
|
||||||
|
{%- for env in envs -%}
|
||||||
|
'{{env}}',
|
||||||
|
{%- endfor -%}
|
||||||
|
'null']
|
||||||
|
|
||||||
# If top_file_merging_strategy is set to 'same' and an environment does not
|
# If top_file_merging_strategy is set to 'same' and an environment does not
|
||||||
# contain a top file, the top file in the environment specified by default_top
|
# contain a top file, the top file in the environment specified by default_top
|
||||||
|
@ -560,12 +563,10 @@ hash_type: sha256
|
||||||
# - /srv/pillar
|
# - /srv/pillar
|
||||||
#
|
#
|
||||||
pillar_roots:
|
pillar_roots:
|
||||||
base:
|
{%- for env in envs %}
|
||||||
- /srv/salt/prod/pillars
|
{{env}}:
|
||||||
prod:
|
- /srv/salt/{{env}}/pillars
|
||||||
- /srv/salt/prod/pillars
|
{%- endfor %}
|
||||||
dev:
|
|
||||||
- /srv/salt/dev/pillars
|
|
||||||
#
|
#
|
||||||
#ext_pillar:
|
#ext_pillar:
|
||||||
# - hiera: /etc/hiera.yaml
|
# - hiera: /etc/hiera.yaml
|
||||||
|
|
5
states/test
Normal file
5
states/test
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{%- set envs=salt.cmd.shell('ls /srv/salt/').split('\n') -%}
|
||||||
|
{% for env in envs %}
|
||||||
|
{{ env }}:
|
||||||
|
'os_family:RedHat':
|
||||||
|
{% endfor %}
|
4
states/test.sls
Normal file
4
states/test.sls
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/test:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://test
|
||||||
|
- template: jinja
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
{%- set states = salt['cp.list_states'](saltenv) -%}
|
{%- set states = salt['cp.list_states'](saltenv) -%}
|
||||||
{%- set envs = ['prod','dev'] -%}
|
{%- set envs=salt.cmd.shell('git ls-remote https://git.actcur.com/actcur/salt.git | grep -o -P "(?<=refs/heads/).*" | grep -Pv "(^temp$)|(^history$)"').split('\n') -%}
|
||||||
|
{%- set envs=salt.cmd.shell('ls /srv/salt/').split('\n') -%}
|
||||||
{% for env in envs %}
|
{% for env in envs %}
|
||||||
{{ env }}:
|
{{ env }}:
|
||||||
'os_family:RedHat':
|
'os_family:RedHat':
|
||||||
|
|
Loading…
Add table
Reference in a new issue