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