
With update of ansible-lint to version >=6.0.0 a lot of new linters were added, that enabled by default. In order to comply with linter rules we're applying changes to the role. With that we also update metdata to reflect current state. Depends-On: https://review.opendev.org/c/openstack/ansible-role-systemd_service/+/888223 Change-Id: I3905e334cfbeb7ccb976358016f81c5edd6cd284
112 lines
3.4 KiB
YAML
112 lines
3.4 KiB
YAML
---
|
|
# (c) 2021, Satish Patel <satish.txt@gmail.com>
|
|
#
|
|
# Copyright
|
|
#
|
|
# 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.
|
|
|
|
# checking if ovn db are clustered or not, if not then this is fresh node.
|
|
- name: Check if ovn db is clustered
|
|
command: ovsdb-tool db-is-clustered /var/lib/ovn/ovnnb_db.db
|
|
ignore_errors: true
|
|
failed_when: false
|
|
register: _check_cluster_db
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
# We need to clean existing ovn db/lock file before cluster join.
|
|
- name: Clean up db/lock files before creating ovn cluster
|
|
when:
|
|
- _check_cluster_db.rc != 0
|
|
block:
|
|
- name: Stop ovn services
|
|
service:
|
|
name: "{{ neutron_ovn_northd_service_name }}"
|
|
state: stopped
|
|
|
|
- name: Clean up ovn db directory
|
|
file:
|
|
path: /var/lib/ovn/
|
|
state: absent
|
|
|
|
# We are finding leader node so new nodes use leader to join cluster.
|
|
- name: Find leader node in ovn cluster
|
|
shell: ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound | sed 's/ //g' | grep -oP '(?<=Role:).*'
|
|
args:
|
|
executable: /bin/bash
|
|
ignore_errors: true
|
|
delegate_to: "{{ container }}"
|
|
with_items: "{{ groups['neutron_ovn_northd'] }}"
|
|
loop_control:
|
|
loop_var: container
|
|
run_once: true
|
|
failed_when: false
|
|
register: _find_leader
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
# set leader_node variable
|
|
- name: Set leader_node fact
|
|
set_fact:
|
|
leader_node: "{{ (_find_leader.results | selectattr('stdout', 'search', 'leader')) | map(attribute='container') | list }}"
|
|
|
|
# This play only run first time to build cluster using primary node.
|
|
- name: Setup ovn cluster using primary node.
|
|
template:
|
|
src: ovn-northd-opts.j2
|
|
dest: "{{ neutron_ovn_northd_opts_file }}"
|
|
mode: "0644"
|
|
when:
|
|
- "inventory_hostname == neutron_ovn_primary_cluster_node"
|
|
- _check_cluster_db.rc != 0
|
|
- not leader_node
|
|
register: ovn_northd_opts
|
|
|
|
- name: Start ovn service
|
|
service:
|
|
name: "{{ neutron_ovn_northd_service_name }}"
|
|
state: started
|
|
when:
|
|
- "inventory_hostname == neutron_ovn_primary_cluster_node"
|
|
- _check_cluster_db.rc != 0
|
|
- not leader_node
|
|
- ovn_northd_opts.changed
|
|
|
|
- name: Configure connection settings for ovn-nb and ovn-sb
|
|
command: "{{ cmd }}"
|
|
changed_when: false
|
|
with_items:
|
|
- "ovn-nbctl --inactivity-probe={{ neutron_ovn_nb_inactivity_probe }} set-connection p{{ ovn_proto }}:6641"
|
|
- "ovn-sbctl --inactivity-probe={{ neutron_ovn_sb_inactivity_probe }} set-connection p{{ ovn_proto }}:6642"
|
|
when:
|
|
- "inventory_hostname == neutron_ovn_primary_cluster_node"
|
|
- _check_cluster_db.rc != 0
|
|
- not leader_node
|
|
- ovn_northd_opts.changed
|
|
loop_control:
|
|
loop_var: cmd
|
|
tags:
|
|
- neutron_ovn-config
|
|
|
|
# This play will add nodes in existing cluster using leader_node var.
|
|
- name: Join new nodes to ovn cluster using leader node
|
|
template:
|
|
src: ovn-northd-opts.j2
|
|
dest: "{{ neutron_ovn_northd_opts_file }}"
|
|
mode: "0644"
|
|
when:
|
|
- _check_cluster_db.rc != 0
|
|
notify:
|
|
- start ovn service
|
|
- restart ovn service
|