From 4ba0cfeb4b98e9e7ad9cd389fcab41c03860a1ba Mon Sep 17 00:00:00 2001 From: Sebastien Pouplin Date: Wed, 10 Oct 2018 19:00:25 +0700 Subject: [PATCH] Added iostype details in network ios_facts module (#46599) --- lib/ansible/modules/network/ios/ios_facts.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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: