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:
parent
ecd5b22f59
commit
30f6995939
1 changed files with 48 additions and 35 deletions
|
@ -32,7 +32,7 @@ description:
|
||||||
version_added: "2.0"
|
version_added: "2.0"
|
||||||
author: Paul Markham
|
author: Paul Markham
|
||||||
requirements:
|
requirements:
|
||||||
- Solaris 10 or later
|
- Solaris 10 or 11
|
||||||
options:
|
options:
|
||||||
state:
|
state:
|
||||||
required: true
|
required: true
|
||||||
|
@ -84,6 +84,12 @@ options:
|
||||||
- 'Extra options to the zonecfg(1M) create command.'
|
- 'Extra options to the zonecfg(1M) create command.'
|
||||||
required: false
|
required: false
|
||||||
default: empty string
|
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:
|
attach_options:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
|
@ -141,12 +147,23 @@ class Zone(object):
|
||||||
self.timeout = self.module.params['timeout']
|
self.timeout = self.module.params['timeout']
|
||||||
self.config = self.module.params['config']
|
self.config = self.module.params['config']
|
||||||
self.create_options = self.module.params['create_options']
|
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.attach_options = self.module.params['attach_options']
|
||||||
|
|
||||||
self.zoneadm_cmd = self.module.get_bin_path('zoneadm', True)
|
self.zoneadm_cmd = self.module.get_bin_path('zoneadm', True)
|
||||||
self.zonecfg_cmd = self.module.get_bin_path('zonecfg', True)
|
self.zonecfg_cmd = self.module.get_bin_path('zonecfg', True)
|
||||||
self.ssh_keygen_cmd = self.module.get_bin_path('ssh-keygen', 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):
|
def configure(self):
|
||||||
if not self.path:
|
if not self.path:
|
||||||
self.module.fail_json(msg='Missing required argument: path')
|
self.module.fail_json(msg='Missing required argument: path')
|
||||||
|
@ -176,10 +193,11 @@ class Zone(object):
|
||||||
|
|
||||||
def install(self):
|
def install(self):
|
||||||
if not self.module.check_mode:
|
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)
|
(rc, out, err) = self.module.run_command(cmd)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.module.fail_json(msg='Failed to install zone. %s' % (out + err))
|
self.module.fail_json(msg='Failed to install zone. %s' % (out + err))
|
||||||
|
if int(self.os_minor) == 10:
|
||||||
self.configure_sysid()
|
self.configure_sysid()
|
||||||
self.configure_password()
|
self.configure_password()
|
||||||
self.configure_ssh_keys()
|
self.configure_ssh_keys()
|
||||||
|
@ -273,7 +291,7 @@ class Zone(object):
|
||||||
while True:
|
while True:
|
||||||
if elapsed > self.timeout:
|
if elapsed > self.timeout:
|
||||||
self.module.fail_json(msg='timed out waiting for zone to boot')
|
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:
|
if rc == 0:
|
||||||
break
|
break
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
@ -341,9 +359,10 @@ class Zone(object):
|
||||||
def status(self):
|
def status(self):
|
||||||
cmd = '%s -z %s list -p' % (self.zoneadm_cmd, self.name)
|
cmd = '%s -z %s list -p' % (self.zoneadm_cmd, self.name)
|
||||||
(rc, out, err) = self.module.run_command(cmd)
|
(rc, out, err) = self.module.run_command(cmd)
|
||||||
if rc != 0:
|
if rc == 0:
|
||||||
self.module.fail_json(msg='Failed to determine zone state. %s' % (out + err))
|
|
||||||
return out.split(':')[2]
|
return out.split(':')[2]
|
||||||
|
else:
|
||||||
|
return 'undefined'
|
||||||
|
|
||||||
def state_present(self):
|
def state_present(self):
|
||||||
if self.exists():
|
if self.exists():
|
||||||
|
@ -407,18 +426,12 @@ def main():
|
||||||
timeout = dict(default=600, type='int'),
|
timeout = dict(default=600, type='int'),
|
||||||
config = dict(default=''),
|
config = dict(default=''),
|
||||||
create_options = dict(default=''),
|
create_options = dict(default=''),
|
||||||
|
install_options = dict(default=''),
|
||||||
attach_options = dict(default=''),
|
attach_options = dict(default=''),
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
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)
|
zone = Zone(module)
|
||||||
|
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
Loading…
Reference in a new issue