From 16381fb5c0c4f9326c6cb3d8f3a2043a2b0f25e2 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 7 Jul 2015 16:10:44 -0700 Subject: [PATCH] Plumb ipv6 modes into os_subnet Shade already supports these, we just need to plumb them into the module code. --- .../modules/cloud/openstack/os_subnet.py | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/openstack/os_subnet.py b/lib/ansible/modules/cloud/openstack/os_subnet.py index f96ce9fd633..b62eb10b0cc 100644 --- a/lib/ansible/modules/cloud/openstack/os_subnet.py +++ b/lib/ansible/modules/cloud/openstack/os_subnet.py @@ -92,6 +92,18 @@ options: - A list of host route dictionaries for the subnet. required: false default: None + ipv6_ra_mode: + description: + - IPv6 router advertisement mode + choices: ['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac'] + required: false + default: None + ipv6_address_mode: + description: + - IPv6 address mode + choices: ['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac'] + required: false + default: None requirements: - "python >= 2.6" - "shade" @@ -117,6 +129,19 @@ EXAMPLES = ''' - os_subnet: state=absent name=net1subnet + +# Create an ipv6 stateless subnet +- os_subnet: + state: present + name: intv6 + network_name: internal + ip_version: 6 + cidr: 2db8:1::/64 + dns_nameservers: + - 2001:4860:4860::8888 + - 2001:4860:4860::8844 + ipv6_ra_mode: dhcpv6-stateless + ipv6_address_mode: dhcpv6-stateless ''' @@ -163,6 +188,7 @@ def _system_state_change(module, subnet): def main(): + ipv6_mode_choices = ['dhcpv6-stateful', 'dhcpv6-stateless', 'slaac'] argument_spec = openstack_full_argument_spec( name=dict(required=True), network_name=dict(default=None), @@ -174,6 +200,8 @@ def main(): allocation_pool_start=dict(default=None), allocation_pool_end=dict(default=None), host_routes=dict(default=None, type='list'), + ipv6_ra_mode=dict(default=None, choice=ipv6_mode_choices), + ipv6_address_mode=dict(default=None, choice=ipv6_mode_choices), state=dict(default='present', choices=['absent', 'present']), ) @@ -196,6 +224,8 @@ def main(): pool_start = module.params['allocation_pool_start'] pool_end = module.params['allocation_pool_end'] host_routes = module.params['host_routes'] + ipv6_ra_mode = module.params['ipv6_ra_mode'] + ipv6_a_mode = module.params['ipv6_address_mode'] # Check for required parameters when state == 'present' if state == 'present': @@ -226,7 +256,9 @@ def main(): gateway_ip=gateway_ip, dns_nameservers=dns, allocation_pools=pool, - host_routes=host_routes) + host_routes=host_routes, + ipv6_ra_mode=ipv6_ra_mode, + ipv6_address_mode=ipv6_a_mode) changed = True else: if _needs_update(subnet, module): @@ -236,7 +268,9 @@ def main(): gateway_ip=gateway_ip, dns_nameservers=dns, allocation_pools=pool, - host_routes=host_routes) + host_routes=host_routes, + ipv6_ra_mode=ipv6_ra_mode, + ipv6_address_mode=ipv6_a_mode) changed = True else: changed = False