Add configuration of Neutron including genericswitch mech driver

This commit is contained in:
Mark Goddard 2017-04-01 09:10:43 +01:00
parent a23bdd2e8c
commit 30f75383e3
8 changed files with 261 additions and 20 deletions

View File

@ -151,6 +151,7 @@ kolla_openstack_logging_debug: "False"
kolla_enable_glance: "yes"
kolla_enable_ironic: "yes"
kolla_enable_neutron: "yes"
kolla_enable_swift: "yes"
###############################################################################

View File

@ -0,0 +1,48 @@
---
###############################################################################
# Neutron configuration.
# List of Neutron ML2 mechanism drivers to use.
kolla_neutron_ml2_mechanism_drivers:
- openvswitch
- genericswitch
# List of Neutron ML2 type drivers to use.
kolla_neutron_ml2_type_drivers:
- flat
- vlan
- vxlan
# List of Neutron ML2 tenant network types to use.
kolla_neutron_ml2_tenant_network_types:
- flat
- vlan
- vxlan
# List of Neutron ML2 network VLAN ranges to use. Each item should be a dict
# containing the following items:
# physical_network: The physical network
# range: Range of allowed VLANs on this physical network (min:max, (optional)
kolla_neutron_ml2_network_vlan_ranges: []
# List of switches to configure for use by genericswitch ML2 mechanism driver.
# Each item should be a dict containing the following items:
# name: Hostname of the switch
# ip: IP address on which to reach the switch
# username: SSH username
# password: SSH password (optional)
# key_file: SSH key file (optional)
# secret: SSH secret (optional)
kolla_neutron_ml2_generic_switches: []
# List of Ansible hosts representing switches to configure for use by
# genericswitch ML2 mechanism driver. These switches will be appended to
# kolla_neutron_ml2_generic_switches and their configuration will be determined
# by the following host variables:
# name: inventory_hostname
# ip: ansible_host
# username: ansible_user
# password: ansible_ssh_pass
# key_file: not currently supported
# secret: not currently supported
kolla_neutron_ml2_generic_switch_hosts: []

View File

@ -1,26 +1,64 @@
---
- name: Ensure Kolla OpenStack components are configured
hosts: config-mgmt
vars:
switch_type_to_device_type:
dellos9: netmiko_dell_force10
pre_tasks:
- name: Check whether Kolla extra configuration files exist
stat:
path: "{{ kayobe_config_path }}/kolla/config/{{ item.file }}"
register: stat_result
with_items:
- { name: glance, file: glance.conf }
- { name: inspector, file: ironic-inspector.conf }
- { name: ironic, file: ironic.conf }
- block:
- name: Check whether Kolla extra configuration files exist
stat:
path: "{{ kayobe_config_path }}/kolla/config/{{ item.file }}"
register: stat_result
with_items:
- { name: glance, file: glance.conf }
- { name: inspector, file: ironic-inspector.conf }
- { name: ironic, file: ironic.conf }
- { name: neutron, file: neutron.conf }
- { name: neutron_ml2, file: neutron/ml2_conf.ini }
- name: Initialise a fact containing extra configuration
set_fact:
kolla_extra_config: {}
- name: Initialise a fact containing extra configuration
set_fact:
kolla_extra_config: {}
- name: Update a fact containing extra configuration
set_fact:
kolla_extra_config: "{{ kolla_extra_config | combine({item.item.name: lookup('template', '{{ item.stat.path }}')}) }}"
with_items: "{{ stat_result.results }}"
when: "{{ item.stat.exists }}"
- name: Update a fact containing extra configuration
set_fact:
kolla_extra_config: "{{ kolla_extra_config | combine({item.item.name: lookup('template', '{{ item.stat.path }}')}) }}"
with_items: "{{ stat_result.results }}"
when: "{{ item.stat.exists }}"
- name: Validate switch configuration for Neutron ML2 genericswitch driver
fail:
msg: >
Switch configuration for {{ item }} is invalid. The following
variables must be set for the host: switch_type, ansible_host,
ansible_user, ansible_ssh_pass. Further, switch_type must be one of
{{ switch_type_to_device_type.keys() | join(', ') }}.
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
when: >
{{
item not in hostvars or
'switch_type' not in hostvars[item] or
hostvars[item].switch_type not in switch_type_to_device_type or
'ansible_host' not in hostvars[item] or
'ansible_user' not in hostvars[item] or
'ansible_ssh_pass' not in hostvars[item]
}}
tags:
- config-validation
- name: Update a fact containing switches for use by Neutron ML2 genericswitch driver
set_fact:
kolla_neutron_ml2_generic_switches: >
{{ kolla_neutron_ml2_generic_switches +
[{'name': item,
'device_type': switch_type_to_device_type[hostvars[item].switch_type],
'ip': hostvars[item].ansible_host,
'username': hostvars[item].ansible_user,
'password': hostvars[item].ansible_ssh_pass}] }}
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
tags:
- config
roles:
- role: kolla-openstack
# Ironic inspector configuration.
@ -39,3 +77,5 @@
kolla_extra_glance: "{{ kolla_extra_config.glance | default }}"
kolla_extra_inspector: "{{ kolla_extra_config.inspector | default }}"
kolla_extra_ironic: "{{ kolla_extra_config.ironic | default }}"
kolla_extra_neutron: "{{ kolla_extra_config.neutron | default }}"
kolla_extra_neutron_ml2: "{{ kolla_extra_config.neutron_ml2 | default }}"

