diff --git a/defaults/main.yml b/defaults/main.yml index 4885ec1..054406e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/handlers/main.yml b/handlers/main.yml index 3c974ad..efc587d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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" diff --git a/releasenotes/notes/systemd_service-d564b5464d854fa7.yaml b/releasenotes/notes/systemd_service-d564b5464d854fa7.yaml new file mode 100644 index 0000000..2bbf8e5 --- /dev/null +++ b/releasenotes/notes/systemd_service-d564b5464d854fa7.yaml @@ -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. diff --git a/tasks/main.yml b/tasks/main.yml index 4a9640c..2abc0b3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/tasks/tacker_init.yml b/tasks/tacker_init.yml deleted file mode 100644 index 2549f1a..0000000 --- a/tasks/tacker_init.yml +++ /dev/null @@ -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 }}" - diff --git a/tasks/tacker_init_common.yml b/tasks/tacker_init_common.yml deleted file mode 100644 index 562e945..0000000 --- a/tasks/tacker_init_common.yml +++ /dev/null @@ -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 - - diff --git a/tasks/tacker_init_systemd.yml b/tasks/tacker_init_systemd.yml deleted file mode 100644 index 06abc30..0000000 --- a/tasks/tacker_init_systemd.yml +++ /dev/null @@ -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 - diff --git a/tasks/tacker_init_upstart.yml b/tasks/tacker_init_upstart.yml deleted file mode 100644 index 0e9aeb5..0000000 --- a/tasks/tacker_init_upstart.yml +++ /dev/null @@ -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 diff --git a/tasks/tacker_install.yml b/tasks/tacker_install.yml deleted file mode 100644 index 51fc3f7..0000000 --- a/tasks/tacker_install.yml +++ /dev/null @@ -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 }}" diff --git a/templates/tacker-systemd-init.j2 b/templates/tacker-systemd-init.j2 deleted file mode 100644 index eaa69e7..0000000 --- a/templates/tacker-systemd-init.j2 +++ /dev/null @@ -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 diff --git a/templates/tacker-systemd-tempfiles.j2 b/templates/tacker-systemd-tempfiles.j2 deleted file mode 100644 index b723d85..0000000 --- a/templates/tacker-systemd-tempfiles.j2 +++ /dev/null @@ -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 }} diff --git a/templates/tacker-upstart-init.j2 b/templates/tacker-upstart-init.j2 deleted file mode 100644 index cec73ec..0000000 --- a/templates/tacker-upstart-init.j2 +++ /dev/null @@ -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 diff --git a/templates/tacker.conf.j2 b/templates/tacker.conf.j2 index 22f2297..ff5f349 100644 --- a/templates/tacker.conf.j2 +++ b/templates/tacker.conf.j2 @@ -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. diff --git a/tests/os_tacker-overrides.yml b/tests/os_tacker-overrides.yml index 2cf4225..d0aa6ad 100644 --- a/tests/os_tacker-overrides.yml +++ b/tests/os_tacker-overrides.yml @@ -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 }}" diff --git a/tests/test-tacker-functional.yml b/tests/test-tacker-functional.yml index 71dc64c..e8e2fae 100644 --- a/tests/test-tacker-functional.yml +++ b/tests/test-tacker-functional.yml @@ -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