Add support for registering a provisioning network and subnet in Neutron

This commit is contained in:
Mark Goddard
2017-03-15 16:45:02 +00:00
parent 4e6effba99
commit c26b30e0bd
4 changed files with 103 additions and 0 deletions

23
ansible/provision-net.yml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: Ensure provisioning network and subnet are registered in neutron
# Only required to run on a single host.
hosts: controllers[0]
vars:
venv: "{{ ansible_env.PWD }}/shade-venv"
roles:
- role: neutron-net
neutron_net_venv: "{{ venv }}"
neutron_net_openstack_auth_type: "{{ openstack_auth_type }}"
neutron_net_openstack_auth: "{{ openstack_auth }}"
# Network configuration.
neutron_net_name: "provision-net"
neutron_net_type: "flat"
neutron_net_physical_network: "physnet1"
neutron_net_segmentation_id:
neutron_net_shared: True
# Subnet configuration.
neutron_net_subnet_name: "provision-subnet"
neutron_net_cidr: "{{ provision_wl_net_name | net_cidr }}"
neutron_net_gateway_ip: "{{ provision_wl_net_name | net_gateway }}"
neutron_net_allocation_pool_start: "{{ provision_wl_net_name | net_allocation_pool_start }}"
neutron_net_allocation_pool_end: "{{ provision_wl_net_name | net_allocation_pool_end }}"

View File

@@ -0,0 +1,41 @@
---
# Path to virtualenv in which to install shade and its dependencies.
neutron_net_venv:
# Authentication type compatible with the 'os_network' Ansible module's
# auth_type argument.
neutron_net_openstack_auth_type:
# Authentication parameters compatible with the 'os_network' Ansible module's
# auth argument.
neutron_net_openstack_auth: {}
# Name of the Neutron network.
neutron_net_name:
# Provider type of the Neutron network.
neutron_net_type:
# Prpvider physical network of the Neutron network.
neutron_net_physical_network:
# Provider segmentation ID of the Neutron network.
neutron_net_segmentation_id:
# Whether the Neutron network is shared.
neutron_net_shared:
# Name of the Neutron subnet.
neutron_net_subnet_name:
# CIDR representation of the Neutron subnet's IP network.
neutron_net_cidr:
# IP address of the Neutron subnet's gateway.
neutron_net_gateway_ip:
# Start of the Neutron subnet's IP allocation pool.
neutron_net_allocation_pool_start:
# End of the Neutron subnet's IP allocation pool.
neutron_net_allocation_pool_end:

View File

@@ -0,0 +1,4 @@
---
dependencies:
- role: shade
shade_venv: "{{ neutron_net_venv }}"

View File

@@ -0,0 +1,35 @@
---
# Note that setting this via a play or task variable seems to not
# evaluate the Jinja variable reference, so we use set_fact.
- name: Update the Ansible python interpreter fact to point to the virtualenv
set_fact:
ansible_python_interpreter: "{{ neutron_net_venv }}/bin/python"
- name: Ensure network is registered with Neutron
os_network:
auth_type: "{{ neutron_net_openstack_auth_type }}"
auth: "{{ neutron_net_openstack_auth }}"
name: "{{ neutron_net_name }}"
provider_network_type: "{{ neutron_net_type | default(omit) }}"
provider_physical_network: "{{ neutron_net_physical_network | default(omit) }}"
provider_segmentation_id: "{{ neutron_net_segmentation_id | default(omit) }}"
shared: "{{ neutron_net_shared }}"
state: present
- name: Ensure subnet is registered with Neutron
os_subnet:
auth_type: "{{ neutron_net_openstack_auth_type }}"
auth: "{{ neutron_net_openstack_auth }}"
name: "{{ neutron_net_subnet_name }}"
network_name: "{{ neutron_net_name }}"
cidr: "{{ neutron_net_cidr }}"
gateway_ip: "{{ neutron_net_gateway_ip | default(omit) }}"
allocation_pool_start: "{{ neutron_net_allocation_pool_start | default(omit) }}"
allocation_pool_end: "{{ neutron_net_allocation_pool_end | default(omit) }}"
state: present
# This variable is unset before we set it, and it does not appear to be
# possible to unset a variable in Ansible.
- name: Set a fact to reset the Ansible python interpreter
set_fact:
ansible_python_interpreter: /usr/bin/python