diff --git a/meta/main.yml b/meta/main.yml index 96cd1b8e..a73819a6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,6 +23,7 @@ galaxy_info: - name: Ubuntu versions: - trusty + - xenial categories: - cloud - python diff --git a/releasenotes/notes/os_cinder-1604-support.yaml b/releasenotes/notes/os_cinder-1604-support.yaml new file mode 100644 index 00000000..cfa5bf6a --- /dev/null +++ b/releasenotes/notes/os_cinder-1604-support.yaml @@ -0,0 +1,3 @@ +--- +features: + - The ''os_cinder'' role now supports Ubuntu 16.04 diff --git a/tasks/cinder_upstart_init.yml b/tasks/cinder_init.yml similarity index 90% rename from tasks/cinder_upstart_init.yml rename to tasks/cinder_init.yml index 5c50c86c..d2726c8f 100644 --- a/tasks/cinder_upstart_init.yml +++ b/tasks/cinder_init.yml @@ -1,5 +1,5 @@ --- -# Copyright 2014, Rackspace US, Inc. +# Copyright 2014-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. @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: cinder_upstart_common_init.yml +- include: cinder_init_common.yml vars: program_name: "{{ cinder_service_program_name }}" service_name: "{{ cinder_service_name }}" @@ -25,7 +25,7 @@ tags: - upstart-init -- include: cinder_upstart_common_init.yml +- include: cinder_init_common.yml vars: program_name: "{{ cinder_service_scheduler_program_name }}" service_name: "{{ cinder_service_name }}" @@ -37,7 +37,7 @@ tags: - upstart-init -- include: cinder_upstart_common_init.yml +- include: cinder_init_common.yml vars: program_name: "{{ cinder_service_volume_program_name }}" service_name: "{{ cinder_service_name }}" @@ -49,7 +49,7 @@ tags: - upstart-init -- include: cinder_upstart_common_init.yml +- include: cinder_init_common.yml vars: program_name: "{{ cinder_service_backup_program_name }}" service_name: "{{ cinder_service_name }}" diff --git a/tasks/cinder_init_common.yml b/tasks/cinder_init_common.yml new file mode 100644 index 00000000..5592adab --- /dev/null +++ b/tasks/cinder_init_common.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# Copyright 2016, IBM Corporation. +# +# 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: cinder_init_upstart.yml + when: pid1_name == "init" + tags: + - cinder-init + +- include: cinder_init_systemd.yml + when: pid1_name == "systemd" + tags: + - cinder-init + +- name: Load service + service: + name: "{{ program_name }}" + enabled: "yes" + notify: + - Restart cinder services \ No newline at end of file diff --git a/tasks/cinder_init_systemd.yml b/tasks/cinder_init_systemd.yml new file mode 100644 index 00000000..bfa0ad9f --- /dev/null +++ b/tasks/cinder_init_systemd.yml @@ -0,0 +1,49 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# Copyright 2016, IBM Corporation. +# +# 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 cinder 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: "cinder-systemd-tempfiles.j2" + dest: "/etc/tmpfiles.d/cinder.conf" + mode: "0644" + owner: "root" + group: "root" + +- name: Place the systemd init script + template: + src: "cinder-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 cinder services \ No newline at end of file diff --git a/tasks/cinder_upstart_common_init.yml b/tasks/cinder_init_upstart.yml similarity index 93% rename from tasks/cinder_upstart_common_init.yml rename to tasks/cinder_init_upstart.yml index 8c8227a8..158e50b7 100644 --- a/tasks/cinder_upstart_common_init.yml +++ b/tasks/cinder_init_upstart.yml @@ -20,6 +20,8 @@ mode: "0644" owner: "root" group: "root" + register: upstart_init + notify: - Restart cinder services tags: @@ -29,6 +31,9 @@ - name: Reload init scripts shell: | initctl reload-configuration + when: upstart_init | changed + register: upstart_init + notify: - Restart cinder services tags: diff --git a/tasks/main.yml b/tasks/main.yml index 10a61393..a69c0126 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,9 +24,30 @@ tags: - always +- 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 + - include: cinder_pre_install.yml + tags: + - cinder-install + - include: cinder_install.yml + tags: + - cinder-install + - cinder-config + - include: cinder_post_install.yml + tags: + - cinder-install - include: cinder_db_setup.yml when: > @@ -36,7 +57,9 @@ when: > inventory_hostname == groups['cinder_all'][0] -- include: cinder_upstart_init.yml +- include: cinder_init.yml + tags: + - cinder-install - name: Flush handlers meta: flush_handlers @@ -49,3 +72,5 @@ when: > inventory_hostname in groups['cinder_volume'] and cinder_backend_lvm_inuse + tags: + - cinder-install diff --git a/templates/cinder-systemd-init.j2 b/templates/cinder-systemd-init.j2 new file mode 100644 index 00000000..b486a0ba --- /dev/null +++ b/templates/cinder-systemd-init.j2 @@ -0,0 +1,25 @@ +# {{ ansible_managed }} + +[Unit] +Description=cinder 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/cinder/{{ program_name }}.log +{% else %} +ExecStart={{ cinder_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ 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/cinder-systemd-tempfiles.j2 b/templates/cinder-systemd-tempfiles.j2 new file mode 100644 index 00000000..3e73b168 --- /dev/null +++ b/templates/cinder-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/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 00000000..c8cffb30 --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,43 @@ +--- +# Copyright 2016, Intel Corporation. +# Copyright 2016, IBM Corporation. +# +# 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. + +## APT Cache options +cache_timeout: 600 + +# Common apt packages +cinder_apt_packages: + - rpcbind + - rsync + - git + - nfs-common + - libpq-dev + - libkmod-dev + - libkmod2 + - libxslt1-dev + - zlib1g + - zlibc + - libffi-dev + - libssl-dev + +cinder_volume_apt_packages: + - qemu-utils + +cinder_lvm_volume_apt_packages: + - dmeventd + - parted + - tgt + +