Update role for new source build process

The variables tacker_developer_mode and tacker_venv_download
no longer carry any meaning. This review changes tacker to
do the equivalent of what developer_mode was all the time,
meaning that it always builds the venv and never requires
the repo server, but it will use a repo server when available.

As part of this, we move the source build out of its own file
because it's now a single task to include the venv build role.
This is just to make it easier to follow the code.

We also change include_tasks to import_tasks and include_role
to import_role so that the tags in the python_venv_build role
will work.

In addition tacker init was replaced by the standard systemd_service
role. Due to this was added new variable tacker_init_config_overrides.
program_override variable has no influence now.

In config notification_driver was deprecated in favor of driver from
oslo_messaging_notifications

Change-Id: Id5629cb631b23887383fa23f472052477edbc4eb
This commit is contained in:
Dmitriy Rabotjagov 2019-03-28 11:54:11 +02:00 committed by Jesse Pretorius (odyssey4me)
parent 886ee2a457
commit 2a199a9621
15 changed files with 55 additions and 327 deletions

View File

@ -35,20 +35,12 @@ tacker_pip_package_state: "latest"
tacker_git_repo: https://git.openstack.org/openstack/tacker
tacker_git_install_branch: master
tacker_developer_mode: false
tacker_developer_constraints:
tacker_upper_constraints_url: "{{ requirements_git_url | default('https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=' ~ requirements_git_install_branch | default('master')) }}"
tacker_git_constraints:
- "git+{{ tacker_git_repo }}@{{ tacker_git_install_branch }}#egg=tacker"
- "--constraint {{ tacker_upper_constraints_url }}"
# TODO(odyssey4me):
# This can be simplified once all the roles are using
# python_venv_build. We can then switch to using a
# set of constraints in pip.conf inside the venv,
# perhaps prepared by giving a giving a list of
# constraints to the role.
tacker_pip_install_args: >-
{{ tacker_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''), '') }}
{{ pip_install_options | default('') }}
tacker_pip_install_args: "{{ pip_install_options | default('') }}"
# Name of the virtual env to deploy into
tacker_venv_tag: "{{ venv_tag | default('untagged') }}"
@ -60,12 +52,6 @@ tacker_bin: "/openstack/venvs/tacker-{{ tacker_venv_tag }}/bin"
# tacker_etc_dir: "/usr/local/etc/tacker"
tacker_etc_dir: "/etc/tacker"
# venv_download, even when true, will use the fallback method of building the
# venv from scratch if the venv download fails.
tacker_venv_download: "{{ not tacker_developer_mode | bool }}"
tacker_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/tacker.tgz
## System info
tacker_system_user_name: tacker
tacker_system_group_name: tacker
@ -118,7 +104,7 @@ tacker_program_name: tacker-server
## Service Type and Data
tacker_service_region: RegionOne
tacker_service_name: tacker
tacker_service_name: tacker-server
tacker_service_proto: http
tacker_service_type: nfv-orchestration
tacker_service_description: "tacker service"
@ -157,12 +143,8 @@ tacker_pip_packages:
- python-tackerclient
- tacker
## Service Names
tacker_service_names:
- "tacker-server"
tacker_config_options: --config-file {{ tacker_etc_dir }}/tacker.conf
tacker_init_config_overrides: {}
## tacker config
tacker_heat_stack_retires: 60

View File

@ -17,12 +17,9 @@
- name: Restart tacker services
service:
name: "{{ item }}"
name: "{{ tacker_service_name }}"
enabled: yes
state: restarted
pattern: "{{ item }}"
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
with_items: "{{ tacker_service_names }}"
failed_when: false
listen:
- "venv changed"

View File

@ -0,0 +1,8 @@
---
upgrade:
- |
Tacker role now uses default systemd_service role. Due to this upstart
is not supported anymore. Was added variable tacker_init_config_overrides,
with wich deployer may override predifined options.
Also variable program_override has no effect now, and tacker_service_names
was removed in favor of tacker_service_name.

View File

