iterate order; common; salt configs
This commit is contained in:
8
common/init.sls
Normal file
8
common/init.sls
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{% from "common/map.jinja" import common with context %}
|
||||||
|
|
||||||
|
'base_packages':
|
||||||
|
pkg.installed:
|
||||||
|
- pkgs:
|
||||||
|
{% for package in common['packages'] %}
|
||||||
|
- {{ package|yaml_encode }}
|
||||||
|
{% endfor %}
|
||||||
25
common/map.jinja
Normal file
25
common/map.jinja
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
{% set common = salt['grains.filter_by']({
|
||||||
|
'Debian': {
|
||||||
|
'packages': [
|
||||||
|
'vim'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'RedHat': {
|
||||||
|
'packages': [
|
||||||
|
'vim-enhanced'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}) %}
|
||||||
|
|
||||||
|
{% set defaults = {
|
||||||
|
'packages': [
|
||||||
|
'iftop'
|
||||||
|
]
|
||||||
|
} %}
|
||||||
|
|
||||||
|
{# deep merge #}
|
||||||
|
{% for key in defaults.keys() %}
|
||||||
|
{% do common[key].extend(defaults[key]) %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
6
salt/files/master.jinja
Normal file
6
salt/files/master.jinja
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
cli_summary: True
|
||||||
|
minion_data_cache: True
|
||||||
|
state_output: changes
|
||||||
|
top_file_merging_strategy: same
|
||||||
|
pillar_merge_lists: True
|
||||||
|
log_level: warning
|
||||||
5
salt/files/minion.jinja
Normal file
5
salt/files/minion.jinja
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
master: kpi.keiran.us
|
||||||
|
pillar_raise_on_missing: True
|
||||||
|
state_output: changes
|
||||||
|
log_level: warning
|
||||||
|
mysql.default_file: '/root/.my.cnf'
|
||||||
0
salt/init.sls
Normal file
0
salt/init.sls
Normal file
9
salt/master.sls
Normal file
9
salt/master.sls
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
/etc/salt/master:
|
||||||
|
file.managed:
|
||||||
|
- source: 'salt://salt/files/master.jinja'
|
||||||
|
- template: jinja
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
|
||||||
9
salt/minion.sls
Normal file
9
salt/minion.sls
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
/etc/salt/minion:
|
||||||
|
file.managed:
|
||||||
|
- source: 'salt://salt/files/minion.jinja'
|
||||||
|
- template: jinja
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
# Managed by Salt
|
# Managed by Salt
|
||||||
{% for comment, keydata in pillar['authorized_keys'].items() -%}
|
{% set comments = pillar['authorized_keys'].keys()|sort -%}
|
||||||
|
{% for comment in comments -%}
|
||||||
|
{% set keydata = pillar['authorized_keys'][comment] -%}
|
||||||
{{keydata}} {{comment}}
|
{{keydata}} {{comment}}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
# Managed by salt
|
# Managed by salt
|
||||||
{% for host, config in pillar['ssh_config'].items() -%}
|
{% set hosts = pillar['ssh_config'].keys()|sort -%}
|
||||||
|
{% for host in hosts -%}
|
||||||
|
{% set config = pillar['ssh_config'][host] %}
|
||||||
Host {{host}}
|
Host {{host}}
|
||||||
{%- for key, val in config.items() %}
|
{%- set keys = config.keys()|sort %}
|
||||||
|
{%- for key in keys %}
|
||||||
|
{%- set val = config[key] %}
|
||||||
{{key}} {{val -}}
|
{{key}} {{val -}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
|
|||||||
Reference in New Issue
Block a user