From 83a9864b0debd52e52ee13478897cb478ca58840 Mon Sep 17 00:00:00 2001 From: Marc Gariepy Date: Wed, 28 Sep 2016 15:10:29 -0400 Subject: [PATCH] Add CentOS support for os_nova * only kvm host are supported right now. Depends-On: Iff4a5999be0263a2c1843d7ca29843468cbc0ccc Depends-On: I78fb85d44b5b0e1643bd07af3e15462c02041c89 Change-Id: Ie05c243daa7d2d46b5e8779371a363d95cc990e9 --- handlers/main.yml | 12 +-- ..._nova-centos-support-4ada2ade2b9dd8c9.yaml | 3 + tasks/nova_compute_kvm.yml | 42 +++++++-- tasks/nova_compute_kvm_install.yml | 6 ++ tasks/nova_init_common.yml | 1 + tasks/nova_install.yml | 3 + tasks/nova_install_yum.yml | 86 +++++++++++++++++++ templates/libvirtd.conf.j2 | 2 +- templates/nova.conf.j2 | 9 +- tests/host_vars/localhost.yml | 1 - tests/test.yml | 10 +-- vars/redhat-7.yml | 64 ++++++++++++++ vars/ubuntu-14.04.yml | 3 + vars/ubuntu-16.04.yml | 3 + 14 files changed, 221 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/os_nova-centos-support-4ada2ade2b9dd8c9.yaml create mode 100644 tasks/nova_install_yum.yml create mode 100644 vars/redhat-7.yml diff --git a/handlers/main.yml b/handlers/main.yml index 2ce4e395..09dcd739 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -13,12 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Restart libvirt-bin - service: - name: "libvirt-bin" - state: "restarted" - pattern: "libvirt-bin" - - name: Reload systemd daemon command: "systemctl daemon-reload" notify: @@ -29,6 +23,12 @@ notify: - Restart nova services +- name: Restart libvirt-bin + service: + name: "{{ libvirt_service_name }}" + state: "restarted" + pattern: "{{ libvirt_service_name }}" + - name: Restart nova services service: name: "{{ item.value.service_name }}" diff --git a/releasenotes/notes/os_nova-centos-support-4ada2ade2b9dd8c9.yaml b/releasenotes/notes/os_nova-centos-support-4ada2ade2b9dd8c9.yaml new file mode 100644 index 00000000..fb17a6d9 --- /dev/null +++ b/releasenotes/notes/os_nova-centos-support-4ada2ade2b9dd8c9.yaml @@ -0,0 +1,3 @@ +--- +features: + - CentOS7/RHEL support has been added to the os_nova role. diff --git a/tasks/nova_compute_kvm.yml b/tasks/nova_compute_kvm.yml index c016a045..b96b43bc 100644 --- a/tasks/nova_compute_kvm.yml +++ b/tasks/nova_compute_kvm.yml @@ -18,7 +18,7 @@ - name: Add nova user to libvirtd group user: name: "{{ nova_system_user_name }}" - groups: "libvirtd" + groups: "{{ libvirt_group }}" append: "yes" tags: - nova-libvirt @@ -56,25 +56,57 @@ - nova-kvm - nova-libvirt -- name: Set libvirt runtime options +- name: Set libvirt runtime options (Ubuntu) lineinfile: dest: "/etc/default/libvirt-bin" line: 'libvirtd_opts="-d -l"' regexp: "^libvirtd_opts=" backup: "yes" - when: nova_libvirtd_listen_tcp == 1 + when: + - nova_libvirtd_listen_tcp == 1 + - ansible_pkg_mgr == 'apt' notify: Restart libvirt-bin tags: - nova-kvm - nova-libvirt -- name: Set libvirt runtime options +- name: Set libvirt runtime options (Ubuntu) lineinfile: dest: "/etc/default/libvirt-bin" line: 'libvirtd_opts="-d"' regexp: "^libvirtd_opts=" backup: "yes" - when: nova_libvirtd_listen_tcp == 0 + when: + - nova_libvirtd_listen_tcp == 0 + - ansible_pkg_mgr == 'apt' + notify: Restart libvirt-bin + tags: + - nova-kvm + - nova-libvirt + +- name: Set libvirt runtime options (CentOS) + lineinfile: + dest: "/etc/sysconfig/libvirtd" + line: 'LIBVIRTD_ARGS="-l"' + regexp: "^(#)?LIBVIRTD_ARGS=*" + backup: "yes" + when: + - nova_libvirtd_listen_tcp == 1 + - ansible_pkg_mgr == 'yum' + notify: Restart libvirt-bin + tags: + - nova-kvm + - nova-libvirt + +- name: Set libvirt runtime options (CentOS) + lineinfile: + dest: "/etc/sysconfig/libvirtd" + line: 'LIBVIRTD_ARGS=""' + regexp: "^(#)?LIBVIRTD_ARGS=*" + backup: "yes" + when: + - nova_libvirtd_listen_tcp == 0 + - ansible_pkg_mgr == 'yum' notify: Restart libvirt-bin tags: - nova-kvm diff --git a/tasks/nova_compute_kvm_install.yml b/tasks/nova_compute_kvm_install.yml index 5d562f3e..c7f22664 100644 --- a/tasks/nova_compute_kvm_install.yml +++ b/tasks/nova_compute_kvm_install.yml @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Make sure libvirt is started + service: + name: "{{ libvirt_service_name }}" + state: "started" + pattern: "{{ libvirt_service_name }}" + - name: Check the state of the default qemu save directory stat: path: "/var/lib/libvirt/qemu/save" diff --git a/tasks/nova_init_common.yml b/tasks/nova_init_common.yml index 82384cd5..47b5c658 100644 --- a/tasks/nova_init_common.yml +++ b/tasks/nova_init_common.yml @@ -25,6 +25,7 @@ service: name: "{{ item.value.service_name }}" enabled: "yes" + state: "started" with_dict: "{{ nova_services }}" when: inventory_hostname in groups[item.value.group] notify: diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index d9b6db8e..564fdf57 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -16,6 +16,9 @@ - include: nova_install_apt.yml when: ansible_pkg_mgr == 'apt' +- include: nova_install_yum.yml + when: ansible_pkg_mgr == 'yum' + - name: Create developer mode constraint file copy: dest: "/opt/developer-pip-constraints.txt" diff --git a/tasks/nova_install_yum.yml b/tasks/nova_install_yum.yml new file mode 100644 index 00000000..0c2e88a7 --- /dev/null +++ b/tasks/nova_install_yum.yml @@ -0,0 +1,86 @@ +--- +# Copyright 2014, 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: Install RDO package + yum: + pkg: "{{ rdo_package }}" + state: "present" + register: install_cloud_rdo_package + until: install_cloud_rdo_package | success + retries: 5 + delay: 2 + +- name: Install yum packages (common) + yum: + pkg: "{{ item }}" + state: "{{ nova_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_distro_packages }}" + tags: + - nova-install + - nova-yum-packages + +- name: Remove known problem packages for the Spice console + yum: + pkg: "{{ item }}" + state: absent + register: remove_packages + until: remove_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_spice_distro_packages }}" + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "spice" + tags: + - nova-install + - nova-yum-packages + - nova-spice-yum-packages + +- name: Install yum packages (novnc console) + yum: + pkg: "{{ item }}" + state: "{{ nova_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_novnc_distro_packages }}" + when: + - inventory_hostname in groups['nova_console'] + - nova_console_type == "novnc" + tags: + - nova-install + - nova-yum-packages + - nova-novnc-apt-packages + +- name: Install yum packages (compute - KVM) + yum: + pkg: "{{ item }}" + state: "{{ nova_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ nova_compute_kvm_distro_packages }}" + when: + - inventory_hostname in groups['nova_compute'] + - nova_virt_type == 'kvm' or nova_virt_type == 'qemu' + tags: + - nova-yum-packages + - nova-compute-kvm-yum-packages diff --git a/templates/libvirtd.conf.j2 b/templates/libvirtd.conf.j2 index bd4fb1bc..10a8ccb0 100644 --- a/templates/libvirtd.conf.j2 +++ b/templates/libvirtd.conf.j2 @@ -8,7 +8,7 @@ log_outputs="1:file:/var/log/libvirt/libvirtd.log" {% endif %} listen_tls = {{ nova_libvirtd_listen_tls }} listen_tcp = {{ nova_libvirtd_listen_tcp }} -unix_sock_group = "libvirtd" +unix_sock_group = "{{ libvirt_group }}" unix_sock_ro_perms = "0777" unix_sock_rw_perms = "0770" auth_unix_ro = "none" diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index e6325082..26e60c83 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -95,7 +95,8 @@ force_dhcp_release = True dhcpbridge_flagfile = /etc/nova/nova.conf firewall_driver = {{ nova_firewall_driver }} use_forwarded_for = {{ nova_network_services[nova_network_type]['use_forwarded_for'] | bool }} -my_ip = {{ nova_management_address }} +my_ip = {% if nova_management_address == 'localhost' %}127.0.0.1{% else %}{{ nova_management_address }}{% endif %} + default_floating_pool = public use_neutron = True @@ -162,8 +163,10 @@ enabled = {{ nova_console_agent_enabled }} keymap = {{ nova_console_keymap }} # Console Url and binds html5proxy_base_url = {{ nova_spice_html5proxy_base_url }} -server_listen = {{ nova_management_address }} -server_proxyclient_address = {{ nova_management_address }} +server_listen = {% if nova_management_address == 'localhost' %}127.0.0.1{% else %}{{ nova_management_address }}{% endif %} + +server_proxyclient_address = {% if nova_management_address == 'localhost' %}127.0.0.1{% else %}{{ nova_management_address }}{% endif %} + [vnc] enabled = False diff --git a/tests/host_vars/localhost.yml b/tests/host_vars/localhost.yml index f7c23ca9..863f3083 100644 --- a/tests/host_vars/localhost.yml +++ b/tests/host_vars/localhost.yml @@ -18,7 +18,6 @@ neutron_provider_networks: network_mappings: "flat:eth12" network_vxlan_ranges: "1:1000" ansible_become: True -ansible_host: 127.0.0.1 neutron_local_ip: 10.1.2.1 ansible_python_interpreter: "/usr/bin/python2" bridges: diff --git a/tests/test.yml b/tests/test.yml index a3f6e4e5..0b259545 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -13,14 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Prepare the user ssh keys -- include: common/test-prepare-keys.yml - -# Prepare the host -- include: common/test-prepare-host.yml - -# Prepare the containers -- include: common/test-prepare-containers.yml +# Setup the host +- include: common/test-setup-host.yml # Install RabbitMQ/MariaDB - include: common/test-install-infra.yml diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml new file mode 100644 index 00000000..2cdfd70c --- /dev/null +++ b/vars/redhat-7.yml @@ -0,0 +1,64 @@ +--- +# Copyright 2014, 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. + +nova_qemu_user: qemu +nova_qemu_group: qemu +libvirt_group: libvirt +libvirt_service_name: libvirtd + +# Common yum packages +nova_distro_packages: + - genisoimage + - git + - iptables + - libpqxx-devel + +# Spice console yum packages +nova_spice_distro_packages: + - spice-html5 + +nova_novnc_distro_packages: + - js-jquery + - js-underscore + - librabbitmq + - libyaml + +nova_compute_kvm_distro_packages: + - bridge-utils + - device-mapper-multipath + - dosfstools + - genisoimage + - iscsi-initiator-utils + - kpartx + - libvirt-daemon-config-nwfilter + - libvirt-daemon-kvm + - libvirt-devel + - libvirt-python + - nfs-utils + - python-libguestfs + - qemu + - qemu-img-ev + - sysfsutils + - vconfig + +# TODO: add support for LXD on CentOS at some point. +nova_compute_lxd_distro_packages: [] + +# TODO: add support for PowerVM/NovaLink on CentOS at some point. +nova_compute_powervm_distro_packages: [] + +novalink_gpg_keys: [] + +rdo_package: "https://rdoproject.org/repos/rdo-release.rpm" diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml index e2145d50..ad835e13 100644 --- a/vars/ubuntu-14.04.yml +++ b/vars/ubuntu-14.04.yml @@ -16,6 +16,9 @@ ## APT Cache options cache_timeout: 600 +libvirt_group: libvirtd +libvirt_service_name: libvirt-bin + # Common apt packages nova_distro_packages: - genisoimage diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index 3c890379..c853323c 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -16,6 +16,9 @@ ## APT Cache options cache_timeout: 600 +libvirt_group: libvirtd +libvirt_service_name: libvirt-bin + # Common apt packages nova_distro_packages: - genisoimage