diff --git a/lib/ansible/module_utils/ios.py b/lib/ansible/module_utils/ios.py index deb74d0488..b1c146583e 100644 --- a/lib/ansible/module_utils/ios.py +++ b/lib/ansible/module_utils/ios.py @@ -26,7 +26,7 @@ # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # from ansible.module_utils.basic import env_fallback -from ansible.module_utils.network_common import to_list +from ansible.module_utils.network_common import to_list, ComplexList from ansible.module_utils.connection import exec_command _DEVICE_CONFIGS = {} @@ -65,9 +65,19 @@ def get_config(module, flags=[]): _DEVICE_CONFIGS[cmd] = cfg return cfg +def to_commands(commands): + transform = ComplexList(dict( + command=dict(key=True), + prompt=dict(), + response=dict() + )) + return transform(commands) + + def run_commands(module, commands, check_rc=True): responses = list() - for cmd in to_list(commands): + commands = to_commands(to_list(commands)) + for cmd in commands: cmd = module.jsonify(cmd) rc, out, err = exec_command(module, cmd) if check_rc and rc != 0: diff --git a/lib/ansible/modules/network/ios/ios_facts.py b/lib/ansible/modules/network/ios/ios_facts.py index 3c5bdf9d1e..28bea3e2e4 100644 --- a/lib/ansible/modules/network/ios/ios_facts.py +++ b/lib/ansible/modules/network/ios/ios_facts.py @@ -208,8 +208,8 @@ class Default(FactsBase): class Hardware(FactsBase): COMMANDS = [ - 'dir | include Directory', - 'show memory statistics | include Processor' + 'dir', + 'show memory statistics' ] def populate(self): diff --git a/lib/ansible/plugins/action/ios.py b/lib/ansible/plugins/action/ios.py index 51ebd313e0..f5d19f5486 100644 --- a/lib/ansible/plugins/action/ios.py +++ b/lib/ansible/plugins/action/ios.py @@ -41,7 +41,8 @@ class ActionModule(_ActionModule): pc = copy.deepcopy(self._play_context) pc.connection = 'network_cli' - pc.port = provider['port'] or self._play_context.port + pc.network_os = 'ios' + pc.port = provider['port'] or self._play_context.port or 22 pc.remote_user = provider['username'] or self._play_context.connection_user pc.password = provider['password'] or self._play_context.password pc.become = provider['authorize'] or False