1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #510 from ludovicc/devel

Add basic support for Solaris
This commit is contained in:
Michael DeHaan 2012-06-26 11:07:29 -07:00
commit 91ad42ae75

View file

@ -211,7 +211,9 @@ def get_virtual_facts(facts):
facts = get_linux_virtual_facts(facts) facts = get_linux_virtual_facts(facts)
# get list of interfaces that are up # get list of interfaces that are up
def get_interfaces(): def get_interfaces(facts):
if facts['system'] == 'SunOS':
return []
length = 4096 length = 4096
offset = 32 offset = 32
step = 32 step = 32
@ -236,7 +238,7 @@ def get_iface_hwaddr(iface):
def get_network_facts(facts): def get_network_facts(facts):
facts['fqdn'] = socket.getfqdn() facts['fqdn'] = socket.getfqdn()
facts['hostname'] = facts['fqdn'].split('.')[0] facts['hostname'] = facts['fqdn'].split('.')[0]
facts['interfaces'] = get_interfaces() facts['interfaces'] = get_interfaces(facts)
for iface in facts['interfaces']: for iface in facts['interfaces']:
facts[iface] = { 'macaddress': get_iface_hwaddr(iface) } facts[iface] = { 'macaddress': get_iface_hwaddr(iface) }
# This is lame, but there doesn't appear to be a good way # This is lame, but there doesn't appear to be a good way
@ -309,6 +311,10 @@ def ansible_facts():
get_service_facts(facts) get_service_facts(facts)
return facts return facts
def md5_sum(f):
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s 2> /dev/null || /usr/bin/digest -a md5 -v %(file)s" % {"file": f}).read().split()[0]
return md5sum
# load config & template variables # load config & template variables
if len(sys.argv) == 1: if len(sys.argv) == 1:
@ -345,7 +351,7 @@ md5sum = None
if not os.path.exists(ansible_file): if not os.path.exists(ansible_file):
changed = True changed = True
else: else:
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0] md5sum = md5_sum(ansible_file)
# Get some basic facts in case facter or ohai are not installed # Get some basic facts in case facter or ohai are not installed
for (k, v) in ansible_facts().items(): for (k, v) in ansible_facts().items():
@ -394,7 +400,7 @@ reformat = json.dumps(setup_options, sort_keys=True, indent=4)
f.write(reformat) f.write(reformat)
f.close() f.close()
md5sum2 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0] md5sum2 = md5_sum(ansible_file)
if md5sum != md5sum2: if md5sum != md5sum2:
changed = True changed = True