Add mq_setup common task file

This patch adds the common task file for the mq setup tasks
which will be replicated by the proposal bot between the roles.

It also updates the script that's useful for manual sync to
accommodate the ability to sync the task file. Some documentation
is also added.

This allows sharing of role files from a single location.
It will be used for sharing common tasks of many roles, like
the mq, the dabatase, or service setup.

Without this patch, roles implementing the same kind of files
would eventually drift and be different. This is a problem as
this increases the maintenance burden.

Relates-To: https://review.openstack.org/580696
Co-Authored-By: Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
Change-Id: Ib564450eb1f3d63bb5fdd3763046dd57df519d28
This commit is contained in:
Jean-Philippe Evrard 2018-07-02 13:46:43 +02:00 committed by Jesse Pretorius
parent c9b8a5cda1
commit 8f691efaaa
2 changed files with 72 additions and 4 deletions

View File

@ -23,6 +23,10 @@
# to get more information on how to use this script. Bugs about this script
# should be submitted to the openstack-ansible project on launchpad as usual.
# This script has a partner which is executed by the proposal bot here:
# https://git.openstack.org/cgit/openstack-infra/project-config/tree/playbooks/proposal/sync_openstack_ansible_common_files.sh
# Changes made to this file should be mirrored there when applicable.
set -eu
usage() {
@ -85,14 +89,33 @@ copy_files() {
local osa_project=${1}
# Copy files
for f in ${files_to_sync[@]}; do
[[ ! -e ${osa_project}/$f ]] && continue
cp $f ${osa_project}/$f
for src_path in ${files_to_sync[@]}; do
# If the source repo does not have the file to copy
# then skip to the next file. This covers the situation
# where this script runs against old branches which
# do not have the same set of files. If the src_path
# is 'sync/tasks/*' because the folder does not exist
# then it will fail this test too.
[[ ! -e ${src_path} ]] && continue
# For the sync/* files in the array, the destination
# path is different to the source path. To work out
# the destination path we remove the 'sync/' prefix.
dst_path=${src_path#sync/}
# If the target repo does not have such a file already
# then it's probably best to leave it alone.
[[ ! -e ${osa_project}/${dst_path} ]] && continue
# We don't preserve anything from the target repo.
# We simply assume that all OSA projects need the same
# $files_to_sync
cp ${src_path} ${osa_project}/${dst_path}
done
}
# Do not change these files unless you know what you are doing
declare -ra files_to_sync=(run_tests.sh bindep.txt Vagrantfile tests/tests-repo-clone.sh .gitignore)
declare -ra files_to_sync=(run_tests.sh bindep.txt Vagrantfile tests/tests-repo-clone.sh .gitignore sync/tasks/*)
declare -r openstack_git_url="git://git.openstack.org"
excluded_projects=

45
sync/tasks/mq_setup.yml Normal file
View File

@ -0,0 +1,45 @@
---
# Copyright 2018, 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.
# WARNING:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/sync/mq_setup.yml
# If you need to modify this file, update the one in the openstack-ansible-tests
# repository. Once it merges there, the changes will automatically be proposed to
# all the repositories which use it.
- name: Setup MQ Service (RabbitMQ)
delegate_to: "{{ item.oslomsg_setup_host }}"
when:
- "item.oslomsg_transport == 'rabbit'"
block:
- name: Add RabbitMQ vhost
rabbitmq_vhost:
name: "{{ item.oslomsg_vhost }}"
state: "present"
- name: Add RabbitMQ user
rabbitmq_user:
user: "{{ item.oslomsg_userid }}"
password: "{{ item.oslomsg_password }}"
vhost: "{{ item.oslomsg_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
force: true
no_log: true
# Note: Add the tasks for additional MQ servers here