openstack-ansible-os_octavia/tests/test-octavia.yml
Major Hayden f510d6561c Octavia role hacking
- installs Octavia service in OSA
- adds a test which installs Octavia (but uses noop
  to work around gate limitations)

Co-Authored-By: German Eichberger <German.eichberger@rackspace.com>

Change-Id: Idb419a4ca5daa311d39c90eda5f83412ccf576ad
2017-03-01 12:48:12 -05:00

122 lines
4.1 KiB
YAML

---
# 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.
- name: Test Octavia
hosts: localhost
user: root
gather_facts: false
vars:
env:
OS_ENDPOINT_TYPE: internalURL
OS_INTERFACE: internalURL
OS_USERNAME: admin
OS_PASSWORD: "{{ keystone_auth_admin_password }}"
OS_PROJECT_NAME: admin
OS_TENANT_NAME: admin
OS_AUTH_URL: "http://{{ test_keystone_host }}:5000/v3"
OS_NO_CACHE: 1
OS_USER_DOMAIN_NAME: Default
OS_PROJECT_DOMAIN_NAME: Default
OS_REGION_NAME: RegionOne
tasks:
- name: Install pip requirements
pip:
name: "{{ item }}"
state: "{{ octavia_pip_package_state }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items:
- "python-neutronclient"
- "python-glanceclient"
- "shade"
- name: Ensure public network exists
neutron:
command: create_network
openrc_path: /root/openrc
net_name: "public"
provider_network_type: "flat"
provider_physical_network: "flat"
router_external: True
insecure: "{{ keystone_service_internaluri_insecure }}"
- name: Ensure public subnet exists
neutron:
command: create_subnet
openrc_path: /root/openrc
net_name: "public"
subnet_name: "public-subnet"
cidr: "10.1.3.0/24"
insecure: "{{ keystone_service_internaluri_insecure }}"
- name: Upload image to glance
shell: >-
glance image-create --name amphora-x64-haproxy --visibility private --disk-format qcow2 \
--container-format bare --tags octavia-amphora-image <{{ octavia_system_home_folder }}/amphora-x64-haproxy.qcow2 \
&& touch {{ octavia_system_home_folder }}/image
args:
creates: "{{ octavia_system_home_folder }}/image"
environment: env
when: test_octavia_amphora | bool
- name: Create ssh-key
shell: >
cat /dev/zero | ssh-keygen -q -N ""
args:
creates: /root/.ssh/id_rsa.pub
- name: Upload key to nova
os_keypair:
auth:
auth_url: "{{ keystone_service_adminurl }}"
username: "{{ octavia_service_user_name }}"
password: "{{ octavia_service_password }}"
project_name: "{{ octavia_service_project_name }}"
user_domain_name: "{{ octavia_service_user_domain_id }}"
project_domain_name: "{{ octavia_service_project_domain_id }}"
endpoint_type: "{{ octavia_ansible_endpoint_type }}"
state: present
name: "octavia_key"
public_key_file: "/root/.ssh/id_rsa.pub"
run_once: true
- name: Create a loadbalancer
shell: >
neutron lbaas-loadbalancer-create --name test-lb public-subnet
environment: env
- name: Wait until LB is up
shell: >
neutron lbaas-loadbalancer-show test-lb | grep ONLINE
environment: env
register: lb_up
until: lb_up|success
retries: 100
delay: 5
- name: Create a listener
shell: >
neutron lbaas-listener-create --loadbalancer test-lb --protocol HTTP --protocol-port 80 --name listener
environment: env
- name: Curl the Listener
shell: >
curl -s -o /dev/null -w "%{http_code}" http://`neutron lbaas-loadbalancer-show test-lb | awk '/ vip_address / {print $4}'`
environment: env
register: http_status_code
when: test_octavia_amphora | bool
- name: Check that we got 503
assert:
that:
- "'503' in http_status_code.stdout"
when: test_octavia_amphora | bool
vars_files:
- common/test-vars.yml