summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Hagen <kim.sidney@gmail.com>2018-07-02 21:15:02 +0200
committerKim Hagen <kim.sidney@gmail.com>2018-07-02 21:15:02 +0200
commit05d5548bdebbe173fa44a29597f7baab631616f7 (patch)
treec49b471c90f09aab35294c6c48ab6d30db46cd47
parentc881147196e826a760836eaad7c9099d0879b485 (diff)
downloadvyos-salt-minion-05d5548bdebbe173fa44a29597f7baab631616f7.tar.gz
vyos-salt-minion-05d5548bdebbe173fa44a29597f7baab631616f7.zip
Update salt script
-rw-r--r--debian/vyos-salt-minion.postinst10
-rwxr-xr-xsrc/conf_mode/salt-minion.py28
2 files changed, 31 insertions, 7 deletions
diff --git a/debian/vyos-salt-minion.postinst b/debian/vyos-salt-minion.postinst
new file mode 100644
index 0000000..42e232c
--- /dev/null
+++ b/debian/vyos-salt-minion.postinst
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+if deb-systemd-helper --quiet was-enabled salt-minion.service; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable salt-minion.service >/dev/null || true
+fi
+
+if [ -x "/etc/init.d/salt-minion" ]; then
+ update-rc.d -f salt-minion remove >/dev/null
+fi
diff --git a/src/conf_mode/salt-minion.py b/src/conf_mode/salt-minion.py
index aa99ecc..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,17 @@ 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):
+ 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
@@ -94,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):