summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKim Hagen <kim.sidney@gmail.com>2018-07-03 11:54:21 +0200
committerKim Hagen <kim.sidney@gmail.com>2018-07-03 11:54:21 +0200
commit615dd2052ce194618cd6fbc0aabb3ad68687e7c3 (patch)
treeb90d4cbf83dc70112495a73762048492a1af9978 /src
parent00d501404064ee548e96d67da70f17f08876a850 (diff)
parent01dbed6d792750550cbd961ba8b2794e4b98e294 (diff)
downloadvyos-salt-minion-615dd2052ce194618cd6fbc0aabb3ad68687e7c3.tar.gz
vyos-salt-minion-615dd2052ce194618cd6fbc0aabb3ad68687e7c3.zip
Merge branch 'master' of github.com:UnicronNL/vyos-salt-minion
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/salt-minion.py32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/conf_mode/salt-minion.py b/src/conf_mode/salt-minion.py
index 4edb7a0..621159b 100755
--- a/src/conf_mode/salt-minion.py
+++ b/src/conf_mode/salt-minion.py
@@ -18,6 +18,7 @@
import sys
import os
+import pwd
import socket
import jinja2
@@ -37,7 +38,9 @@ config_tmpl = """
# Set the location of the salt master server, if the master server cannot be
# resolved, then the minion will fail to start.
-master: {{ master }}
+{% for host in master -%}
+master: {{ host }}
+{% endfor %}
# The user to run salt
user: {{ user }}
@@ -50,13 +53,17 @@ pki_dir: /config/salt/pki/minion
# Since salt uses detached ids it is possible to run multiple minions on the
# same machine but with different ids, this can be useful for salt compute
# clusters.
-id: {{ id }}
+id: {{ salt_id }}
+
+mine_enabled: True
+mine_return_job: False
+mine_interval: 60
"""
default_config_data = {
'master' : 'salt',
'user': 'vyos',
- 'id': socket.gethostname()
+ 'salt_id': socket.gethostname()
}
def get_config():
@@ -72,17 +79,18 @@ def get_config():
salt['master'] = master
if conf.exists('ID'):
- id = conf.return_values('ID')
- salt['id'] = id
+ salt['salt_id'] = conf.return_value('ID')
if conf.exists('user'):
- user = conf.return_values('user')
- salt['user'] = user
+ salt['user'] = conf.return_value('user')
return salt
def generate(salt):
- directory = '/config/salt/pki/minion'
+ paths = ['/etc/salt/','/var/run/salt','/opt/vyatta/etc/config/salt/']
+ directory = '/opt/vyatta/etc/config/salt/pki/minion'
+ uid = pwd.getpwnam(salt['user']).pw_uid
+
if salt is None:
return None
@@ -93,6 +101,13 @@ def generate(salt):
config_text = tmpl.render(salt)
with open(config_file, 'w') as f:
f.write(config_text)
+ path = "/etc/salt/"
+ for path in paths:
+ for root, dirs, files in os.walk(path):
+ for usgr in dirs:
+ os.chown(os.path.join(root, usgr), uid, 100)
+ for usgr in files:
+ os.chown(os.path.join(root, usgr), uid, 100)
return None
def apply(salt):
@@ -108,7 +123,6 @@ def apply(salt):
if __name__ == '__main__':
try:
c = get_config()
- verify(c)
generate(c)
apply(c)
except ConfigError as e: