|
|
@ -148,18 +148,22 @@ class VmwareServiceManager(PyVmomi):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if self.desired_state in ['start', 'present']:
|
|
|
|
if self.desired_state in ['start', 'present']:
|
|
|
|
if not actual_service_state:
|
|
|
|
if not actual_service_state:
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
host_service_system.StartService(id=self.service_name)
|
|
|
|
host_service_system.StartService(id=self.service_name)
|
|
|
|
changed_state = True
|
|
|
|
changed_state = True
|
|
|
|
elif self.desired_state in ['stop', 'absent']:
|
|
|
|
elif self.desired_state in ['stop', 'absent']:
|
|
|
|
if actual_service_state:
|
|
|
|
if actual_service_state:
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
host_service_system.StopService(id=self.service_name)
|
|
|
|
host_service_system.StopService(id=self.service_name)
|
|
|
|
changed_state = True
|
|
|
|
changed_state = True
|
|
|
|
elif self.desired_state == 'restart':
|
|
|
|
elif self.desired_state == 'restart':
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
host_service_system.RestartService(id=self.service_name)
|
|
|
|
host_service_system.RestartService(id=self.service_name)
|
|
|
|
changed_state = True
|
|
|
|
changed_state = True
|
|
|
|
|
|
|
|
|
|
|
|
if self.desired_policy:
|
|
|
|
if self.desired_policy:
|
|
|
|
if actual_service_policy != self.desired_policy:
|
|
|
|
if actual_service_policy != self.desired_policy:
|
|
|
|
|
|
|
|
if not self.module.check_mode:
|
|
|
|
host_service_system.UpdateServicePolicy(id=self.service_name,
|
|
|
|
host_service_system.UpdateServicePolicy(id=self.service_name,
|
|
|
|
policy=self.desired_policy)
|
|
|
|
policy=self.desired_policy)
|
|
|
|
changed_state = True
|
|
|
|
changed_state = True
|
|
|
@ -205,7 +209,8 @@ def main():
|
|
|
|
argument_spec=argument_spec,
|
|
|
|
argument_spec=argument_spec,
|
|
|
|
required_one_of=[
|
|
|
|
required_one_of=[
|
|
|
|
['cluster_name', 'esxi_hostname'],
|
|
|
|
['cluster_name', 'esxi_hostname'],
|
|
|
|
]
|
|
|
|
],
|
|
|
|
|
|
|
|
supports_check_mode=True
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
vmware_host_service = VmwareServiceManager(module)
|
|
|
|
vmware_host_service = VmwareServiceManager(module)
|
|
|
|