View File

@ -2,9 +2,22 @@
# Directory where Kolla custom configuration files will be installed.
kolla_node_custom_config_path:
###############################################################################
# Glance configuration.
# Whether to enable Glance.
kolla_enable_glance:
# Free form extra configuration to append to glance-api.conf and
# glance-registry.conf.
kolla_extra_glance:
###############################################################################
# Ironic configuration.
# Whether to enable Ironic.
kolla_enable_ironic:
# List of enabled Ironic drivers.
kolla_ironic_drivers:
- agent_ssh
@ -144,8 +157,50 @@ kolla_inspector_dhcp_pool_start:
kolla_inspector_dhcp_pool_end:
###############################################################################
# Glance configuration.
# Neutron configuration.
# Free form extra configuration to append to glance-api.conf and
# glance-registry.conf.
kolla_extra_glance:
# Whether to enable Neutron.
kolla_enable_neutron:
# List of Neutron ML2 mechanism drivers to use.
kolla_neutron_ml2_mechanism_drivers: []
# List of Neutron ML2 type drivers to use.
kolla_neutron_ml2_type_drivers: []
# List of Neutron ML2 tenant network types to use.
kolla_neutron_ml2_tenant_network_types: []
# List of Neutron ML2 network VLAN ranges to use. Each item should be a dict
# containing the following items:
# physical_network: The physical network
# range: Range of allowed VLANs on this physical network (min:max, (optional)
kolla_neutron_ml2_network_vlan_ranges: []
# List of switches to configure for use by genericswitch ML2 mechanism driver.
# Each item should be a dict containing the following items;
# name: Hostname of the switch
# ip: IP address on which to reach the switch
# username: SSH username
# password: SSH password (optional)
# key_file: SSH key file (optional)
# secret: SSH secret (optional)
kolla_neutron_ml2_generic_switches: []
# List of Ansible hosts representing switches to configure for use by
# genericswitch ML2 mechanism driver. These switches will be appended to
# kolla_neutron_ml2_generic_switches and their configuration will be determined
# by the following host variables:
# name: inventory_hostname
# ip: ansible_host
# username: ansible_user
# password: ansible_ssh_password
# key_file: not currently supported
# secret: not currently supported
kolla_neutron_ml2_generic_switch_hosts: []
# Free form extra configuration to append to neutron.conf.
kolla_extra_neutron:
# Free form extra configuration to append to ml2_conf.ini.
kolla_extra_neutron_ml2:

View File

