From 442806ab9e7d8f28bb93f8b5c3c2f509b1ce1760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 22 May 2017 19:20:36 -0300 Subject: [PATCH 1/4] Allow to specify different reactors for minions and masters --- pillar.example | 22 +++++++++++++++++++--- salt/files/master.d/reactor.conf | 4 ++++ salt/files/minion.d/reactor.conf | 4 ++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pillar.example b/pillar.example index 721bd3b..0cbf45e 100644 --- a/pillar.example +++ b/pillar.example @@ -95,6 +95,13 @@ salt: type: runner cmd: jobs.list_jobs + # optional: these reactors will be configured on the master + # They override reactors configured in + # 'salt:reactors' or the old 'salt:reactor' parameters + reactors: + - 'master/deploy': + - /srv/salt/reactors/deploy.sls + # salt minion config: minion: @@ -171,6 +178,12 @@ salt: - 1.0 interval: 10 + # Optional reactors: these reactors will be configured on the minion + # They override reactors configured in + # 'salt:reactors' or the old 'salt:reactor' parameters + reactors: + - 'master/deploy': + - /srv/salt/reactors/deploy.sls # salt cloud config cloud: @@ -229,9 +242,7 @@ salt: - IAD - SYD - HKG - reactor: - - 'deploy': - - /srv/salt/reactors/deploy.sls + ssh_roster: prod1: host: host.example.com @@ -249,6 +260,11 @@ salt: pub: | ........... + # These reactors will be configured both to the minion and the master + reactors: + - 'deploy': + - /srv/salt/reactors/deploy.sls + salt_cloud_certs: aws: pem: | diff --git a/salt/files/master.d/reactor.conf b/salt/files/master.d/reactor.conf index dd7fbb5..881a82c 100644 --- a/salt/files/master.d/reactor.conf +++ b/salt/files/master.d/reactor.conf @@ -1,7 +1,11 @@ # # This file is managed by Salt! Do not edit by hand! # +{# The parameter reactor is kept for backward compatibility -#} {%- set reactors = salt['pillar.get']('salt:reactor') -%} +{%- set reactors = salt['pillar.get']('salt:reactors', default=reactors, merge=True) -%} +{%- set reactors = salt['pillar.get']('salt:master:reactors', default=reactors, merge=True) -%} + {%- if reactors %} reactor: {%- for reactor in reactors %} diff --git a/salt/files/minion.d/reactor.conf b/salt/files/minion.d/reactor.conf index dd7fbb5..4022fdc 100644 --- a/salt/files/minion.d/reactor.conf +++ b/salt/files/minion.d/reactor.conf @@ -1,7 +1,11 @@ # # This file is managed by Salt! Do not edit by hand! # +{# The parameter reactor is kept for backward compatibility -#} {%- set reactors = salt['pillar.get']('salt:reactor') -%} +{%- set reactors = salt['pillar.get']('salt:reactors', default=reactors, merge=True) -%} +{%- set reactors = salt['pillar.get']('salt:minion:reactors', default=reactors, merge=True) -%} + {%- if reactors %} reactor: {%- for reactor in reactors %} From 561eb4c5c8deb149076ae16468320ea7c2ad0dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 22 May 2017 19:34:31 -0300 Subject: [PATCH 2/4] Reactors should be in an array --- salt/files/master.d/reactor.conf | 2 +- salt/files/minion.d/reactor.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/files/master.d/reactor.conf b/salt/files/master.d/reactor.conf index 881a82c..9c8a4b7 100644 --- a/salt/files/master.d/reactor.conf +++ b/salt/files/master.d/reactor.conf @@ -2,7 +2,7 @@ # This file is managed by Salt! Do not edit by hand! # {# The parameter reactor is kept for backward compatibility -#} -{%- set reactors = salt['pillar.get']('salt:reactor') -%} +{%- set reactors = salt['pillar.get']('salt:reactor', []) -%} {%- set reactors = salt['pillar.get']('salt:reactors', default=reactors, merge=True) -%} {%- set reactors = salt['pillar.get']('salt:master:reactors', default=reactors, merge=True) -%} diff --git a/salt/files/minion.d/reactor.conf b/salt/files/minion.d/reactor.conf index 4022fdc..d0f0a39 100644 --- a/salt/files/minion.d/reactor.conf +++ b/salt/files/minion.d/reactor.conf @@ -2,7 +2,7 @@ # This file is managed by Salt! Do not edit by hand! # {# The parameter reactor is kept for backward compatibility -#} -{%- set reactors = salt['pillar.get']('salt:reactor') -%} +{%- set reactors = salt['pillar.get']('salt:reactor', []) -%} {%- set reactors = salt['pillar.get']('salt:reactors', default=reactors, merge=True) -%} {%- set reactors = salt['pillar.get']('salt:minion:reactors', default=reactors, merge=True) -%} From 3a1e7ad9f978eef7684554b326f4bd550186844c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 22 May 2017 20:52:48 -0300 Subject: [PATCH 3/4] Fix reactor examples --- pillar.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pillar.example b/pillar.example index 0cbf45e..c74a963 100644 --- a/pillar.example +++ b/pillar.example @@ -182,7 +182,7 @@ salt: # They override reactors configured in # 'salt:reactors' or the old 'salt:reactor' parameters reactors: - - 'master/deploy': + - 'minion/deploy': - /srv/salt/reactors/deploy.sls # salt cloud config @@ -260,7 +260,7 @@ salt: pub: | ........... - # These reactors will be configured both to the minion and the master + # These reactors will be configured both in the minion and the master reactors: - 'deploy': - /srv/salt/reactors/deploy.sls From 93319972697e0936b0689182273aff0b570d0374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 22 May 2017 20:56:13 -0300 Subject: [PATCH 4/4] Exclude reactors from f_defaults.conf --- salt/files/master.d/f_defaults.conf | 2 +- salt/files/minion.d/f_defaults.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/files/master.d/f_defaults.conf b/salt/files/master.d/f_defaults.conf index 6e7cebe..bc2d162 100644 --- a/salt/files/master.d/f_defaults.conf +++ b/salt/files/master.d/f_defaults.conf @@ -1,6 +1,6 @@ # This file managed by Salt, do not edit by hand!! # Based on salt version 2016.11 default config -{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs', 'engines', 'lxc.network_profile', 'lxc.container_profile'] -%} +{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs', 'engines', 'lxc.network_profile', 'lxc.container_profile', 'reactors'] -%} {% set cfg_salt = pillar.get('salt', {}) -%} {% set cfg_master = cfg_salt.get('master', {}) -%} {% set default_keys = [] -%} diff --git a/salt/files/minion.d/f_defaults.conf b/salt/files/minion.d/f_defaults.conf index a14b9ac..c7e59f9 100644 --- a/salt/files/minion.d/f_defaults.conf +++ b/salt/files/minion.d/f_defaults.conf @@ -1,7 +1,7 @@ # This file managed by Salt, do not edit by hand!! # Based on salt version 2016.11 default config # -{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs', 'engines', 'beacons'] -%} +{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs', 'engines', 'beacons', 'reactors'] -%} {% set cfg_salt = pillar.get('salt', {}) -%} {% set cfg_minion = cfg_salt.get('minion', {}) -%} {% set default_keys = [] -%}