diff --git a/lib/ansible/modules/network/ios/ios_facts.py b/lib/ansible/modules/network/ios/ios_facts.py index 45b7e4bcd94..553219babd3 100644 --- a/lib/ansible/modules/network/ios/ios_facts.py +++ b/lib/ansible/modules/network/ios/ios_facts.py @@ -83,6 +83,10 @@ ansible_net_version: description: The operating system version running on the remote device returned: always type: string +ansible_net_iostype: + description: The operating system type (IOS or IOS-XE) running on the remote device + returned: always + type: string ansible_net_hostname: description: The configured hostname of the device returned: always @@ -176,6 +180,7 @@ class Default(FactsBase): data = self.responses[0] if data: self.facts['version'] = self.parse_version(data) + self.facts['iostype'] = self.parse_iostype(data) self.facts['serialnum'] = self.parse_serialnum(data) self.facts['model'] = self.parse_model(data) self.facts['image'] = self.parse_image(data) @@ -187,6 +192,13 @@ class Default(FactsBase): if match: return match.group(1) + def parse_iostype(self, data): + match = re.search(r'\S+(X86_64_LINUX_IOSD-UNIVERSALK9-M)(\S+)', data) + if match: + return "IOS-XE" + else: + return "IOS" + def parse_hostname(self, data): match = re.search(r'^(.+) uptime', data, re.M) if match: