|
|
@ -38,12 +38,12 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Password of login user
|
|
|
|
- Password of login user
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
default: True
|
|
|
|
default: 'yes'
|
|
|
|
login_tenant_name:
|
|
|
|
login_tenant_name:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The tenant name of the login user
|
|
|
|
- The tenant name of the login user
|
|
|
|
required: true
|
|
|
|
required: true
|
|
|
|
default: True
|
|
|
|
default: 'yes'
|
|
|
|
auth_url:
|
|
|
|
auth_url:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- The keystone url for authentication
|
|
|
|
- The keystone url for authentication
|
|
|
@ -209,30 +209,35 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec = dict(
|
|
|
|
login_username = dict(default='admin'),
|
|
|
|
login_username = dict(default='admin'),
|
|
|
|
login_password = dict(required=True),
|
|
|
|
login_password = dict(required=True),
|
|
|
|
login_tenant_name = dict(required='True'),
|
|
|
|
login_tenant_name = dict(required='True'),
|
|
|
|
auth_url = dict(default='http://127.0.0.1:35357/v2.0/'),
|
|
|
|
auth_url = dict(default='http://127.0.0.1:35357/v2.0/'),
|
|
|
|
region_name = dict(default=None),
|
|
|
|
region_name = dict(default=None),
|
|
|
|
name = dict(required=True),
|
|
|
|
name = dict(required=True),
|
|
|
|
tenant_name = dict(default=None),
|
|
|
|
tenant_name = dict(default=None),
|
|
|
|
provider_network_type = dict(default='local', choices=['local', 'vlan', 'flat', 'gre']),
|
|
|
|
provider_network_type = dict(default='local', choices=['local', 'vlan', 'flat', 'gre']),
|
|
|
|
provider_physical_network = dict(default=None),
|
|
|
|
provider_physical_network = dict(default=None),
|
|
|
|
provider_segmentation_id = dict(default=None),
|
|
|
|
provider_segmentation_id = dict(default=None),
|
|
|
|
router_external = dict(default='false', choices=BOOLEANS),
|
|
|
|
router_external = dict(default='false', choices=BOOLEANS),
|
|
|
|
shared = dict(default='false', choices=BOOLEANS),
|
|
|
|
shared = dict(default='false', choices=BOOLEANS),
|
|
|
|
admin_state_up = dict(default='true', choices=BOOLEANS),
|
|
|
|
admin_state_up = dict(default='true', choices=BOOLEANS),
|
|
|
|
state = dict(default='present', choices=['absent', 'present'])
|
|
|
|
state = dict(default='present', choices=['absent', 'present'])
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['provider_network_type'] in ['vlan' , 'flat']:
|
|
|
|
if module.params['provider_network_type'] in ['vlan' , 'flat']:
|
|
|
|
if not module.params['provider_physical_network']:
|
|
|
|
if not module.params['provider_physical_network']:
|
|
|
|
module.fail_json(msg = " for vlan and flat networks, variable provider_physical_network should be set.")
|
|
|
|
module.fail_json(msg = " for vlan and flat networks, variable provider_physical_network should be set.")
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['provider_network_type'] in ['vlan', 'gre']:
|
|
|
|
if module.params['provider_network_type'] in ['vlan', 'gre']:
|
|
|
|
if not module.params['provider_segmentation_id']:
|
|
|
|
if not module.params['provider_segmentation_id']:
|
|
|
|
module.fail_json(msg = " for vlan & gre networks, variable provider_segmentation_id should be set.")
|
|
|
|
module.fail_json(msg = " for vlan & gre networks, variable provider_segmentation_id should be set.")
|
|
|
|
|
|
|
|
|
|
|
|
quantum = _get_quantum_client(module, module.params)
|
|
|
|
quantum = _get_quantum_client(module, module.params)
|
|
|
|
|
|
|
|
|
|
|
|
_set_tenant_id(module)
|
|
|
|
_set_tenant_id(module)
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['state'] == 'present':
|
|
|
|
if module.params['state'] == 'present':
|
|
|
|
network_id = _get_net_id(quantum, module)
|
|
|
|
network_id = _get_net_id(quantum, module)
|
|
|
|
if not network_id:
|
|
|
|
if not network_id:
|
|
|
@ -240,6 +245,7 @@ def main():
|
|
|
|
module.exit_json(changed = True, result = "Created", id = network_id)
|
|
|
|
module.exit_json(changed = True, result = "Created", id = network_id)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
module.exit_json(changed = False, result = "Success", id = network_id)
|
|
|
|
module.exit_json(changed = False, result = "Success", id = network_id)
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['state'] == 'absent':
|
|
|
|
if module.params['state'] == 'absent':
|
|
|
|
network_id = _get_net_id(quantum, module)
|
|
|
|
network_id = _get_net_id(quantum, module)
|
|
|
|
if not network_id:
|
|
|
|
if not network_id:
|
|
|
@ -248,9 +254,6 @@ def main():
|
|
|
|
_delete_network(module, network_id, quantum)
|
|
|
|
_delete_network(module, network_id, quantum)
|
|
|
|
module.exit_json(changed = True, result = "Deleted")
|
|
|
|
module.exit_json(changed = True, result = "Deleted")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# this is magic, see lib/ansible/module.params['common.py
|
|
|
|
# this is magic, see lib/ansible/module.params['common.py
|
|
|
|
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
|
|
|
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|