diff --git a/defaults/main.yml b/defaults/main.yml index 2f83d689..4fea1e42 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -352,6 +352,7 @@ nova_apt_packages: - genisoimage - git - libpq-dev + - iptables # Spice console apt packages nova_spice_apt_packages: diff --git a/releasenotes/notes/add-xenial-support-3dc3711e5b1bdc34.yaml b/releasenotes/notes/add-xenial-support-3dc3711e5b1bdc34.yaml new file mode 100644 index 00000000..dac463c4 --- /dev/null +++ b/releasenotes/notes/add-xenial-support-3dc3711e5b1bdc34.yaml @@ -0,0 +1,4 @@ +--- +feature: + - Support has been added to deploy the nova services on Ubuntu 16.04 + LTS. diff --git a/tasks/main.yml b/tasks/main.yml index 1bf99090..6925b85e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Detect whether the init system is upstart of systemd. +- name: Check init system + command: cat /proc/1/comm + register: _pid1_name + tags: + - always + +- name: Set the name of pid1 + set_fact: + pid1_name: "{{ _pid1_name.stdout }}" + tags: + - always + +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + - include: nova_virt_detect.yml when: nova_virt_type is not defined tags: @@ -23,7 +45,7 @@ - include: nova_install.yml - include: nova_console_install.yml - include: nova_post_install.yml -- include: nova_upstart_init.yml +- include: nova_init.yml - include: nova_db_setup.yml when: > diff --git a/tasks/nova_upstart_init.yml b/tasks/nova_init.yml similarity index 90% rename from tasks/nova_upstart_init.yml rename to tasks/nova_init.yml index dc9ba0d6..ff8f3144 100644 --- a/tasks/nova_upstart_init.yml +++ b/tasks/nova_init.yml @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_metadata_program_name }}" service_name: "{{ nova_service_name }}" @@ -22,7 +22,7 @@ service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_api_metadata'] -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_cert_program_name }}" service_name: "{{ nova_service_name }}" @@ -31,7 +31,7 @@ service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_cert'] -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_conductor_program_name }}" service_name: "{{ nova_service_name }}" @@ -40,7 +40,7 @@ service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_conductor'] -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_program_name }}" service_name: "{{ nova_service_name }}" @@ -49,7 +49,7 @@ service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_api_os_compute'] -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_scheduler_program_name }}" service_name: "{{ nova_service_name }}" @@ -58,7 +58,7 @@ service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_scheduler'] -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_compute_program_name }}" service_name: "{{ nova_service_name }}" @@ -68,7 +68,7 @@ when: inventory_hostname in groups['nova_compute'] # Upstart init script for spice console. -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_spice_program_name }}" service_name: "{{ nova_service_name }}" @@ -80,7 +80,7 @@ - nova_console_type == "spice" # Upstart init script for novnc console. -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_novncproxy_program_name }}" service_name: "{{ nova_service_name }}" @@ -91,7 +91,7 @@ - inventory_hostname in groups ['nova_console'] - nova_console_type == "novnc" -- include: nova_upstart_common_init.yml +- include: nova_init_common.yml vars: program_name: "{{ nova_consoleauth_program_name }}" service_name: "{{ nova_service_name }}" @@ -99,4 +99,3 @@ system_group: "{{ nova_system_group_name }}" service_home: "{{ nova_system_home_folder }}" when: inventory_hostname in groups['nova_console'] - diff --git a/tasks/nova_init_common.yml b/tasks/nova_init_common.yml new file mode 100644 index 00000000..82d3c6f6 --- /dev/null +++ b/tasks/nova_init_common.yml @@ -0,0 +1,35 @@ +--- +# 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: nova_init_upstart.yml + when: pid1_name == "init" + tags: + - upstart-init + - nova-init + +- include: nova_init_systemd.yml + when: pid1_name == "systemd" + tags: + - systemd-init + - nova-init + +- name: Load service + service: + name: "{{ program_name }}" + enabled: "yes" + notify: + - Restart nova services + tags: + - nova-init diff --git a/tasks/nova_init_systemd.yml b/tasks/nova_init_systemd.yml new file mode 100644 index 00000000..5983acf6 --- /dev/null +++ b/tasks/nova_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 nova 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: "nova-systemd-tempfiles.j2" + dest: "/etc/tmpfiles.d/nova.conf" + mode: "0644" + owner: "root" + group: "root" + +- name: Place the systemd init script + template: + src: "nova-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 nova services diff --git a/tasks/nova_upstart_common_init.yml b/tasks/nova_init_upstart.yml similarity index 86% rename from tasks/nova_upstart_common_init.yml rename to tasks/nova_init_upstart.yml index dcd1d969..8486eb9b 100644 --- a/tasks/nova_upstart_common_init.yml +++ b/tasks/nova_init_upstart.yml @@ -34,13 +34,3 @@ tags: - upstart-init - nova-init - -- name: Load service - service: - name: "{{ program_name }}" - enabled: "yes" - notify: - - Restart nova services - tags: - - upstart-init - - nova-init diff --git a/templates/nova-systemd-init.j2 b/templates/nova-systemd-init.j2 new file mode 100644 index 00000000..b93c484c --- /dev/null +++ b/templates/nova-systemd-init.j2 @@ -0,0 +1,25 @@ +# {{ ansible_managed }} + +[Unit] +Description=nova 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/nova/{{ program_name }}.log +{% else %} +ExecStart={{ nova_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/nova/{{ 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 diff --git a/templates/nova-systemd-tempfiles.j2 b/templates/nova-systemd-tempfiles.j2 new file mode 100644 index 00000000..b723d85d --- /dev/null +++ b/templates/nova-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 }} diff --git a/tests/test-prepare-containers.yml b/tests/test-prepare-containers.yml index c0d539ea..f85472e4 100644 --- a/tests/test-prepare-containers.yml +++ b/tests/test-prepare-containers.yml @@ -18,7 +18,6 @@ gather_facts: false roles: - role: "lxc_container_create" - lxc_container_release: trusty lxc_container_backing_store: dir global_environment_variables: PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml index c660347d..8734c24f 100644 --- a/tests/test-prepare-host.yml +++ b/tests/test-prepare-host.yml @@ -74,8 +74,3 @@ lxc_net_bridge: lxcbr0 lxc_kernel_options: - { key: 'fs.inotify.max_user_instances', value: 1024 } - lxc_container_caches: - - url: "https://rpc-repo.rackspace.com/container_images/rpc-trusty-container.tgz" - name: "trusty.tgz" - sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c" - chroot_path: trusty/rootfs-amd64 diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/vars/ubuntu-14.04.yml @@ -0,0 +1 @@ +--- diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 00000000..fb1874fc --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,2 @@ +--- +nova_uca_enable: False