Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ios_config file prompt issue #32744

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/modules/network/ios/ios_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def main():
if running_config.sha1 != startup_config.sha1 or module.params['save_when'] == 'always':
result['changed'] = True
if not module.check_mode:
run_commands(module, 'copy running-config startup-config')
run_commands(module, 'copy running-config startup-config\r')
else:
module.warn('Skipping command `copy running-config startup-config` '
'due to check_mode. Configuration not copied to '
Expand Down
27 changes: 25 additions & 2 deletions test/integration/targets/ios_config/tests/cli/save.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,33 @@
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true

- name: delete config (setup)
ios_config:
replace: line
lines:
- "ip http server"
save_when: modified
authorize: yes
register: result

- name: save should always run
ios_config:
replace: line
lines:
- "ip http server"
save_when: modified
authorize: yes
register: result

- assert:
that:
- "result.changed == true"
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true

- name: teardown
ios_config:
lines:
- "no ip http server"
authorize: yes
register: result

- debug: msg="END cli/save.yaml"
2 changes: 1 addition & 1 deletion test/units/modules/network/ios/test_ios_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_ios_config_save_always(self):
self.assertEqual(self.get_config.call_count, 0)
self.assertEqual(self.load_config.call_count, 0)
args = self.run_commands.call_args[0][1]
self.assertIn('copy running-config startup-config', args)
self.assertIn('copy running-config startup-config\r', args)

def test_ios_config_lines_wo_parents(self):
set_module_args(dict(lines=['hostname foo']))
Expand Down