Compare commits
3 Commits
b435117808
...
f949c0aba0
Author | SHA1 | Date | |
---|---|---|---|
f949c0aba0 | |||
56a1e11ef6 | |||
d627582075 |
@ -5,13 +5,17 @@ import roles
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import socket
|
import socket
|
||||||
|
import yaml
|
||||||
|
|
||||||
roles = roles.get()
|
roles = roles.get()
|
||||||
grainsfile = '/etc/salt/grains'
|
grainsfile = '/etc/salt/grains'
|
||||||
idfile = 'pillar/id/' + socket.gethostname() + '.sls'
|
idfile = os.path.join('pillar/id/', socket.gethostname() + '.sls')
|
||||||
configfile = '/etc/salt/minion.d/local.conf'
|
configfile = '/etc/salt/minion.d/local.conf'
|
||||||
mypwd = os.getcwd()
|
mypwd = os.getcwd()
|
||||||
|
formulasfile = 'formulas.yaml'
|
||||||
|
formulasdir = '/srv/formulas'
|
||||||
|
|
||||||
|
configdata = {'file_roots': {'production': ['/srv/salt']}}
|
||||||
grainsdata = {'roles': roles}
|
grainsdata = {'roles': roles}
|
||||||
|
|
||||||
with open(grainsfile, mode='w') as grainsfh:
|
with open(grainsfile, mode='w') as grainsfh:
|
||||||
@ -20,16 +24,16 @@ with open(grainsfile, mode='w') as grainsfh:
|
|||||||
with open(idfile, mode='w') as idfh:
|
with open(idfile, mode='w') as idfh:
|
||||||
idfh.write('# empty')
|
idfh.write('# empty')
|
||||||
|
|
||||||
# to-do: include formulas automatically, maybe from some YAML file?
|
with open(formulasfile, mode='r') as formulasfh:
|
||||||
|
formulas = yaml.load(formulasfh, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
for formula in formulas:
|
||||||
|
formula = os.path.join('/srv/formulas/', formula + '-formula')
|
||||||
|
configdata['file_roots']['production'].append(formula)
|
||||||
|
|
||||||
with open(configfile, mode='w') as configfh:
|
with open(configfile, mode='w') as configfh:
|
||||||
configfh.write('''# written by prepare_minion.py
|
configfh.write('# written by prepare_minion.py\n')
|
||||||
file_roots:
|
yaml.dump(configdata, configfh)
|
||||||
production:
|
|
||||||
- /srv/salt
|
|
||||||
- /srv/formulas/salt-formula
|
|
||||||
- /srv/formulas/users-formula
|
|
||||||
- /srv/formulas/postfix-formula
|
|
||||||
''')
|
|
||||||
|
|
||||||
os.symlink(mypwd + '/salt', '/srv/salt')
|
os.symlink(mypwd + '/salt', '/srv/salt')
|
||||||
os.symlink(mypwd + '/pillar', '/srv/pillar')
|
os.symlink(mypwd + '/pillar', '/srv/pillar')
|
||||||
|
1
formulas.yaml
Symbolic link
1
formulas.yaml
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
pillar/formulas.yaml
|
3
pillar/formulas.yaml
Normal file
3
pillar/formulas.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- postfix
|
||||||
|
- salt
|
||||||
|
- users
|
@ -1,7 +1,7 @@
|
|||||||
include:
|
include:
|
||||||
- role.salt.common
|
- role.salt.common
|
||||||
- role.salt.minion
|
- role.salt.minion
|
||||||
- role.mta.postfix
|
- .mta
|
||||||
|
|
||||||
managed_header_pound: |
|
managed_header_pound: |
|
||||||
### This file is managed via https://git.com.de/LibertaCasa/salt
|
### This file is managed via https://git.com.de/LibertaCasa/salt
|
@ -1,4 +1,4 @@
|
|||||||
{%- set formulas = ['salt', 'users', 'postfix'] -%}
|
{%- import_yaml 'formulas.yaml' as formulas -%}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- role.salt.common
|
- role.salt.common
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{{ saltenv }}:
|
{{ saltenv }}:
|
||||||
'*':
|
'*':
|
||||||
- common
|
- global
|
||||||
'id:{{ id }}':
|
'id:{{ id }}':
|
||||||
- match: grain
|
- match: grain
|
||||||
- ignore_missing: True
|
- ignore_missing: True
|
||||||
|
@ -3,7 +3,8 @@ include:
|
|||||||
- profile.zypp
|
- profile.zypp
|
||||||
- profile.node_exporter
|
- profile.node_exporter
|
||||||
- users
|
- users
|
||||||
- role.mta.postfix
|
- postfix
|
||||||
|
- postfix.config
|
||||||
|
|
||||||
{#- to-do: move this to some formula or macro -#}
|
{#- to-do: move this to some formula or macro -#}
|
||||||
{%- set osfullname = grains['osfullname'] -%}
|
{%- set osfullname = grains['osfullname'] -%}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
include:
|
|
||||||
- postfix
|
|
||||||
- postfix.config
|
|
Loading…
x
Reference in New Issue
Block a user