openstack-ansible-tests/test-prepare-containers.yml

70 lines
2.4 KiB
YAML

---
# 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: Gather facts for the LXC hosts
hosts: localhost
# This set of tasks runs against localhost
# and requires root access, but tests run as
# the user running the playbook (zuul). As
# such, we use a local connection and become.
connection: local
become: yes
gather_facts: true
tasks:
- include_tasks: "common-tasks/test-set-nodepool-vars.yml"
- import_playbook: destroy_containers.yml
when: destroy_first | default(True) | bool
- name: Playbook for creating containers
hosts: all_containers
# We explicitly do not use 'remote_user: root' here because the
# role totally fails when we do due to the delegation of various
# tasks to localhost for creating the /openstack and /var/lib/lxc
# directories.
# TODO(odyssey4me):
# Figure out whether this issue happens for normal (non localhost)
# delegation, and how to resolve the issue.
become: True
gather_facts: False
any_errors_fatal: true
tasks:
- name: Create containers
include_role:
name: "lxc_container_create"
- name: Wait for container connectivity
wait_for_connection:
connect_timeout: "{{ lxc_container_wait_params.connect_timeout | default(omit) }}"
delay: "{{ lxc_container_wait_params.delay | default(omit) }}"
sleep: "{{ lxc_container_wait_params.sleep | default(omit) }}"
timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}"
vars_files:
- test-vars.yml
# TODO(evrardjp): Move this as an include_role above like the patch
# https://review.openstack.org/525109
# when https://review.openstack.org/#/c/521598 is in,
# to optimize serialization
- name: Execute the openstack-host role on containers
hosts: all_containers
remote_user: root
gather_facts: true
pre_tasks:
- include_tasks: "common-tasks/test-set-nodepool-vars.yml"
roles:
- role: "openstack_hosts"
vars_files:
- test-vars.yml