@ -27,38 +27,54 @@
tags:
- always
- name: Check init system
command: cat /proc/1/comm
register: _pid1_name
changed_when: False
tags:
- always
- name: Set the name of pid1
set_fact:
pid1_name: "{{ _pid1_name.stdout }}"
tags:
- always
- include_tasks: tacker_pre_install.yml
tags:
- tacker-install
- include_tasks: tacker_install.yml
- import_tasks: tacker_pre_install.yml
tags:
- tacker-install
- include_tasks: tacker_install.yml
- name: Install the python venv
import_role:
name: "python_venv_build"
vars:
venv_build_constraints: "{{ tacker_git_constraints }}"
venv_install_destination_path: "{{ tacker_bin | dirname }}"
venv_install_distro_package_list: "{{ tacker_distro_packages }}"
venv_pip_install_args: "{{ tacker_pip_install_args }}"
venv_pip_packages: "{{ tacker_pip_packages | union((tacker_oslomsg_amqp1_enabled | bool) | ternary(tacker_optional_oslomsg_amqp1_pip_packages, [])) }}"
venv_facts_when_changed:
- section: "tacker"
option: "venv_tag"
value: "{{ tacker_venv_tag }}"
tags:
- tacker-install
- include_tasks: tacker_post_install.yml
- import_tasks: tacker_post_install.yml
tags:
- tacker-install
- tacker-config
- include_tasks: tacker_init.yml
- name: Run the systemd service role
import_role:
name: systemd_service
vars:
systemd_user_name: "{{ tacker_system_user_name }}"
systemd_group_name: "{{ tacker_system_group_name }}"
systemd_tempd_prefix: openstack
systemd_slice_name: tacker
systemd_lock_path: /var/lock/tacker
systemd_CPUAccounting: true
systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true
systemd_TasksAccounting: true
systemd_services:
- service_name: "{{ tacker_service_name }}"
enabled: yes
state: started
execstarts: "{{ tacker_bin }}/{{ tacker_program_name }} {{ tacker_config_options|default('') }} --log-file=/var/log/tacker/{{ tacker_program_name }}.log"
config_overrides: "{{ tacker_init_config_overrides }}"
tags:
- systemd-service
- tacker-install
- tacker-config
- import_tasks: mq_setup.yml
when:
@ -78,13 +94,13 @@
- common-mq
- tacker-config
- include: tacker_db_setup.yml
- import_tasks: tacker_db_setup.yml
when:
- inventory_hostname == groups['tacker_all'][0]
tags:
- tacker-install
- include: tacker_service_setup.yml
- import_tasks: tacker_service_setup.yml
when:
- inventory_hostname == groups['tacker_all'][0]
tags:

View File

@ -1,26 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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_tasks: tacker_init_common.yml
vars:
program_name: "{{ tacker_program_name }}"
service_name: "{{ tacker_service_name }}"
system_user: "{{ tacker_system_user_name }}"
system_group: "{{ tacker_system_group_name }}"
service_home: "{{ tacker_system_user_home }}"
program_config_options: "{{ tacker_config_options }}"

View File

@ -1,31 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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_tasks: tacker_init_upstart.yml
when: pid1_name == "init"
- include_tasks: tacker_init_systemd.yml
when: pid1_name == "systemd"
- name: Load service
service:
name: "{{ program_name }}"
enabled: "yes"
notify:
- Restart tacker services

View File

@ -1,54 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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 TEMP run dir
file:
path: "/var/run/{{ program_name }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
mode: "02755"
- name: Create TEMP lock dir
file:
path: "/var/lock/{{ program_name }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
mode: "02755"
- name: Create tempfile.d entry
template:
src: "tacker-systemd-tempfiles.j2"
dest: "/etc/tmpfiles.d/tacker.conf"
mode: "0644"
owner: "root"
group: "root"
notify:
- Restart tacker services
- name: Place the systemd init script
template:
src: "tacker-systemd-init.j2"
dest: "/etc/systemd/system/{{ program_name }}.service"
mode: "0644"
owner: "root"
group: "root"
register: systemd_init
notify:
- Restart tacker services

View File

@ -1,33 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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 init script
template:
src: "tacker-upstart-init.j2"
dest: "/etc/init/{{ program_name }}.conf"
mode: "0644"
owner: "root"
group: "root"
register: upstart_init
notify:
- Restart tacker services
- name: Reload init scripts
command: initctl reload-configuration
when: upstart_init is changed
notify:
- Restart tacker services

View File

