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

Updates for Solaris 11

This commit is contained in:
Paul Markham 2015-07-10 13:15:47 +10:00 committed by Matt Clay
parent ecd5b22f59
commit 30f6995939

View file

@ -32,7 +32,7 @@ description:
version_added: "2.0"
author: Paul Markham
requirements:
- Solaris 10 or later
- Solaris 10 or 11
options:
state:
required: true
@ -84,6 +84,12 @@ options:
- 'Extra options to the zonecfg(1M) create command.'
required: false
default: empty string
install_options:
required: false
description:
- 'Extra options to the zoneadm(1M) install command. To automate Solaris 11 zone creation,
use this to specify the profile XML file, e.g. install_options="-c sc_profile.xml"'
required: false
attach_options:
required: false
description:
@ -141,12 +147,23 @@ class Zone(object):
self.timeout = self.module.params['timeout']
self.config = self.module.params['config']
self.create_options = self.module.params['create_options']
self.install_options = self.module.params['install_options']
self.attach_options = self.module.params['attach_options']
self.zoneadm_cmd = self.module.get_bin_path('zoneadm', True)
self.zonecfg_cmd = self.module.get_bin_path('zonecfg', True)
self.ssh_keygen_cmd = self.module.get_bin_path('ssh-keygen', True)
if self.module.check_mode:
self.msg.append('Running in check mode')
if platform.system() != 'SunOS':
self.module.fail_json(msg='This module requires Solaris')
(self.os_major, self.os_minor) = platform.release().split('.')
if int(self.os_minor) < 10:
self.module.fail_json(msg='This module requires Solaris 10 or later')
def configure(self):
if not self.path:
self.module.fail_json(msg='Missing required argument: path')
@ -176,10 +193,11 @@ class Zone(object):
def install(self):
if not self.module.check_mode:
cmd = '%s -z %s install' % (self.zoneadm_cmd, self.name)
cmd = '%s -z %s install %s' % (self.zoneadm_cmd, self.name, self.install_options)
(rc, out, err) = self.module.run_command(cmd)
if rc != 0:
self.module.fail_json(msg='Failed to install zone. %s' % (out + err))
if int(self.os_minor) == 10:
self.configure_sysid()
self.configure_password()
self.configure_ssh_keys()
@ -273,7 +291,7 @@ class Zone(object):
while True:
if elapsed > self.timeout:
self.module.fail_json(msg='timed out waiting for zone to boot')
rc = os.system('ps -z %s -o args|grep "/usr/lib/saf/ttymon.*-d /dev/console" > /dev/null 2>/dev/null' % self.name)
rc = os.system('ps -z %s -o args|grep "ttymon.*-d /dev/console" > /dev/null 2>/dev/null' % self.name)
if rc == 0:
break
time.sleep(10)
@ -341,9 +359,10 @@ class Zone(object):
def status(self):
cmd = '%s -z %s list -p' % (self.zoneadm_cmd, self.name)
(rc, out, err) = self.module.run_command(cmd)
if rc != 0:
self.module.fail_json(msg='Failed to determine zone state. %s' % (out + err))
if rc == 0:
return out.split(':')[2]
else:
return 'undefined'
def state_present(self):
if self.exists():
@ -407,18 +426,12 @@ def main():
timeout = dict(default=600, type='int'),
config = dict(default=''),
create_options = dict(default=''),
install_options = dict(default=''),
attach_options = dict(default=''),
),
supports_check_mode=True
)
if platform.system() == 'SunOS':
(major, minor) = platform.release().split('.')
if minor < 10:
module.fail_json(msg='This module requires Solaris 10 or later')
else:
module.fail_json(msg='This module requires Solaris')
zone = Zone(module)
state = module.params['state']