openstack-ansible-os_neutron/tasks/neutron_pre_install.yml
Dmitriy Rabotyagov d81a2fb7aa Ensure proper permissions for OVN Metadata service
With change of the user under which ovn-metadata service is
running from root to neutron, it was clean forgot to change an
ownership for existing configuration produced be the service during
upgrades.

This patch adds an extra folder defenition that should ensure ownership
being correct for all files related to the ovn-metadata-proxy service.

Closes-Bug: #2077684
Change-Id: I8e82558fce8a420dca5fb5302dd5f73e40230e48
2024-08-27 07:16:55 +00:00

109 lines
3.5 KiB
YAML

---
# Copyright 2014, 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 the system group
group:
name: "{{ neutron_system_group_name }}"
state: "present"
system: "yes"
- name: Create the neutron system user
user:
name: "{{ neutron_system_user_name }}"
group: "{{ neutron_system_group_name }}"
comment: "{{ neutron_system_comment }}"
shell: "{{ neutron_system_shell }}"
system: "yes"
createhome: "yes"
home: "/var/lib/{{ neutron_system_user_name }}"
# NOTE(cloudnull): During an upgrade the local directory may exist on a source
# install. If the directory does exist it will need to be
# removed. This is required on source installs because the
# config directory is a link.
- name: Source config block
block:
- name: Stat config directory
stat:
path: "{{ neutron_conf_dir }}"
register: neutron_conf_dir_stat
- name: Remove the config directory
file:
path: "{{ neutron_conf_dir }}"
state: absent
when:
- neutron_conf_dir_stat.stat.isdir is defined and
neutron_conf_dir_stat.stat.isdir
when:
- neutron_install_method == 'source'
- ((filtered_neutron_services|length) + (uwsgi_neutron_services|length)) > 0
- name: Create neutron dir
file:
path: "{{ item.path | default(omit) }}"
state: "{{ item.state | default('directory') }}"
owner: "{{ item.owner | default(neutron_system_user_name) }}"
group: "{{ item.group | default(neutron_system_group_name) }}"
mode: "{{ item.mode | default(omit) }}"
recurse: "{{ item.recurse | default(omit) }}"
when:
- (item.condition | default(true)) | bool
with_items:
- path: "/openstack"
owner: "root"
group: "root"
- path: "{{ neutron_conf_version_dir }}"
mode: "0755"
- path: "/etc/sudoers.d"
mode: "0750"
owner: "root"
group: "root"
- path: "{{ neutron_system_home_folder }}"
mode: "0755"
- path: "{{ neutron_system_home_folder }}/ovn-metadata-proxy"
mode: "u=rwX,g=rX,o=rX"
recurse: True
condition: "{{ (neutron_plugin_type == 'ml2.ovn' and neutron_services['neutron-ovn-metadata-agent']['group'] in group_names) }}"
- path: "{{ neutron_system_home_folder }}/ha_confs"
state: "{{ (neutron_plugin_type == 'ml2.ovn') | ternary('absent', 'directory') }}"
- name: Add dependency repos for Neutron
package:
name: "{{ neutron_repos }}"
state: "{{ neutron_package_state }}"
retries: 5
delay: 2
when:
- ansible_facts['pkg_mgr'] == 'dnf'
- neutron_needs_openvswitch | bool
- name: Create ovs tempfiles directory
block:
- name: Create ovs tmpfiles file
lineinfile:
dest: "/etc/tmpfiles.d/openstack-openvswitch.conf"
line: "D /var/run/openvswitch 2755 root root"
create: true
mode: "0644"
- name: Create ovs tmp directory
file:
path: "/var/run/openvswitch"
state: directory
mode: "02755"
when:
- "'ovs' in neutron_plugin_type | lower"