Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable passing test=False as kwarg from orchestration file to minion in permanent test mode #47427

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions doc/topics/releases/fluorine.rst
Expand Up @@ -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.
11 changes: 7 additions & 4 deletions salt/states/saltmod.py
Expand Up @@ -116,7 +116,7 @@ def state(name,
sls=None,
top=None,
saltenv=None,
test=False,
test=None,
pillar=None,
pillarenv=None,
expect_minions=True,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down