|
|
@ -1,4 +1,4 @@
|
|
|
|
#!/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# (c) 2015, Joseph Callen <jcallen () csc.com>
|
|
|
|
# (c) 2015, Joseph Callen <jcallen () csc.com>
|
|
|
@ -21,38 +21,39 @@
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: vmware_datacenter
|
|
|
|
module: vmware_datacenter
|
|
|
|
short_description: Create VMware vSphere Datacenter
|
|
|
|
short_description: Manage VMware vSphere Datacenters
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Create VMware vSphere Datacenter
|
|
|
|
- Manage VMware vSphere Datacenters
|
|
|
|
version_added: 2.0
|
|
|
|
version_added: 2.0
|
|
|
|
author: Joseph Callen
|
|
|
|
author: Joseph Callen
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
requirements:
|
|
|
|
|
|
|
|
- Tested on vSphere 5.5
|
|
|
|
- Tested on vSphere 5.5
|
|
|
|
- PyVmomi installed
|
|
|
|
requirements:
|
|
|
|
|
|
|
|
- PyVmomi
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
hostname:
|
|
|
|
hostname:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The hostname or IP address of the vSphere vCenter
|
|
|
|
- The hostname or IP address of the vSphere vCenter API server
|
|
|
|
required: True
|
|
|
|
required: True
|
|
|
|
version_added: 2.0
|
|
|
|
|
|
|
|
username:
|
|
|
|
username:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The username of the vSphere vCenter
|
|
|
|
- The username of the vSphere vCenter
|
|
|
|
required: True
|
|
|
|
required: True
|
|
|
|
aliases: ['user', 'admin']
|
|
|
|
aliases: ['user', 'admin']
|
|
|
|
version_added: 2.0
|
|
|
|
|
|
|
|
password:
|
|
|
|
password:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The password of the vSphere vCenter
|
|
|
|
- The password of the vSphere vCenter
|
|
|
|
required: True
|
|
|
|
required: True
|
|
|
|
aliases: ['pass', 'pwd']
|
|
|
|
aliases: ['pass', 'pwd']
|
|
|
|
version_added: 2.0
|
|
|
|
|
|
|
|
datacenter_name:
|
|
|
|
datacenter_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The name of the datacenter the cluster will be created in.
|
|
|
|
- The name of the datacenter the cluster will be created in.
|
|
|
|
required: True
|
|
|
|
required: True
|
|
|
|
version_added: 2.0
|
|
|
|
state:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- If the datacenter should be present or absent
|
|
|
|
|
|
|
|
choices: ['present', 'absent']
|
|
|
|
|
|
|
|
required: True
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
@ -133,10 +134,6 @@ def state_destroy_datacenter(module):
|
|
|
|
module.fail_json(msg=method_fault.msg)
|
|
|
|
module.fail_json(msg=method_fault.msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def state_update_datacenter(module):
|
|
|
|
|
|
|
|
module.exit_json(changed=False, msg="Currently Not Implemented")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def state_exit_unchanged(module):
|
|
|
|
def state_exit_unchanged(module):
|
|
|
|
module.exit_json(changed=False)
|
|
|
|
module.exit_json(changed=False)
|
|
|
|
|
|
|
|
|
|
|
@ -144,8 +141,12 @@ def state_exit_unchanged(module):
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
|
|
argument_spec = vmware_argument_spec()
|
|
|
|
argument_spec = vmware_argument_spec()
|
|
|
|
argument_spec.update(dict(datacenter_name=dict(required=True, type='str'),
|
|
|
|
argument_spec.update(
|
|
|
|
state=dict(default='present', choices=['present', 'absent'], type='str')))
|
|
|
|
dict(
|
|
|
|
|
|
|
|
datacenter_name=dict(required=True, type='str'),
|
|
|
|
|
|
|
|
state=dict(required=True, choices=['present', 'absent'], type='str'),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
|
|
|
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
|
|
|
|
|
|
|
|
|
|
|
if not HAS_PYVMOMI:
|
|
|
|
if not HAS_PYVMOMI:
|
|
|
@ -157,7 +158,6 @@ def main():
|
|
|
|
'absent': state_exit_unchanged,
|
|
|
|
'absent': state_exit_unchanged,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'present': {
|
|
|
|
'present': {
|
|
|
|
'update': state_update_datacenter,
|
|
|
|
|
|
|
|
'present': state_exit_unchanged,
|
|
|
|
'present': state_exit_unchanged,
|
|
|
|
'absent': state_create_datacenter,
|
|
|
|
'absent': state_create_datacenter,
|
|
|
|
}
|
|
|
|
}
|