From c9a4382e02848cd65b22837b3cb333967b08b529 Mon Sep 17 00:00:00 2001 From: Tanoti Date: Wed, 2 May 2018 09:09:35 +0000 Subject: [PATCH 1/2] Enable passing test=False as kwarg from orchestration file to minion in permanent test mode --- doc/topics/releases/fluorine.rst | 19 +++++++++++++++++++ salt/states/saltmod.py | 11 +++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/topics/releases/fluorine.rst b/doc/topics/releases/fluorine.rst index 9b73d0cfc61b..220a1bb52b3b 100644 --- a/doc/topics/releases/fluorine.rst +++ b/doc/topics/releases/fluorine.rst @@ -470,3 +470,22 @@ It is also possible to use several alternative versions of Salt. You can for ins a minimal tarball using runners and include that. But this is only possible, when such specific Salt version is also available on the Master machine, although does not need to be directly installed together with the older Python interpreter. + +======= +State Module Changes +==================== + +states.saltmod +-------------- +The 'test' option now defaults to None. A value of True or False set here is +passed to the state being run and can be used to override a ``test:True`` option +set in the minion's config file. In previous releases the minion's config option +would take precedence and it would be impossible to run an orchestration on a +minion with test mode set to True in the config file. + +If a minion is not in permanent test mode due to the config file and the 'test' +argument here is left as None then a value of ``test=True`` on the command-line is +passed correctly to the minion to run an orchestration in test mode. At present +it is not possible to pass ``test=False`` on the command-line to override a +minion in permanent test mode and so the ``test:False`` option must still be set +in the orchestration file. diff --git a/salt/states/saltmod.py b/salt/states/saltmod.py index c51e62710f44..edf944962354 100644 --- a/salt/states/saltmod.py +++ b/salt/states/saltmod.py @@ -116,7 +116,7 @@ def state(name, sls=None, top=None, saltenv=None, - test=False, + test=None, pillar=None, pillarenv=None, expect_minions=True, @@ -169,7 +169,10 @@ def state(name, containing a single sls file, or a list of sls files test - Pass ``test=true`` through to the state function + Pass ``test=true`` or ``test=false`` through to the state function. This + can be used to overide a test mode set in the minion's config file. If + left as the default of None and the 'test' mode is supplied on the + command line, that value is passed instead. pillar Pass the ``pillar`` kwarg through to the state function @@ -283,8 +286,8 @@ def state(name, state_ret['result'] = False return state_ret - if test or __opts__.get('test'): - cmd_kw['kwarg']['test'] = True + if test is not None or __opts__.get('test'): + cmd_kw['kwarg']['test'] = test if test is not None else __opts__.get('test') if pillar: cmd_kw['kwarg']['pillar'] = pillar From 11b616fd62edf6d5d2c01c75c7c535ad3e29c650 Mon Sep 17 00:00:00 2001 From: Nicole Thomas Date: Wed, 2 May 2018 09:18:05 -0400 Subject: [PATCH 2/2] whitespace fix --- salt/states/saltmod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/saltmod.py b/salt/states/saltmod.py index edf944962354..96ad35586fca 100644 --- a/salt/states/saltmod.py +++ b/salt/states/saltmod.py @@ -170,7 +170,7 @@ def state(name, test Pass ``test=true`` or ``test=false`` through to the state function. This - can be used to overide a test mode set in the minion's config file. If + can be used to overide a test mode set in the minion's config file. If left as the default of None and the 'test' mode is supplied on the command line, that value is passed instead.