Adds parents to mutually_exclusive with src for *_config modules (#33957)

* mutually_exclusive add - ios_config parents works with lines by not src

* mutually_execlusive parents,src added to all other net modules

* tests for mutually_exclusive parents,src and whitespce removal
pull/18752/merge
bdowling 7 years ago committed by Nathaniel Case
parent af236f2531
commit 552d1df901

@ -48,7 +48,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -287,7 +287,8 @@ def main():
argument_spec.update(aruba_argument_spec) argument_spec.update(aruba_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -49,7 +49,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -277,7 +277,9 @@ def main():
argument_spec.update(asa_argument_spec) argument_spec.update(asa_argument_spec)
mutually_exclusive = [('lines', 'src'), ('defaults', 'passwords')] mutually_exclusive = [('lines', 'src'),
('parents', 'src'),
('defaults', 'passwords')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -291,7 +291,8 @@ def main():
argument_spec.update(ce_argument_spec) argument_spec.update(ce_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -49,7 +49,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -229,7 +229,8 @@ def main():
argument_spec.update(dellos10_argument_spec) argument_spec.update(dellos10_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive, mutually_exclusive=mutually_exclusive,

@ -48,7 +48,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -228,7 +228,8 @@ def main():
argument_spec.update(dellos6_argument_spec) argument_spec.update(dellos6_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive, mutually_exclusive=mutually_exclusive,

@ -48,7 +48,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -234,7 +234,8 @@ def main():
argument_spec.update(dellos9_argument_spec) argument_spec.update(dellos9_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive, mutually_exclusive=mutually_exclusive,

@ -52,7 +52,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is path from the playbook or role root directory. This argument is
mutually exclusive with I(lines). mutually exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -253,7 +253,8 @@ def main():
argument_spec.update(enos_argument_spec) argument_spec.update(enos_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -336,6 +336,7 @@ def main():
argument_spec.update(eos_argument_spec) argument_spec.update(eos_argument_spec)
mutually_exclusive = [('lines', 'src'), mutually_exclusive = [('lines', 'src'),
('parents', 'src'),
('save', 'save_when')] ('save', 'save_when')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),

@ -60,7 +60,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
version_added: "2.2" version_added: "2.2"
@ -416,6 +416,7 @@ def main():
argument_spec.update(ios_argument_spec) argument_spec.update(ios_argument_spec)
mutually_exclusive = [('lines', 'src'), mutually_exclusive = [('lines', 'src'),
('parents', 'src'),
('save', 'save_when')] ('save', 'save_when')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),

@ -51,7 +51,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
version_added: "2.2" version_added: "2.2"
@ -281,7 +281,8 @@ def main():
argument_spec.update(iosxr_argument_spec) argument_spec.update(iosxr_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -49,7 +49,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -256,7 +256,8 @@ def main():
argument_spec.update(ironware_argument_spec) argument_spec.update(ironware_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -47,7 +47,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -230,7 +230,8 @@ def main():
save=dict(type='bool', default=False), save=dict(type='bool', default=False),
) )
mutually_exclusive = [('lines', 'src'), ] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -344,6 +344,7 @@ def main():
argument_spec.update(nxos_argument_spec) argument_spec.update(nxos_argument_spec)
mutually_exclusive = [('lines', 'src'), mutually_exclusive = [('lines', 'src'),
('parents', 'src'),
('save', 'save_when')] ('save', 'save_when')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),

@ -48,7 +48,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
before: before:
@ -342,7 +342,8 @@ def main():
save=dict(default=False, type='bool'), save=dict(default=False, type='bool'),
) )
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
required_if = [('match', 'strict', ['lines']), required_if = [('match', 'strict', ['lines']),
('match', 'exact', ['lines']), ('match', 'exact', ['lines']),

@ -50,7 +50,7 @@ options:
or configuration template to load. The path to the source file can or configuration template to load. The path to the source file can
either be the full path on the Ansible control host or a relative either be the full path on the Ansible control host or a relative
path from the playbook or role root directory. This argument is mutually path from the playbook or role root directory. This argument is mutually
exclusive with I(lines). exclusive with I(lines), I(parents).
required: false required: false
default: null default: null
version_added: "2.2" version_added: "2.2"
@ -296,7 +296,8 @@ def main():
argument_spec.update(sros_argument_spec) argument_spec.update(sros_argument_spec)
mutually_exclusive = [('lines', 'src')] mutually_exclusive = [('lines', 'src'),
('parents', 'src')]
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive, mutually_exclusive=mutually_exclusive,

@ -174,3 +174,33 @@ class TestIosConfigModule(TestIosModule):
set_module_args(dict(lines=lines, parents=parents, match='exact')) set_module_args(dict(lines=lines, parents=parents, match='exact'))
commands = parents + lines commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False) self.execute_module(changed=True, commands=commands, sort=False)
def test_ios_config_src_and_lines_fails(self):
args = dict(src='foo', lines='foo')
set_module_args(args)
result = self.execute_module(failed=True)
def test_ios_config_src_and_parents_fails(self):
args = dict(src='foo', parents='foo')
set_module_args(args)
result = self.execute_module(failed=True)
def test_ios_config_match_exact_requires_lines(self):
args = dict(match='exact')
set_module_args(args)
result = self.execute_module(failed=True)
def test_ios_config_match_strict_requires_lines(self):
args = dict(match='strict')
set_module_args(args)
result = self.execute_module(failed=True)
def test_ios_config_replace_block_requires_lines(self):
args = dict(replace='block')
set_module_args(args)
result = self.execute_module(failed=True)
def test_ios_config_replace_config_requires_src(self):
args = dict(replace='config')
set_module_args(args)
result = self.execute_module(failed=True)

@ -137,3 +137,33 @@ class TestIosxrConfigModule(TestIosxrModule):
set_module_args(dict(lines=lines, parents=parents, match='exact')) set_module_args(dict(lines=lines, parents=parents, match='exact'))
commands = parents + lines commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False) self.execute_module(changed=True, commands=commands, sort=False)
def test_iosxr_config_src_and_lines_fails(self):
args = dict(src='foo', lines='foo')
set_module_args(args)
result = self.execute_module(failed=True)
def test_iosxr_config_src_and_parents_fails(self):
args = dict(src='foo', parents='foo')
set_module_args(args)
result = self.execute_module(failed=True)
def test_iosxr_config_match_exact_requires_lines(self):
args = dict(match='exact')
set_module_args(args)
result = self.execute_module(failed=True)
def test_iosxr_config_match_strict_requires_lines(self):
args = dict(match='strict')
set_module_args(args)
result = self.execute_module(failed=True)
def test_iosxr_config_replace_block_requires_lines(self):
args = dict(replace='block')
set_module_args(args)
result = self.execute_module(failed=True)
def test_iosxr_config_replace_config_requires_src(self):
args = dict(replace='config')
set_module_args(args)
result = self.execute_module(failed=True)

@ -110,6 +110,11 @@ class TestNxosConfigModule(TestNxosModule):
set_module_args(args) set_module_args(args)
result = self.execute_module(failed=True) result = self.execute_module(failed=True)
def test_nxos_config_src_and_parents_fails(self):
args = dict(src='foo', parents='foo')
set_module_args(args)
result = self.execute_module(failed=True)
def test_nxos_config_match_exact_requires_lines(self): def test_nxos_config_match_exact_requires_lines(self):
args = dict(match='exact') args = dict(match='exact')
set_module_args(args) set_module_args(args)

Loading…
Cancel
Save