From ad39362fb0e5c31741ae7f0f2d8bd44428c381ef Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Apr 2020 10:27:57 +0200 Subject: salt: T2382: XML: add proper valueHelp and validators for master --- interface-definitions/salt-minion.xml.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'interface-definitions/salt-minion.xml.in') diff --git a/interface-definitions/salt-minion.xml.in b/interface-definitions/salt-minion.xml.in index 9aa60249a..02501c5e8 100644 --- a/interface-definitions/salt-minion.xml.in +++ b/interface-definitions/salt-minion.xml.in @@ -55,6 +55,19 @@ The hostname or IP address of the master. + + ipv4 + Remote syslog server IPv4 address + + + hostname + Remote syslog server FQDN + + + + + + Invalid FQDN or IP address -- cgit v1.2.3 From 52817fc97de3e5a5af4a43f2a2acfe05509f6258 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Apr 2020 11:11:32 +0200 Subject: salt: T2384: always log to syslog --- data/templates/salt-minion/minion.tmpl | 6 +---- interface-definitions/salt-minion.xml.in | 39 -------------------------------- src/conf_mode/salt-minion.py | 8 +------ 3 files changed, 2 insertions(+), 51 deletions(-) (limited to 'interface-definitions/salt-minion.xml.in') diff --git a/data/templates/salt-minion/minion.tmpl b/data/templates/salt-minion/minion.tmpl index 5e50d588c..0b97c0524 100644 --- a/data/templates/salt-minion/minion.tmpl +++ b/data/templates/salt-minion/minion.tmpl @@ -21,11 +21,7 @@ hash_type: {{ hash_type }} # location. Remote logging works best when configured to use rsyslogd(8) (e.g.: # ``file:///dev/log``), with rsyslogd(8) configured for network logging. The URI # format is: ://:/ -#log_file: /var/log/salt/minion -#log_file: file:///dev/log -#log_file: udp://loghost:10514 -# -log_file: {{ log_file }} +log_file: file:///dev/log # The level of messages to send to the console. # One of 'garbage', 'trace', 'debug', info', 'warning', 'error', 'critical'. diff --git a/interface-definitions/salt-minion.xml.in b/interface-definitions/salt-minion.xml.in index 02501c5e8..f62465a64 100644 --- a/interface-definitions/salt-minion.xml.in +++ b/interface-definitions/salt-minion.xml.in @@ -1,5 +1,4 @@ - @@ -14,44 +13,6 @@ The hash_type is the hash to use when discovering the hash of a file on the master server. - - - The location of the minion log file. - - - - - Log level - - garbage - log garbage info - - - trace - log trace info - - - debug - log debug info - - - info - log info - - - warning - log warning info - - - error - log error info - - - critical - log critical info - - - The hostname or IP address of the master. diff --git a/src/conf_mode/salt-minion.py b/src/conf_mode/salt-minion.py index a460c95b3..d3412b7ef 100755 --- a/src/conf_mode/salt-minion.py +++ b/src/conf_mode/salt-minion.py @@ -31,7 +31,6 @@ master_keyfile = r'/opt/vyatta/etc/config/salt/pki/minion/master_sign.pub' default_config_data = { 'hash_type': 'sha256', - 'log_file': '/var/log/salt/minion', 'log_level': 'warning', 'master' : 'salt', 'user': 'nobody', @@ -55,12 +54,6 @@ def get_config(): if conf.exists(['hash_type']): salt['hash_type'] = conf.return_value(['hash_type']) - if conf.exists(['log_file']): - salt['log_file'] = conf.return_value(['log_file']) - - if conf.exists(['log_level']): - salt['log_level'] = conf.return_value(['log_level']) - if conf.exists(['master']): salt['master'] = conf.return_values(['master']) @@ -90,6 +83,7 @@ def generate(salt): dirname = os.path.dirname(file) if not os.path.exists(dirname): os.mkdir(dirname) + chown(dirname, salt['user'], salt['group']) render(config_file, 'salt-minion/minion.tmpl', salt) chown(config_file, salt['user'], salt['group']) -- cgit v1.2.3 From bdda118c4573ba6e42376f9391d4ab16e73eb4bd Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Apr 2020 11:24:24 +0200 Subject: salt: T2385: XML: improve completion helpers on hash_type --- interface-definitions/salt-minion.xml.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'interface-definitions/salt-minion.xml.in') diff --git a/interface-definitions/salt-minion.xml.in b/interface-definitions/salt-minion.xml.in index f62465a64..1c1dee2fb 100644 --- a/interface-definitions/salt-minion.xml.in +++ b/interface-definitions/salt-minion.xml.in @@ -10,7 +10,13 @@ - The hash_type is the hash to use when discovering the hash of a file on the master server. + Hash used when discovering file on master server (default: sha256) + + md5 sha1 sha224 sha256 sha384 sha512 + + + (md5|sha1|sha224|sha256|sha384|sha512) + -- cgit v1.2.3 From 6a3938cbf595ea24d2d2e3802cf78a0519483339 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 26 Apr 2020 11:31:16 +0200 Subject: salt: T2384: migrate config options - delete log_file, log_level and user nodes - rename hash_type to hash - rename mine_interval to interval --- data/templates/salt-minion/minion.tmpl | 4 +-- interface-definitions/salt-minion.xml.in | 9 ++--- src/conf_mode/salt-minion.py | 10 +++--- src/migration-scripts/salt/0-to-1 | 58 ++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 14 deletions(-) create mode 100755 src/migration-scripts/salt/0-to-1 (limited to 'interface-definitions/salt-minion.xml.in') diff --git a/data/templates/salt-minion/minion.tmpl b/data/templates/salt-minion/minion.tmpl index 0b97c0524..9369573a4 100644 --- a/data/templates/salt-minion/minion.tmpl +++ b/data/templates/salt-minion/minion.tmpl @@ -12,7 +12,7 @@ # # Prior to changing this value, the master should be stopped and all Salt # caches should be cleared. -hash_type: {{ hash_type }} +hash_type: {{ hash }} ##### Logging settings ##### ########################################## @@ -54,6 +54,6 @@ id: {{ salt_id }} # The number of minutes between mine updates. -mine_interval: {{ mine_interval }} +mine_interval: {{ interval }} verify_master_pubkey_sign: {{ verify_master_pubkey_sign }} diff --git a/interface-definitions/salt-minion.xml.in b/interface-definitions/salt-minion.xml.in index 1c1dee2fb..d0e8e3e2b 100644 --- a/interface-definitions/salt-minion.xml.in +++ b/interface-definitions/salt-minion.xml.in @@ -8,7 +8,7 @@ 500 - + Hash used when discovering file on master server (default: sha256) @@ -43,12 +43,7 @@ Explicitly declare the id for this minion to use. - - - The user to run the Salt processes. - - - + The number of minutes between mine updates. diff --git a/src/conf_mode/salt-minion.py b/src/conf_mode/salt-minion.py index d3412b7ef..515019014 100755 --- a/src/conf_mode/salt-minion.py +++ b/src/conf_mode/salt-minion.py @@ -30,7 +30,7 @@ config_file = r'/etc/salt/minion' master_keyfile = r'/opt/vyatta/etc/config/salt/pki/minion/master_sign.pub' default_config_data = { - 'hash_type': 'sha256', + 'hash': 'sha256', 'log_level': 'warning', 'master' : 'salt', 'user': 'nobody', @@ -51,8 +51,8 @@ def get_config(): else: conf.set_level(base) - if conf.exists(['hash_type']): - salt['hash_type'] = conf.return_value(['hash_type']) + if conf.exists(['hash']): + salt['hash'] = conf.return_value(['hash']) if conf.exists(['master']): salt['master'] = conf.return_values(['master']) @@ -63,8 +63,8 @@ def get_config(): if conf.exists(['user']): salt['user'] = conf.return_value(['user']) - if conf.exists(['mine_interval']): - salt['mine_interval'] = conf.return_value(['mine_interval']) + if conf.exists(['interval']): + salt['interval'] = conf.return_value(['interval']) if conf.exists(['master-key']): salt['master_key'] = conf.return_value(['master-key']) diff --git a/src/migration-scripts/salt/0-to-1 b/src/migration-scripts/salt/0-to-1 new file mode 100755 index 000000000..79053c056 --- /dev/null +++ b/src/migration-scripts/salt/0-to-1 @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Delete log_file, log_level and user nodes +# rename hash_type to hash +# rename mine_interval to interval + +from sys import argv,exit + +from vyos.configtree import ConfigTree + +if (len(argv) < 1): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +config = ConfigTree(config_file) + +base = ['service', 'salt-minion'] +if not config.exists(base): + # Nothing to do + exit(0) +else: + + # delete nodes which are now populated with sane defaults + for node in ['log_file', 'log_level', 'user']: + if config.exists(base + [node]): + config.delete(base + [node]) + + if config.exists(base + ['hash_type']): + config.rename(base + ['hash_type'], 'hash') + + if config.exists(base + ['mine_interval']): + config.rename(base + ['mine_interval'], 'interval') + + try: + with open(file_name, 'w') as f: + f.write(config.to_string()) + except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) -- cgit v1.2.3