Added tasks in nova and neutron test yml files

Moved Rabbitmq and DB tasks to generic files.
This patch removes the redundant behaviour of the tasks such
as Ensuring Rabbitmq hosts and user, creating db, granting access
to db in the testing yml files. The patch  makes it more generic
and shifted the common tasks to separate files create-grant-db.yml
 and ensure-rabbitmq.yml

Change-Id: Ibd94e1ebdce45b782ab447ca3db5068588a1e368
This commit is contained in:
root 2016-08-11 22:00:15 +00:00
parent 9b8832ef50
commit 7f03b7fdc4
7 changed files with 149 additions and 222 deletions

38
create-grant-db.yml Normal file
View File

@ -0,0 +1,38 @@
---
# Copyright 2015, 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 DB for service
mysql_db:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ db_name }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
- name: Grant access to the DB for the service
mysql_user:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ db_name }}"
password: "{{ db_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ db_name }}.*:ALL"
with_items:
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"

32
ensure-rabbitmq.yml Normal file
View File

@ -0,0 +1,32 @@
---
# Copyright 2015, 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: Ensure rabbitmq vhost
rabbitmq_vhost:
name: "{{ vhost_name }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ user_name }}"
password: "{{ user_password }}"
vhost: "{{ vhost_name }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"

View File

@ -0,0 +1,34 @@
---
# Copyright 2015, 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: Setting nodepool variables
hosts: all
gather_facts: false
tasks:
- name: Check if this is an OpenStack-CI nodepool instance
stat:
path: /etc/nodepool/provider
register: nodepool
delegate_to: localhost
- name: Determine the existing Ubuntu repo URL (only on OpenStack-CI)
shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list'
register: ubuntu_repo_url
changed_when: false
when: ansible_pkg_mgr == 'apt' and nodepool.stat.exists == True
delegate_to: localhost
- name: Set Ubuntu Cloud Archive repo URL based on discovered information
set_fact:
uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive"
when: ansible_pkg_mgr == 'apt' and nodepool.stat.exists == True

View File

@ -18,47 +18,15 @@
user: root
gather_facts: true
pre_tasks:
- name: Ensure rabbitmq vhost
rabbitmq_vhost:
name: "{{ glance_rabbitmq_vhost }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['glance_all'][0]
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ glance_rabbitmq_userid }}"
password: "{{ glance_rabbitmq_password }}"
vhost: "{{ glance_rabbitmq_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['glance_all'][0]
- name: Create DB for service
mysql_db:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ glance_galera_database }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['glance_all'][0]
- name: Grant access to the DB for the service
mysql_user:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ glance_galera_database }}"
password: "{{ glance_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ glance_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['glance_all'][0]
- include: ensure-rabbitmq.yml
vhost_name: "{{ glance_rabbitmq_vhost }}"
user_name: "{{ glance_rabbitmq_userid }}"
user_password: "{{ glance_rabbitmq_password }}"
host_name: groups['glance_all'][0]
- include: create-grant-db.yml
db_name: "{{ glance_galera_database }}"
db_password: "{{ glance_container_mysql_password }}"
host_name: groups['glance_all'][0]
roles:
- role: "{{ glance_rolename | default('os_glance') }}"
vars_files:

View File

