mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
ios_command: Whitelist some commands starting with configure
(#35363)
* Whitelist some commands starting with `configure` * Add tests for conditional `configure` rejection
This commit is contained in:
parent
4fa02d581d
commit
1f1e5c11a9
3 changed files with 19 additions and 1 deletions
|
@ -131,6 +131,7 @@ failed_conditions:
|
|||
type: list
|
||||
sample: ['...', '...']
|
||||
"""
|
||||
import re
|
||||
import time
|
||||
|
||||
from ansible.module_utils.network.ios.ios import run_commands
|
||||
|
@ -156,13 +157,14 @@ def parse_commands(module, warnings):
|
|||
), module)
|
||||
commands = command(module.params['commands'])
|
||||
for item in list(commands):
|
||||
configure_type = re.match(r'conf(?:\w*)(?:\s+(\w+))?', item['command'])
|
||||
if module.check_mode and not item['command'].startswith('show'):
|
||||
warnings.append(
|
||||
'only show commands are supported when using check mode, not '
|
||||
'executing `%s`' % item['command']
|
||||
)
|
||||
commands.remove(item)
|
||||
elif item['command'].startswith('conf'):
|
||||
elif configure_type and configure_type.group(1) not in ('confirm', 'replace', 'revert', 'network'):
|
||||
module.fail_json(
|
||||
msg='ios_command does not support running config mode '
|
||||
'commands. Please use ios_config instead'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue