diff --git a/lib/ansible/modules/network/ios/ios_facts.py b/lib/ansible/modules/network/ios/ios_facts.py index a6016453809..c5aebd5fec6 100644 --- a/lib/ansible/modules/network/ios/ios_facts.py +++ b/lib/ansible/modules/network/ios/ios_facts.py @@ -204,11 +204,11 @@ class Default(FactsBase): return match.group(1) def parse_stacks(self, data): - match = re.findall(r'^Model number\s+: (\S+)', data, re.M) + match = re.findall(r'^Model [Nn]umber\s+: (\S+)', data, re.M) if match: self.facts['stacked_models'] = match - match = re.findall(r'^System serial number\s+: (\S+)', data, re.M) + match = re.findall(r'^System [Ss]erial [Nn]umber\s+: (\S+)', data, re.M) if match: self.facts['stacked_serialnums'] = match @@ -228,12 +228,15 @@ class Hardware(FactsBase): data = self.responses[1] if data: - processor_line = [l for l in data.splitlines() - if 'Processor' in l].pop() - match = re.findall(r'\s(\d+)\s', processor_line) - if match: - self.facts['memtotal_mb'] = int(match[0]) / 1024 - self.facts['memfree_mb'] = int(match[3]) / 1024 + if 'Invalid input detected' in data: + warnings.append('Unable to gather memory statistics') + else: + processor_line = [l for l in data.splitlines() + if 'Processor' in l].pop() + match = re.findall(r'\s(\d+)\s', processor_line) + if match: + self.facts['memtotal_mb'] = int(match[0]) / 1024 + self.facts['memfree_mb'] = int(match[3]) / 1024 def parse_filesystems(self, data): return re.findall(r'^Directory of (\S+)/', data, re.M) @@ -446,6 +449,9 @@ FACT_SUBSETS = dict( VALID_SUBSETS = frozenset(FACT_SUBSETS.keys()) +global warnings +warnings = list() + def main(): """main entry point for module execution @@ -508,7 +514,6 @@ def main(): key = 'ansible_net_%s' % key ansible_facts[key] = value - warnings = list() check_args(module, warnings) module.exit_json(ansible_facts=ansible_facts, warnings=warnings) diff --git a/lib/ansible/plugins/terminal/ios.py b/lib/ansible/plugins/terminal/ios.py index 61927bda906..4a43c72b02c 100644 --- a/lib/ansible/plugins/terminal/ios.py +++ b/lib/ansible/plugins/terminal/ios.py @@ -64,7 +64,7 @@ class TerminalModule(TerminalBase): if passwd: # Note: python-3.5 cannot combine u"" and r"" together. Thus make # an r string and use to_text to ensure it's text on both py2 and py3. - cmd[u'prompt'] = to_text(r"[\r\n]password: ?$", errors='surrogate_or_strict') + cmd[u'prompt'] = to_text(r"[\r\n](?:Local_)?[Pp]assword: ?$", errors='surrogate_or_strict') cmd[u'answer'] = passwd cmd[u'prompt_retry_check'] = True try: