diff --git a/lib/ansible/module_utils/network/enos/enos.py b/lib/ansible/module_utils/network/enos/enos.py index 953922441f..0ab41597d0 100644 --- a/lib/ansible/module_utils/network/enos/enos.py +++ b/lib/ansible/module_utils/network/enos/enos.py @@ -97,7 +97,11 @@ def get_connection(module): def get_config(module, flags=None): flags = [] if flags is None else flags - passwords = module.params['passwords'] + passwords = None + try: + passwords = module.params['passwords'] + except KeyError: + passwords = None if passwords: cmd = 'more system:running-config' else: @@ -147,6 +151,7 @@ def run_commands(module, commands, check_rc=True): def load_config(module, config): try: conn = get_connection(module) + conn.get('enable') conn.edit_config(config) except ConnectionError as exc: module.fail_json(msg=to_text(exc)) diff --git a/lib/ansible/modules/network/enos/enos_config.py b/lib/ansible/modules/network/enos/enos_config.py index 31b066a3d8..1b222b1003 100644 --- a/lib/ansible/modules/network/enos/enos_config.py +++ b/lib/ansible/modules/network/enos/enos_config.py @@ -166,20 +166,13 @@ backup_path: from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.enos.enos import load_config, get_config from ansible.module_utils.network.enos.enos import enos_argument_spec -from ansible.module_utils.network.enos.enos import check_args as enos_check_args +from ansible.module_utils.network.enos.enos import check_args from ansible.module_utils.network.common.config import NetworkConfig, dumps DEFAULT_COMMIT_COMMENT = 'configured by enos_config' -def check_args(module, warnings): - enos_check_args(module, warnings) - if module.params['comment']: - if len(module.params['comment']) > 60: - module.fail_json(msg='comment argument cannot be more than 60 characters') - - def get_running_config(module): contents = module.params['config'] if not contents: @@ -190,7 +183,10 @@ def get_running_config(module): def get_candidate(module): candidate = NetworkConfig(indent=1) if module.params['src']: - candidate.load(module.params['src']) + try: + candidate.loadfp(module.params['src']) + except IOError: + candidate.load(module.params['src']) elif module.params['lines']: parents = module.params['parents'] or list() candidate.add(module.params['lines'], parents=parents) @@ -228,8 +224,7 @@ def run(module, result): result['commands'] = commands - diff = load_config(module, commands, result['warnings'], - not check_mode, replace_config, comment, admin) + diff = load_config(module, commands) if diff: result['diff'] = dict(prepared=diff) result['changed'] = True