@ -18,63 +18,18 @@
user: root
gather_facts: true
pre_tasks:
- name: Set keystone_messaging fact no rabbit
- name: Set keystone_messaging fact
set_fact:
keystone_messaging_enabled: false
when: groups['rabbitmq_all'] is not defined
- name: Set keystone_messaging fact rabbit
set_fact:
keystone_messaging_enabled: true
when: groups['rabbitmq_all'] is defined
- name: Ensure rabbitmq vhost
rabbitmq_vhost:
name: "{{ keystone_rabbitmq_vhost }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when:
- inventory_hostname == groups['keystone_all'][0]
- groups['rabbitmq_all'] is defined
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ keystone_rabbitmq_userid }}"
password: "{{ keystone_rabbitmq_password }}"
vhost: "{{ keystone_rabbitmq_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when:
- inventory_hostname == groups['keystone_all'][0]
- groups['rabbitmq_all'] is defined
- name: Create DB for service
mysql_db:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ keystone_galera_database }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['keystone_all'][0]
tags:
- mysql-db-setup
- name: Grant access to the DB for the service
mysql_user:
login_user: "{{ galera_root_user }}"
login_password: "{{ galera_root_password }}"
login_host: "localhost"
name: "{{ keystone_galera_database }}"
password: "{{ keystone_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ keystone_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['keystone_all'][0]
tags:
- mysql-db-setup
keystone_messaging_enabled: "{{ groups['rabbitmq_all'] is defined }}"
- include: ensure-rabbitmq.yml
vhost_name: "{{ keystone_rabbitmq_vhost }}"
user_name: "{{ keystone_rabbitmq_userid }}"
user_password: "{{ keystone_rabbitmq_password }}"
host_name: groups['keystone_all'][0]
- include: create-grant-db.yml
db_name: "{{ keystone_galera_database }}"
db_password: "{{ keystone_container_mysql_password }}"
host_name: groups['keystone_all'][0]
roles:
- role: "{{ keystone_rolename | default('os_keystone') }}"
vars_files:

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: setting-nodepool-variables.yml
- name: Make /lib/modules accessible on neutron_agent containers
hosts: neutron_agent
user: root
@ -56,57 +58,15 @@
with_items:
- libffi-dev
when: inventory_hostname in groups['neutron_all']
- name: Ensure rabbitmq vhost
rabbitmq_vhost:
name: "{{ neutron_rabbitmq_vhost }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['neutron_all'][0]
tags:
- neutron-rabbitmq
- neutron-rabbitmq-vhost
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ neutron_rabbitmq_userid }}"
password: "{{ neutron_rabbitmq_password }}"
vhost: "{{ neutron_rabbitmq_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['neutron_all'][0]
tags:
- neutron-rabbitmq
- neutron-rabbitmq-user
- name: Create DB for service
mysql_db:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ neutron_galera_database }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['neutron_all'][0]
tags:
- mysql-db-setup
- name: Grant access to the DB for the service
mysql_user:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ neutron_galera_database }}"
password: "{{ neutron_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ neutron_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['neutron_all'][0]
tags:
- mysql-db-setup
- include: ensure-rabbitmq.yml
vhost_name: "{{ neutron_rabbitmq_vhost }}"
user_name: "{{ neutron_rabbitmq_userid }}"
user_password: "{{ neutron_rabbitmq_password }}"
host_name: groups['neutron_all'][0]
- include: create-grant-db.yml
db_name: "{{ neutron_galera_database }}"
db_password: "{{ neutron_container_mysql_password }}"
host_name: groups['neutron_all'][0]
roles:
- role: "{{ neutron_rolename | default('os_neutron') }}"
vars_files:

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include: setting-nodepool-variables.yml
- name: Playbook for deploying nova
hosts: nova_all
user: root
@ -29,80 +31,18 @@
- libffi-dev
- pkg-config
- libvirt-dev
when: inventory_hostname in groups['nova_all']
- name: Ensure rabbitmq vhost
rabbitmq_vhost:
name: "{{ nova_rabbitmq_vhost }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['nova_all'][0]
tags:
- aodh-rabbitmq
- aodh-rabbitmq-vhost
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ nova_rabbitmq_userid }}"
password: "{{ nova_rabbitmq_password }}"
vhost: "{{ nova_rabbitmq_vhost }}"
configure_priv: ".*"
read_priv: ".*"
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == groups['nova_all'][0]
tags:
- aodh-rabbitmq
- aodh-rabbitmq-user
- name: Create DB for service
mysql_db:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ nova_galera_database }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['nova_all'][0]
tags:
- mysql-db-setup
- name: Grant access to the DB for the service
mysql_user:
login_user: "root"
login_password: "secrete"
login_host: "localhost"
name: "{{ nova_galera_database }}"
password: "{{ nova_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ nova_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == groups['nova_all'][0]
tags:
- mysql-db-setup
- name: Create API DB for service
mysql_db:
login_user: "{{ galera_root_user }}"
login_password: "{{ galera_root_password }}"
login_host: "{{ nova_api_galera_address }}"
name: "{{ nova_api_galera_database }}"
state: "present"
when: inventory_hostname == groups['nova_all'][0]
- name: Grant access to the API DB for the service
mysql_user:
login_user: "{{ galera_root_user }}"
login_password: "{{ galera_root_password }}"
login_host: "{{ nova_api_galera_address }}"
name: "{{ nova_api_galera_user }}"
password: "{{ nova_api_container_mysql_password }}"
host: "{{ item }}"
state: "present"
priv: "{{ nova_api_galera_database }}.*:ALL"
with_items:
- "localhost"
- "%"
when: inventory_hostname == groups['nova_all'][0]
when:
- inventory_hostname in groups['nova_all']
- ansible_pkg_mgr == 'apt'
- include: ensure-rabbitmq.yml
vhost_name: "{{ nova_rabbitmq_vhost }}"
user_name: "{{ nova_rabbitmq_userid }}"
user_password: "{{ nova_rabbitmq_password }}"
host_name: groups['nova_all'][0]
- include: create-grant-db.yml
db_name: "{{ nova_galera_database }}"
db_password: "{{ nova_container_mysql_password }}"
host_name: groups['nova_all'][0]
roles:
- role: "{{ nova_rolename | default('os_nova') }}"
vars_files: