From 8e461beab923c30b05a5b63db4153303294654bd Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Fri, 27 May 2016 16:52:57 +0100 Subject: [PATCH] Neutron 16.04 support Like glance because that was awesome work. Ubuntu 16.04 requires a few changes: - bridge-utils needs to be installed on linux bridge agents - Namespaces get listed as (id: ) instead of only which causes our tests to fail. Signed-off-by: Jean-Philippe Evrard Implements: blueprint support-ubuntu-1604 Change-Id: I94723d512097b9b1f767262bde534d89cfeb1408 --- defaults/main.yml | 3 ++ tasks/main.yml | 5 +- ...tron_upstart_init.yml => neutron_init.yml} | 20 ++++---- tasks/neutron_init_common.yml | 38 +++++++++++++++ tasks/neutron_init_systemd.yml | 48 +++++++++++++++++++ ...mmon_init.yml => neutron_init_upstart.yml} | 18 ++----- tasks/neutron_install-apt.yml | 17 +++++++ templates/neutron-systemd-init.j2 | 25 ++++++++++ templates/neutron-systemd-tempfiles.j2 | 4 ++ tests/test-neutron-functional.yml | 2 +- vars/ubuntu-16.04.yml | 47 ++++++++++++++++++ 11 files changed, 197 insertions(+), 30 deletions(-) rename tasks/{neutron_upstart_init.yml => neutron_init.yml} (93%) create mode 100644 tasks/neutron_init_common.yml create mode 100644 tasks/neutron_init_systemd.yml rename tasks/{neutron_upstart_common_init.yml => neutron_init_upstart.yml} (75%) create mode 100644 templates/neutron-systemd-init.j2 create mode 100644 templates/neutron-systemd-tempfiles.j2 create mode 100644 vars/ubuntu-16.04.yml diff --git a/defaults/main.yml b/defaults/main.yml index 9a120cf7..049b7ed1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -416,6 +416,9 @@ neutron_apt_packages: - libpq-dev - radvd +neutron_lxb_apt_packages: + - bridge-utils + neutron_lbaas_apt_packages: - haproxy diff --git a/tasks/main.yml b/tasks/main.yml index b49bec28..54877c4c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,10 +36,7 @@ - include: neutron_post_install.yml # neutron system services -- include: neutron_upstart_init.yml - when: - - ansible_distribution | lower == 'ubuntu' - - ansible_distribution_version | version_compare('16.04', '<') +- include: neutron_init.yml - include: neutron_lbaas.yml diff --git a/tasks/neutron_upstart_init.yml b/tasks/neutron_init.yml similarity index 93% rename from tasks/neutron_upstart_init.yml rename to tasks/neutron_init.yml index 4950dab8..2cbd70ee 100644 --- a/tasks/neutron_upstart_init.yml +++ b/tasks/neutron_init.yml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-server'].service_name }}" program_config_options: "{{ neutron_services['neutron-server'].config_options }}" @@ -27,7 +27,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-dhcp-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-dhcp-agent'].config_options }}" @@ -41,7 +41,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-l3-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-l3-agent'].config_options }}" @@ -55,7 +55,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-linuxbridge-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-linuxbridge-agent'].config_options }}" @@ -69,7 +69,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-openvswitch-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-openvswitch-agent'].config_options }}" @@ -84,7 +84,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-metadata-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-metadata-agent'].config_options }}" @@ -98,7 +98,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-metering-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-metering-agent'].config_options }}" @@ -112,7 +112,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-lbaas-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-lbaas-agent'].config_options }}" @@ -126,7 +126,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-lbaasv2-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-lbaasv2-agent'].config_options }}" @@ -140,7 +140,7 @@ tags: - upstart-init -- include: neutron_upstart_common_init.yml +- include: neutron_init_common.yml vars: program_name: "{{ neutron_services['neutron-vpnaas-agent'].service_name }}" program_config_options: "{{ neutron_services['neutron-vpnaas-agent'].config_options }}" diff --git a/tasks/neutron_init_common.yml b/tasks/neutron_init_common.yml new file mode 100644 index 00000000..ace141c6 --- /dev/null +++ b/tasks/neutron_init_common.yml @@ -0,0 +1,38 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- include: neutron_init_upstart.yml + when: + - ansible_distribution | lower == 'ubuntu' + - ansible_distribution_version | version_compare('16.04', '<') + tags: + - neutron-init + +- include: neutron_init_systemd.yml + when: + - ansible_distribution | lower == 'ubuntu' + - ansible_distribution_version | version_compare('16.04', '>=') + tags: + - neutron-init + +- name: Load service + service: + name: "{{ program_name }}" + enabled: "yes" + notify: + - Restart neutron services + tags: + - upstart-init + - neutron-init diff --git a/tasks/neutron_init_systemd.yml b/tasks/neutron_init_systemd.yml new file mode 100644 index 00000000..979ebd27 --- /dev/null +++ b/tasks/neutron_init_systemd.yml @@ -0,0 +1,48 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Create neutron TEMP dirs + file: + path: "{{ item.path }}/{{ program_name }}" + state: directory + owner: "{{ system_user }}" + group: "{{ system_group }}" + mode: "2755" + with_items: + - { path: "/var/run" } + - { path: "/var/lock" } + +- name: Create tempfile.d entry + template: + src: "neutron-systemd-tempfiles.j2" + dest: "/etc/tmpfiles.d/neutron.conf" + mode: "0644" + owner: "root" + group: "root" + +- name: Place the systemd init script + template: + src: "neutron-systemd-init.j2" + dest: "/etc/systemd/system/{{ program_name }}.service" + mode: "0644" + owner: "root" + group: "root" + register: systemd_init + +- name: Reload the systemd daemon + command: "systemctl daemon-reload" + when: systemd_init | changed + notify: + - Restart neutron services diff --git a/tasks/neutron_upstart_common_init.yml b/tasks/neutron_init_upstart.yml similarity index 75% rename from tasks/neutron_upstart_common_init.yml rename to tasks/neutron_init_upstart.yml index f7a94af6..c1d65b43 100644 --- a/tasks/neutron_upstart_common_init.yml +++ b/tasks/neutron_init_upstart.yml @@ -1,5 +1,5 @@ --- -# Copyright 2014, Rackspace US, Inc. +# Copyright 2016, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,7 @@ mode: "0644" owner: "root" group: "root" - notify: - - Restart neutron services + register: upstart_init tags: - upstart-init - neutron-init @@ -29,18 +28,7 @@ - name: Reload init scripts shell: | initctl reload-configuration - notify: - - Restart neutron services - tags: - - upstart-init - - neutron-init - -- name: Load service - service: - name: "{{ program_name }}" - enabled: "yes" - notify: - - Restart neutron services + when: upstart_init | changed tags: - upstart-init - neutron-init diff --git a/tasks/neutron_install-apt.yml b/tasks/neutron_install-apt.yml index f95411f4..918d9011 100644 --- a/tasks/neutron_install-apt.yml +++ b/tasks/neutron_install-apt.yml @@ -43,6 +43,23 @@ - neutron-install - neutron-apt-packages +- name: Install apt packages for lxb + apt: + pkg: "{{ item }}" + state: latest + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ neutron_lxb_apt_packages }}" + when: + - inventory_hostname in groups[neutron_services['neutron-linuxbridge-agent']['group']] + - neutron_services['neutron-linuxbridge-agent']['group'] in group_names + - neutron_services['neutron-linuxbridge-agent'].service_en | bool + tags: + - neutron-install + - neutron-apt-packages + - name: Install apt packages for LBaaS apt: pkg: "{{ item }}" diff --git a/templates/neutron-systemd-init.j2 b/templates/neutron-systemd-init.j2 new file mode 100644 index 00000000..c6972cbb --- /dev/null +++ b/templates/neutron-systemd-init.j2 @@ -0,0 +1,25 @@ +# {{ ansible_managed }} + +[Unit] +Description=neutron openstack service +After=syslog.target +After=network.target + +[Service] +Type=simple +User={{ system_user }} +Group={{ system_group }} + +{% if program_override is defined %} +ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/neutron/{{ program_name }}.log +{% else %} +ExecStart={{ neutron_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/neutron/{{ program_name }}.log +{% endif %} + +# Give a reasonable amount of time for the server to start up/shut down +TimeoutSec=300 +Restart=on-failure +RestartSec=150 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/templates/neutron-systemd-tempfiles.j2 b/templates/neutron-systemd-tempfiles.j2 new file mode 100644 index 00000000..3e73b168 --- /dev/null +++ b/templates/neutron-systemd-tempfiles.j2 @@ -0,0 +1,4 @@ +# {{ ansible_managed }} + +D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }} +D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }} \ No newline at end of file diff --git a/tests/test-neutron-functional.yml b/tests/test-neutron-functional.yml index 0917d554..5d1a239a 100644 --- a/tests/test-neutron-functional.yml +++ b/tests/test-neutron-functional.yml @@ -69,7 +69,7 @@ - name: Check for iptables checksum rule shell: | - ip netns exec {{ dhcp_namespace.stdout }} iptables -C neutron-dhcp-age-POSTROUTING -t mangle -p udp --dport 68 -j CHECKSUM --checksum-fill + ip netns exec {{ dhcp_namespace.stdout.split(' ')[0] }} iptables -C neutron-dhcp-age-POSTROUTING -t mangle -p udp --dport 68 -j CHECKSUM --checksum-fill register: checksum_rule until : checksum_rule.rc == 0 retries: 5 diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 00000000..e71c937a --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,47 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This has to be reworked because openvswitch packages are not part of the UCA now +# current version is included in mainstream xenial. +ovs_apt_repo: 'deb http://ubuntu-cloud.archive.canonical.com/ubuntu xenial-updates/newton main' + +ovs_apt_packages: + - openvswitch-common + - openvswitch-switch + +## APT Cache options +cache_timeout: 600 + +neutron_apt_dependencies: + - conntrack + - dnsmasq-base + - dnsmasq-utils + - ebtables + - ipset + - iputils-arping + - keepalived + - libpq-dev + - radvd + +neutron_lbaas_apt_packages: + - haproxy + +neutron_apt_remove_packages: + - conntrackd + +neutron_lbaasv1_initscript_path: "/etc/init/neutron-lbaas-agent.conf" +neutron_lbaasv2_initscript_path: "/etc/init/neutron-lbaasv2-agent.conf" +neutron_lbaasv1_agent_servicename: "neutron-lbaas-agent" +neutron_lbaasv2_agent_servicename: "neutron-lbaasv2-agent" \ No newline at end of file