From f4893b621fe0afad884b3dfb166926e16be16c0e Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 22 Mar 2016 12:11:34 +0000 Subject: [PATCH] Simplify test inventory The previous inventory was 'dynamic' in that the host/group information was added through a playbook. This then required the playbook implementing the inventory to be executed if the deployer wished to test any single playbook. This implements a static inventory and group_vars to achieve the same result, simplifying the test implementation and providing greater flexibility when executing the test playbooks. Change-Id: Ia5b35efd42955cc840990e798eee96a79926b134 --- tests/group_vars/all_containers.yml | 27 +++++++++++++++++ tests/group_vars/designate_all.yml | 17 +++++++++++ tests/inventory | 44 +++++++++++++++++++++++++++ tests/test-include-inventory.yml | 46 ----------------------------- tests/test-install-designate.yml | 7 ----- tests/test-install-infra.yml | 7 ----- tests/test-install-keystone.yml | 7 ----- tests/test-prepare-containers.yml | 7 ----- 8 files changed, 88 insertions(+), 74 deletions(-) create mode 100644 tests/group_vars/all_containers.yml create mode 100644 tests/group_vars/designate_all.yml delete mode 100644 tests/test-include-inventory.yml diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml new file mode 100644 index 0000000..4cc9794 --- /dev/null +++ b/tests/group_vars/all_containers.yml @@ -0,0 +1,27 @@ +--- +# Copyright 2016, 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. + +ansible_ssh_host: "{{ ansible_host }}" +container_name: "{{ inventory_hostname }}" +container_networks: + management_address: + address: "{{ ansible_host }}" + bridge: "lxcbr0" + interface: "eth1" + netmask: "255.255.252.0" + type: "veth" +physical_host: localhost +properties: + service_name: "{{ inventory_hostname }}" diff --git a/tests/group_vars/designate_all.yml b/tests/group_vars/designate_all.yml new file mode 100644 index 0000000..8499fe2 --- /dev/null +++ b/tests/group_vars/designate_all.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2016, 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. + +properties: + service_name: designate diff --git a/tests/inventory b/tests/inventory index 6c0833a..4ab6e93 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,46 @@ [all] localhost ansible_connection=local ansible_become=True +infra1 ansible_host=10.100.100.101 ansible_become=True +openstack1 ansible_host=10.100.100.102 ansible_become=True + +[hosts] +localhost + +[all_containers] +infra1 +openstack1 + +[designate_all:children] +designate_api +designate_central +designate_mdns +designate_pool_manager +designate_sink + +[designate_api] +openstack1 + +[designate_central] +openstack1 + +[designate_mdns] +openstack1 + +[designate_pool_manager] +openstack1 + +[designate_sink] +openstack1 + +[keystone_all] +openstack1 + +[service_all:children] +rabbitmq_all +galera_all + +[rabbitmq_all] +infra1 + +[galera_all] +infra1 diff --git a/tests/test-include-inventory.yml b/tests/test-include-inventory.yml deleted file mode 100644 index 2fc4746..0000000 --- a/tests/test-include-inventory.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -# Copyright 2016, 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. - -# Inventory is being pre-loaded using a post tasks instead of through a dynamic -# inventory system. While this is not a usual method for deployment it's being -# done for functional testing. - -- name: Create container hosts - add_host: - groups: "{{ item.groups }}" - hostname: "{{ item.name }}" - inventory_hostname: "{{ item.name }}" - ansible_ssh_host: "{{ item.address }}" - ansible_become: true - properties: - service_name: "{{ item.service }}" - container_networks: - management_address: - address: "{{ item.address }}" - bridge: "lxcbr0" - interface: "eth1" - netmask: "255.255.252.0" - type: "veth" - physical_host: localhost - container_name: "{{ item.name }}" - with_items: - - name: "infra1" - service: "infra1" - address: "10.100.100.101" - groups: "all,all_containers,rabbitmq_all,galera_all,service_all" - - name: "openstack1" - service: "openstack1" - address: "10.100.100.102" - groups: "all,all_containers,keystone_all,designate_all,designate_api,designate_central,designate_pool_manager,designate_mdns,designate_sink" diff --git a/tests/test-install-designate.yml b/tests/test-install-designate.yml index dd7ff2e..d0c979f 100644 --- a/tests/test-install-designate.yml +++ b/tests/test-install-designate.yml @@ -13,13 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Prepare the inventory - hosts: localhost - connection: local - become: yes - tasks: - - include: test-include-inventory.yml - - name: Playbook for deploying designate hosts: designate_all user: root diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml index a7e2cf7..d8e0235 100644 --- a/tests/test-install-infra.yml +++ b/tests/test-install-infra.yml @@ -13,13 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Prepare the inventory - hosts: localhost - connection: local - become: yes - tasks: - - include: test-include-inventory.yml - - name: Playbook for deploying infra services hosts: service_all user: root diff --git a/tests/test-install-keystone.yml b/tests/test-install-keystone.yml index 6bd946b..9645f73 100644 --- a/tests/test-install-keystone.yml +++ b/tests/test-install-keystone.yml @@ -13,13 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Prepare the inventory - hosts: localhost - connection: local - become: yes - tasks: - - include: test-include-inventory.yml - - name: Playbook for deploying keystone hosts: keystone_all user: root diff --git a/tests/test-prepare-containers.yml b/tests/test-prepare-containers.yml index 7aac7a3..932d681 100644 --- a/tests/test-prepare-containers.yml +++ b/tests/test-prepare-containers.yml @@ -13,13 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Prepare the inventory - hosts: localhost - connection: local - become: yes - tasks: - - include: test-include-inventory.yml - - name: Playbook for creating containers hosts: all_containers connection: local