@ -1,52 +0,0 @@
---
# (C)2016 Brocade Communications Systems, Inc.
# 130 Holger Way, San Jose, CA 95134.
# All rights reserved.
#
# 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.
# TODO(odyssey4me):
# This can be simplified once all the roles are using
# python_venv_build. We can then switch to using a
# set of constraints in pip.conf inside the venv,
# perhaps prepared by giving a giving a list of
# constraints to the role.
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
content: |
{% for item in tacker_developer_constraints %}
{{ item }}
{% endfor %}
when:
- tacker_developer_mode | bool
- name: Ensure remote wheel building is disabled in developer mode
set_fact:
venv_build_host: "{{ ansible_hostname }}"
when:
- tacker_developer_mode | bool
- name: Install the python venv
include_role:
name: "python_venv_build"
private: yes
vars:
venv_install_destination_path: "{{ tacker_bin | dirname }}"
venv_install_distro_package_list: "{{ tacker_distro_packages }}"
venv_pip_install_args: "{{ tacker_pip_install_args }}"
venv_pip_packages: "{{ (tacker_oslomsg_amqp1_enabled | bool) | ternary(tacker_pip_packages + tacker_optional_oslomsg_amqp1_pip_packages, tacker_pip_packages) }}"
venv_facts_when_changed:
- section: "tacker"
option: "venv_tag"
value: "{{ tacker_venv_tag }}"

View File

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

View File

@ -1,4 +0,0 @@
# {{ ansible_managed }}
D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }}

View File

@ -1,41 +0,0 @@
# {{ ansible_managed }}
# vim:set ft=upstart ts=2 et:
description "{{ tacker_program_name }}"
start on runlevel [2345]
stop on runlevel [016]
respawn
respawn limit 10 5
# Set the RUNBIN environment variable
env RUNBIN="{{ tacker_bin }}/{{ tacker_program_name }}"
# Change directory to service users home
chdir "{{ tacker_system_user_home }}"
# Pre start actions
pre-start script
mkdir -p "/var/run/{{ tacker_program_name }}"
chown {{ tacker_system_user_name }}:{{ tacker_system_group_name }} "/var/run/{{ tacker_program_name }}"
mkdir -p "/var/lock/{{ tacker_program_name }}"
chown {{ tacker_system_user_name }}:{{ tacker_system_group_name }} "/var/lock/{{ tacker_program_name }}"
end script
# Post stop actions
post-stop script
rm "/var/run/{{ tacker_program_name }}/{{ tacker_program_name }}.pid"
end script
# Run the start up job
exec start-stop-daemon --start \
--chuid {{ tacker_system_user_name }} \
--make-pidfile \
--pidfile /var/run/{{ tacker_program_name }}/{{ tacker_program_name }}.pid \
--exec "{{ program_override|default('$RUNBIN') }}" \
-- {{ program_config_options|default('') }} \
--log-file=/var/log/tacker/{{ tacker_program_name }}.log

View File

@ -48,20 +48,12 @@ bind_port = {{ tacker_service_port }}
#
# service_plugins =
# Example: service_plugins = router,firewall,lbaas,vpnaas,metering
service_plugins = vnfm,nfvo
service_plugins = nfvo,vnfm
# The strategy to be used for auth.
# Supported values are 'keystone'(default), 'noauth'.
auth_strategy = keystone
# Notification_driver can be defined multiple times
# Do nothing driver
# notification_driver = tacker.openstack.common.notifier.no_op_notifier
# Logging driver
# notification_driver = tacker.openstack.common.notifier.log_notifier
# RPC driver.
notification_driver = tacker.openstack.common.notifier.rpc_notifier
[agent]
# Use "sudo tacker-rootwrap /etc/tacker/rootwrap.conf" to use the real
# root filter facility.

View File

@ -19,5 +19,4 @@ tacker_service_adminuri: "{{ tacker_service_proto }}://{{ hostvars[groups['tacke
tacker_oslomsg_rpc_password: "{{ oslomsg_rpc_password }}"
tacker_service_password: "secrete"
tacker_container_mysql_password: "secrete"
tacker_developer_mode: true
tacker_galera_address: "{{ test_galera_host }}"

View File

@ -20,7 +20,7 @@
tasks:
- name: check tacker api
uri:
url: "http://localhost:9890"
url: "http://localhost:9890/"
status_code: 200
register: result
until: result.status == 200