mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Add test mode conditionals to the alternatives state
This commit is contained in:
parent
b26679c3aa
commit
948de0a2f6
@ -65,6 +65,12 @@ def install(name, link, path, priority):
|
||||
|
||||
isinstalled = __salt__['alternatives.check_installed'](name, path)
|
||||
if not isinstalled:
|
||||
if __opts__['test']:
|
||||
ret['comment'] = (
|
||||
'Alternative will be set for {0} to {1} with priority {2}'
|
||||
).format(name, path, priority)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
__salt__['alternatives.install'](name, link, path, priority)
|
||||
ret['comment'] = (
|
||||
'Setting alternative for {0} to {1} with priority {2}'
|
||||
@ -100,6 +106,11 @@ def remove(name, path):
|
||||
|
||||
isinstalled = __salt__['alternatives.check_installed'](name, path)
|
||||
if isinstalled:
|
||||
if __opts__['test']:
|
||||
ret['comment'] = ('Alternative for {0} will be removed'
|
||||
.format(name))
|
||||
ret['result'] = None
|
||||
return ret
|
||||
__salt__['alternatives.remove'](name, path)
|
||||
current = __salt__['alternatives.show_current'](name)
|
||||
if current:
|
||||
@ -154,6 +165,10 @@ def auto(name):
|
||||
ret['comment'] = '{0} already in auto mode'.format(name)
|
||||
return ret
|
||||
|
||||
if __opts__['test']:
|
||||
ret['comment'] = '{0} will be put in auto mode'.format(name)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
ret['changes']['result'] = __salt__['alternatives.auto'](name)
|
||||
return ret
|
||||
|
||||
@ -192,6 +207,12 @@ def set_(name, path):
|
||||
break
|
||||
|
||||
if isinstalled:
|
||||
if __opts__['test']:
|
||||
ret['comment'] = (
|
||||
'Alternative for {0} will be set to path {1}'
|
||||
).format(name, current)
|
||||
ret['result'] = None
|
||||
return ret
|
||||
__salt__['alternatives.set'](name, path)
|
||||
current = __salt__['alternatives.show_current'](name)
|
||||
if current == path:
|
||||
|
Loading…
Reference in New Issue
Block a user