Skip to content

Commit

Permalink
Fix ios_config file prompt issue (#32744)
Browse files Browse the repository at this point in the history
Fixes #23263

Add a carriage return (\r) at end on copy config
command which results in prompt on cli terminal
  • Loading branch information
ganeshrn committed Nov 9, 2017
1 parent 316e793 commit 37b0537
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
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

0 comments on commit 37b0537

Please sign in to comment.