Init
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
commit
f1a4b0514c
22
bin/prepare_minion.py
Executable file
22
bin/prepare_minion.py
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import roles
|
||||||
|
import os
|
||||||
|
import yaml
|
||||||
|
import socket
|
||||||
|
|
||||||
|
roles = roles.get()
|
||||||
|
grainsfile = '/etc/salt/grains'
|
||||||
|
idfile = 'pillar/id/' + socket.gethostname() + '.sls'
|
||||||
|
mypwd = os.getcwd()
|
||||||
|
|
||||||
|
grainsdata = {'roles': roles}
|
||||||
|
|
||||||
|
with open(grainsfile, mode='w') as grainsfh:
|
||||||
|
yaml.dump(grainsdata, grainsfh)
|
||||||
|
|
||||||
|
with open(idfile, mode='w') as idfh:
|
||||||
|
idfh.write('# empty')
|
||||||
|
|
||||||
|
os.symlink(mypwd + '/salt', '/srv/salt')
|
||||||
|
os.symlink(mypwd + '/pillar', '/srv/pillar')
|
13
bin/prepare_mock.py
Executable file
13
bin/prepare_mock.py
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import socket
|
||||||
|
|
||||||
|
iddir = 'pillar/id/'
|
||||||
|
secretiddir = 'pillar/secret/id/'
|
||||||
|
baseidfile = 'atvkdev02_home_lysergic_dev.sls'
|
||||||
|
myidfile = socket.gethostname() + '.sls'
|
||||||
|
|
||||||
|
shutil.copyfile(iddir + baseidfile, iddir + myidfile)
|
||||||
|
shutil.copyfile(secretiddir + baseidfile, secretiddir + myidfile)
|
13
bin/roles.py
Executable file
13
bin/roles.py
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
roles = []
|
||||||
|
excluded = ['common-suse', 'minion']
|
||||||
|
|
||||||
|
def get():
|
||||||
|
for file in os.listdir('salt/role'):
|
||||||
|
role = os.path.splitext(file)[0]
|
||||||
|
if not role in excluded:
|
||||||
|
roles.append(role)
|
||||||
|
return roles
|
11
salt/top.sls
Normal file
11
salt/top.sls
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% set client_id = salt['grains.get']('id') %}
|
||||||
|
{% set roles = salt['grains.get']('roles', []) %}
|
||||||
|
|
||||||
|
{{ saltenv }}:
|
||||||
|
'*':
|
||||||
|
- baseline
|
||||||
|
{% for role in roles %}
|
||||||
|
'roles:{{ role }}':
|
||||||
|
- match: grain
|
||||||
|
- role.{{ role }}
|
||||||
|
{% endfor %}
|
Loading…
Reference in New Issue
Block a user