Implement Ubuntu 16.04 support with SystemD

This change updates the barbican role to support Ubuntu 14.04 with
upstart init and 16.04 with systemd init.

Change-Id: I6d1221481c6ad97b265eece2b23c3ab83ef49248
Implements: blueprint support-ubuntu-1604
This commit is contained in:
Travis Truman 2016-07-13 15:30:12 -04:00
parent d4f029bf31
commit 82b2173701
10 changed files with 134 additions and 18 deletions

View File

@ -5,14 +5,15 @@ galaxy_info:
license: Apache-2.0
min_ansible_version: 1.9
platforms:
- name: Ubuntu
versions:
- trusty
- name: Ubuntu
versions:
- trusty
- xenial
galaxy_tags:
- cloud
- openstack
- python
- barbican
- cloud
- openstack
- python
- barbican
dependencies:
- pip_install
@ -20,3 +21,4 @@ dependencies:
when:
- ansible_pkg_mgr == 'apt'
- galera_client

View File

@ -0,0 +1,4 @@
---
features:
- The ``os_barbican`` role now supports deployment on Ubuntu 16.04 using
SystemD.

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: upstart-common-init.yml
- include: init_common.yml
vars:
program_name: "{{ barbican_uwsgi_program_name }}"
program_config_options: "{{ barbican_uwsgi_options }}"
@ -21,4 +21,4 @@
system_user: "{{ barbican_system_user_name }}"
system_group: "{{ barbican_system_group_name }}"
service_home: "{{ barbican_system_user_home }}"
log_directory: "{{ barbican_log_directory }}"
log_directory: "{{ barbican_log_directory }}"

27
tasks/init_common.yml Normal file
View File

@ -0,0 +1,27 @@
---
# Copyright 2016, Comcast 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: init_upstart.yml
when: pid1_name == "init"
- include: init_systemd.yml
when: pid1_name == "systemd"
- name: Load service
service:
name: "{{ program_name }}"
enabled: "yes"
notify:
- Restart barbican services

48
tasks/init_systemd.yml Normal file
View File

@ -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 barbican TEMP dirs
file:
path: "{{ item.path }}/{{ program_name }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
mode: 02755
with_items:
- { path: "/var/run" }
- { path: "/var/lock" }
- name: Create tempfile.d entry
template:
src: "barbican-systemd-tempfiles.j2"
dest: "/etc/tmpfiles.d/barbican.conf"
mode: "0644"
owner: "root"
group: "root"
- name: Place the systemd init script
template:
src: "barbican-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 barbican services

View File

@ -20,12 +20,9 @@
mode: "0644"
owner: "root"
group: "root"
register: upstart_init
- name: Reload init scripts
shell: |
initctl reload-configuration
- name: Load service
service:
name: "{{ program_name }}"
enabled: "yes"
when: upstart_init | changed

View File

@ -26,6 +26,18 @@
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: pre-install.yml
tags:
- barbican-install
@ -39,7 +51,7 @@
- barbican-install
- barbican-config
- include: upstart-init.yml
- include: init.yml
tags:
- barbican-install
- barbican-config

View File

@ -0,0 +1,25 @@
# {{ ansible_managed }}
[Unit]
Description=barbican 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('') }}
{% else %}
ExecStart={{ barbican_bin }}/{{ program_name }} {{ program_config_options|default('') }}
{% 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

View File

@ -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 }}

View File

@ -18,9 +18,6 @@ barbican_apt_packages:
- libapache2-mod-wsgi
- python-dev
- libssl-dev
# - libxml2-dev
# - libmysqlclient-dev
# - libxslt-dev
- libpq-dev
- git
- libffi-dev