diff --git a/lib/ansible/modules/network/nxos/nxos_hsrp.py b/lib/ansible/modules/network/nxos/nxos_hsrp.py index 8428fddd17..3da4ef7fcd 100644 --- a/lib/ansible/modules/network/nxos/nxos_hsrp.py +++ b/lib/ansible/modules/network/nxos/nxos_hsrp.py @@ -374,10 +374,7 @@ def main(): vip=dict(type='str', required=False), auth_type=dict(choices=['text', 'md5'], required=False), auth_string=dict(type='str', required=False), - state=dict(choices=['absent', 'present'], required=False, default='present'), - include_defaults=dict(default=True), - config=dict(), - save=dict(type='bool', default=False) + state=dict(choices=['absent', 'present'], required=False, default='present') ) argument_spec.update(nxos_argument_spec) @@ -464,11 +461,15 @@ def main(): module.exit_json(**results) else: load_config(module, commands) + + # validate IP if transport == 'cli': + commands.insert(0, 'config t') body = run_commands(module, commands) validate_config(body, vip, module) + results['changed'] = True - end_state = get_hsrp_group(group, interface, module) + if 'configure' in commands: commands.pop(0) diff --git a/test/units/modules/network/nxos/test_nxos_hsrp.py b/test/units/modules/network/nxos/test_nxos_hsrp.py index cd96cdd63a..d60d5e26e4 100644 --- a/test/units/modules/network/nxos/test_nxos_hsrp.py +++ b/test/units/modules/network/nxos/test_nxos_hsrp.py @@ -46,15 +46,16 @@ class TestNxosHsrpModule(TestNxosModule): def test_nxos_hsrp(self): set_module_args(dict(group='10', - vip='192.0.2.2', + vip='192.0.2.2/8', priority='150', interface='Ethernet1/2', preempt='enabled', host='192.0.2.1')) result = self.execute_module(changed=True) - self.assertEqual(sorted(result['commands']), sorted(['interface ethernet1/2', + self.assertEqual(sorted(result['commands']), sorted(['config t', + 'interface ethernet1/2', 'hsrp version 2', 'hsrp 10', 'priority 150', - 'ip 192.0.2.2', + 'ip 192.0.2.2/8', 'preempt']))