From f9760d8c98890f05d0e9cb71ef0b6eea7885dc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 5 Oct 2016 13:02:06 -0400 Subject: [PATCH] Make the role compatible with Ubuntu Xenial --- README.rst | 2 +- meta/main.yml | 1 + tasks/almanach_init.yml | 14 ++++++--- tasks/almanach_init_api_systemd.yml | 29 +++++++++++++++++++ ..._api.yml => almanach_init_api_upstart.yml} | 2 +- tasks/almanach_init_collector_systemd.yml | 29 +++++++++++++++++++ ...ml => almanach_init_collector_upstart.yml} | 2 +- tasks/main.yml | 12 ++++++++ templates/almanach-api-systemd.j2 | 20 +++++++++++++ ...pstart-init.j2 => almanach-api-upstart.j2} | 0 templates/almanach-collector-systemd.j2 | 20 +++++++++++++ ...-init.j2 => almanach-collector-upstart.j2} | 2 +- tests/test-install-infra.yml | 2 +- tests/test-vars.yml | 10 +------ tox.ini | 2 -- vars/{ubuntu.yml => ubuntu-14.04.yml} | 0 vars/ubuntu-16.04.yml | 17 +++++++++++ 17 files changed, 144 insertions(+), 20 deletions(-) create mode 100644 tasks/almanach_init_api_systemd.yml rename tasks/{almanach_init_api.yml => almanach_init_api_upstart.yml} (96%) create mode 100644 tasks/almanach_init_collector_systemd.yml rename tasks/{almanach_init_collector.yml => almanach_init_collector_upstart.yml} (95%) create mode 100644 templates/almanach-api-systemd.j2 rename templates/{almanach-api-upstart-init.j2 => almanach-api-upstart.j2} (100%) create mode 100644 templates/almanach-collector-systemd.j2 rename templates/{almanach-collector-upstart-init.j2 => almanach-collector-upstart.j2} (85%) rename vars/{ubuntu.yml => ubuntu-14.04.yml} (100%) create mode 100644 vars/ubuntu-16.04.yml diff --git a/README.rst b/README.rst index e064e50..3b982e7 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ OpenStack-Ansible Almanach :tags: openstack, almanach, cloud, ansible :category: \*nix -This Ansible role installs and configures OpenStack Almanach on Ubuntu 14.04. +This Ansible role installs and configures OpenStack Almanach on Ubuntu 14.04 and 16.04. This role will install the following Upstart services: * almanach-api diff --git a/meta/main.yml b/meta/main.yml index f0464a1..844a05d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,6 +23,7 @@ galaxy_info: - name: Ubuntu versions: - trusty + - xenial galaxy_tags: - cloud - python diff --git a/tasks/almanach_init.yml b/tasks/almanach_init.yml index 47c40b0..eb1cf71 100644 --- a/tasks/almanach_init.yml +++ b/tasks/almanach_init.yml @@ -13,8 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -- include: almanach_init_api.yml - when: inventory_hostname in groups['almanach_api'] +- include: almanach_init_api_upstart.yml + when: inventory_hostname in groups['almanach_api'] and pid1_name == "init" -- include: almanach_init_collector.yml - when: inventory_hostname in groups['almanach_collector'] +- include: almanach_init_collector_upstart.yml + when: inventory_hostname in groups['almanach_collector'] and pid1_name == "init" + +- include: almanach_init_api_systemd.yml + when: inventory_hostname in groups['almanach_api'] and pid1_name == "systemd" + +- include: almanach_init_collector_systemd.yml + when: inventory_hostname in groups['almanach_collector'] and pid1_name == "systemd" diff --git a/tasks/almanach_init_api_systemd.yml b/tasks/almanach_init_api_systemd.yml new file mode 100644 index 0000000..a73c598 --- /dev/null +++ b/tasks/almanach_init_api_systemd.yml @@ -0,0 +1,29 @@ +--- +# Copyright 2016, Internap 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: Place the systemd init script + template: + src: "almanach-api-systemd.j2" + dest: "/etc/systemd/system/{{ almanach_api_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 almanach services diff --git a/tasks/almanach_init_api.yml b/tasks/almanach_init_api_upstart.yml similarity index 96% rename from tasks/almanach_init_api.yml rename to tasks/almanach_init_api_upstart.yml index 6372c56..80ebc76 100644 --- a/tasks/almanach_init_api.yml +++ b/tasks/almanach_init_api_upstart.yml @@ -15,7 +15,7 @@ - name: Place the init script template: - src: "almanach-api-upstart-init.j2" + src: "almanach-api-upstart.j2" dest: "/etc/init/{{ almanach_api_program_name }}.conf" mode: "0644" owner: "root" diff --git a/tasks/almanach_init_collector_systemd.yml b/tasks/almanach_init_collector_systemd.yml new file mode 100644 index 0000000..eed9129 --- /dev/null +++ b/tasks/almanach_init_collector_systemd.yml @@ -0,0 +1,29 @@ +--- +# Copyright 2016, Internap 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: Place the collector systemd init script + template: + src: "almanach-collector-systemd.j2" + dest: "/etc/systemd/system/{{ almanach_collector_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 almanach services diff --git a/tasks/almanach_init_collector.yml b/tasks/almanach_init_collector_upstart.yml similarity index 95% rename from tasks/almanach_init_collector.yml rename to tasks/almanach_init_collector_upstart.yml index 75064b5..5bac0f9 100644 --- a/tasks/almanach_init_collector.yml +++ b/tasks/almanach_init_collector_upstart.yml @@ -15,7 +15,7 @@ - name: Place the init script template: - src: "almanach-collector-upstart-init.j2" + src: "almanach-collector-upstart.j2" dest: "/etc/init/{{ almanach_collector_program_name }}.conf" mode: "0644" owner: "root" diff --git a/tasks/main.yml b/tasks/main.yml index a58f92e..e595d16 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,6 +24,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: almanach_pre_install.yml tags: - almanach-install diff --git a/templates/almanach-api-systemd.j2 b/templates/almanach-api-systemd.j2 new file mode 100644 index 0000000..eb16677 --- /dev/null +++ b/templates/almanach-api-systemd.j2 @@ -0,0 +1,20 @@ +# {{ ansible_managed }} + +[Unit] +Description=Almanach api openstack service +After=syslog.target +After=network.target + +[Service] +Type=simple +User={{ almanach_system_user_name }} +Group={{ almanach_system_group_name }} + +ExecStart={{ almanach_app_dir }}/bin/almanach api {{ almanach_config_file }} --host {{ almanach_listen_ip }} --port {{ almanach_port }} --logging {{ almanach_logging_config_file }} + +TimeoutSec=300 +Restart=on-failure +RestartSec=150 + +[Install] +WantedBy=multi-user.target diff --git a/templates/almanach-api-upstart-init.j2 b/templates/almanach-api-upstart.j2 similarity index 100% rename from templates/almanach-api-upstart-init.j2 rename to templates/almanach-api-upstart.j2 diff --git a/templates/almanach-collector-systemd.j2 b/templates/almanach-collector-systemd.j2 new file mode 100644 index 0000000..010efeb --- /dev/null +++ b/templates/almanach-collector-systemd.j2 @@ -0,0 +1,20 @@ +# {{ ansible_managed }} + +[Unit] +Description=Almanach collector openstack service +After=syslog.target +After=network.target + +[Service] +Type=simple +User={{ almanach_system_user_name }} +Group={{ almanach_system_group_name }} + +ExecStart={{ almanach_app_dir }}/bin/almanach collector {{ almanach_config_file }} --logging {{ almanach_logging_config_file }} + +TimeoutSec=300 +Restart=on-failure +RestartSec=150 + +[Install] +WantedBy=multi-user.target diff --git a/templates/almanach-collector-upstart-init.j2 b/templates/almanach-collector-upstart.j2 similarity index 85% rename from templates/almanach-collector-upstart-init.j2 rename to templates/almanach-collector-upstart.j2 index 70e38cc..71b7fe4 100644 --- a/templates/almanach-collector-upstart-init.j2 +++ b/templates/almanach-collector-upstart.j2 @@ -1,6 +1,6 @@ # {{ ansible_managed }} -description "{{ almanach_api_program_name }}" +description "{{ almanach_collector_program_name }}" start on runlevel [2345] stop on runlevel [!2345] diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml index 5aec179..eb1a2a5 100644 --- a/tests/test-install-infra.yml +++ b/tests/test-install-infra.yml @@ -57,7 +57,7 @@ - name: Add almanach database user mongodb_user: login_host: "10.100.100.2" - database: almanach + database: admin name: almanach password: secrete roles: 'readWrite,dbAdmin' diff --git a/tests/test-vars.yml b/tests/test-vars.yml index a630087..1e66ddc 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -13,12 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -almanach_mongodb_url: mongodb://almanach:secrete@10.100.100.2:27017/almanach -almanach_mongodb_database: almanach - -internal_lb_vip_address: 10.100.100.2 -external_lb_vip_address: 10.100.100.2 - -rabbitmq_servers: 10.100.100.2 -rabbitmq_use_ssl: true -rabbitmq_port: 5671 +almanach_mongodb_url: mongodb://almanach:secrete@10.100.100.2:27017/admin diff --git a/tox.ini b/tox.ini index 5ace16d..58e4f69 100644 --- a/tox.ini +++ b/tox.ini @@ -116,8 +116,6 @@ commands = {toxinidir}/tests/test.yml -vvvv bash -c 'mkdir -p {toxinidir}/logs' bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' - bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv' - bash -c 'command gzip --best --recursive "{toxinidir}/logs/"' [testenv:linters] diff --git a/vars/ubuntu.yml b/vars/ubuntu-14.04.yml similarity index 100% rename from vars/ubuntu.yml rename to vars/ubuntu-14.04.yml diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 0000000..6bee34f --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2016, Internap 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. + +## APT Cache options +cache_timeout: 600