From b55791ef43c2bf5b0a3e7eb4eaa72d98ca899726 Mon Sep 17 00:00:00 2001 From: Joseph Benden Date: Wed, 16 Jul 2014 12:37:11 -0700 Subject: [PATCH 1/2] Support for OS X 10.10 DP3. --- lib/ansible/module_utils/facts.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 9515bd1fffe..b6030440b4b 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1377,7 +1377,9 @@ class Darwin(Hardware): return system_profile def get_mac_facts(self): - self.facts['model'] = self.sysctl['hw.model'] + rc, out, err = module.run_command("sysctl hw.model") + if rc == 0: + self.facts['model'] = out.splitlines()[-1].split()[1] self.facts['osversion'] = self.sysctl['kern.osversion'] self.facts['osrevision'] = self.sysctl['kern.osrevision'] @@ -1392,7 +1394,10 @@ class Darwin(Hardware): def get_memory_facts(self): self.facts['memtotal_mb'] = long(self.sysctl['hw.memsize']) / 1024 / 1024 - self.facts['memfree_mb'] = long(self.sysctl['hw.usermem']) / 1024 / 1024 + + rc, out, err = module.run_command("sysctl hw.usermem") + if rc == 0: + self.facts['memfree_mb'] = long(out.splitlines()[-1].split()[1]) / 1024 class Network(Facts): """ From da5e32b316a33d10a1e34c01bb8638bf854a5725 Mon Sep 17 00:00:00 2001 From: Joseph Benden Date: Fri, 18 Jul 2014 07:55:24 -0700 Subject: [PATCH 2/2] Needs additional divisor. --- lib/ansible/module_utils/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index b6030440b4b..98f77e68682 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1397,7 +1397,7 @@ class Darwin(Hardware): rc, out, err = module.run_command("sysctl hw.usermem") if rc == 0: - self.facts['memfree_mb'] = long(out.splitlines()[-1].split()[1]) / 1024 + self.facts['memfree_mb'] = long(out.splitlines()[-1].split()[1]) / 1024 / 1024 class Network(Facts): """