@ -6,6 +6,7 @@
mode: 0750
with_items:
- { name: ironic, enabled: "{{ kolla_enable_ironic }}" }
- { name: neutron, enabled: "{{ kolla_enable_neutron }}" }
- { name: swift, enabled: "{{ kolla_enable_swift }}" }
when: "{{ item.enabled | bool }}"
@ -19,6 +20,8 @@
- { src: ironic.conf.j2, dest: ironic.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: ironic-dnsmasq.conf.j2, dest: ironic/ironic-dnsmasq.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: ironic-inspector.conf.j2, dest: ironic-inspector.conf, enabled: "{{ kolla_enable_ironic }}" }
- { src: ml2_conf.ini.j2, dest: neutron/ml2_conf.ini, enabled: "{{ kolla_enable_neutron }}" }
- { src: neutron.conf.j2, dest: neutron.conf, enabled: "{{ kolla_enable_neutron }}" }
- { src: pxelinux.default.j2, dest: ironic/pxelinux.default, enabled: "{{ kolla_enable_ironic }}" }
when: "{{ item.enabled | bool }}"

View File

@ -0,0 +1,44 @@
# {{ ansible_managed }}
[ml2]
{% if kolla_neutron_ml2_mechanism_drivers %}
mechanism_drivers = {{ kolla_neutron_ml2_mechanism_drivers | join(',') }}
{% endif %}
{% if kolla_neutron_ml2_type_drivers %}
type_drivers = {{ kolla_neutron_ml2_type_drivers | join(',') }}
{% endif %}
{% if kolla_neutron_ml2_tenant_network_types %}
tenant_network_types = {{ kolla_neutron_ml2_tenant_network_types | join(',') }}
{% endif %}
[ml2_type_vlan]
{% if kolla_neutron_ml2_network_vlan_ranges %}
network_vlan_ranges = {% for vnr in kolla_neutron_ml2_network_vlan_ranges %}{{ vnr.physical_network }}{% if vnr.range is defined %}:{{ vnr.range }}{% endif %}{% if not loop.last %},{% endif %}{% endfor %}
{% endif %}
{% for switch in kolla_neutron_ml2_generic_switches %}
[genericswitch:{{ switch.name }}]
device_type = {{ switch.device_type }}
ip = {{ switch.ip }}
username = {{ switch.username }}
{% if switch.password is defined %}
password = {{ switch.password }}
{% endif %}
{% if switch.key_file is defined %}
key_file = {{ switch.key_file }}
{% endif %}
{% if switch.secret is defined %}
secret = {{ switch.secret }}
{% endif %}
{% endfor %}
{% if kolla_extra_neutron_ml2 %}
#######################
# Extra configuration
#######################
{{ kolla_extra_neutron_ml2 }}
{% endif %}

View File

@ -0,0 +1,9 @@
# {{ ansible_managed }}
{% if kolla_extra_neutron %}
#######################
# Extra configuration
#######################
{{ kolla_extra_neutron }}
{% endif %}

41
etc/kayobe/neutron.yml Normal file
View File

@ -0,0 +1,41 @@
---
###############################################################################
# Neutron configuration.
# List of Neutron ML2 mechanism drivers to use.
#kolla_neutron_ml2_mechanism_drivers:
# List of Neutron ML2 type drivers to use.
#kolla_neutron_ml2_type_drivers:
# List of Neutron ML2 tenant network types to use.
#kolla_neutron_ml2_tenant_network_types:
# List of Neutron ML2 network VLAN ranges to use. Each item should be a dict
# containing the following items:
# physical_network: The physical network
# min: Minimum of allowed VLAN range (optional)
# max: Maximum of allowed VLAN range (optional)
#kolla_neutron_ml2_network_vlan_ranges:
# List of switches to configure for use by genericswitch ML2 mechanism driver.
# Each item should be a dict containing the following items:
# name: Hostname of the switch
# ip: IP address on which to reach the switch
# username: SSH username
# password: SSH password (optional)
# key_file: SSH key file (optional)
# secret: SSH secret (optional)
#kolla_neutron_ml2_generic_switches:
# List of Ansible hosts representing switches to configure for use by
# genericswitch ML2 mechanism driver. These switches will be appended to
# kolla_neutron_ml2_generic_switches and their configuration will be determined
# by the following host variables:
# name: inventory_hostname
# ip: ansible_host
# username: ansible_user
# password: ansible_ssh_pass
# key_file: not currently supported
# secret: not currently supported
#kolla_neutron_ml2_generic_switch_hosts: