openstack-ansible-tests/common-tasks/test-set-nodepool-vars.yml
Major Hayden 391a951f70
Improve idempotency
These discovery tasks always show up as "changed" in the Ansible
output. This patch ensures that they are not labeled as changed
when they are run.

The patch also fixes the idempotency check grep so that it works
properly with multiple hosts. Previously, if *any* of the hosts
finished with no changes/failures, the entire job was marked as
passing the idempotency tests.

Depends-On: I17748b0dd2307fd9bee705140c67883140090298
Change-Id: Ie414d32d39fdeeedd77fe94b57a09ba344084ec1
Signed-off-by: Major Hayden <major@mhtx.net>
2018-03-07 16:02:33 -06:00

145 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: Check if this is an OpenStack-CI nodepool instance
stat:
path: /etc/nodepool
register: nodepool
delegate_to: localhost
- name: Discover the lxc_image_cache_server value when in nodepool
shell: |
source /etc/ci/mirror_info.sh
echo "http://${NODEPOOL_MIRROR_HOST}:8080/images.linuxcontainers/"
args:
executable: /bin/bash
register: lxc_reverse_proxy
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool
tags:
- skip_ansible_lint
- name: Set a fact to override lxc_image_cache_server value when in nodepool
set_fact:
lxc_image_cache_server_mirrors: "{{ [lxc_reverse_proxy.stdout] }}"
when:
- nodepool.stat.exists | bool
- name: Discover the UCA repo URL value when in nodepool
shell: |
source /etc/ci/mirror_info.sh
echo "${NODEPOOL_UCA_MIRROR}"
args:
executable: /bin/bash
register: uca_repo_url
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool
tags:
- skip_ansible_lint
- name: Set a fact to override uca_apt_repo_url value when in nodepool
set_fact:
uca_apt_repo_url: "{{ uca_repo_url.stdout }}"
when:
- ansible_pkg_mgr == 'apt'
- nodepool.stat.exists | bool
- name: Discover the CentOS mirror URL when in nodepool
shell: |
source /etc/ci/mirror_info.sh
echo "${NODEPOOL_CENTOS_MIRROR}"
args:
executable: /bin/bash
register: centos_mirror_url
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr in ['yum', 'dnf']
- nodepool.stat.exists | bool
tags:
- skip_ansible_lint
# NOTE(mhayden): This mirror URL already has the '/centos' URI added.
- name: Set a fact to override the CentOS mirror URL when in nodepool
set_fact:
openstack_hosts_centos_mirror_url: "{{ centos_mirror_url.stdout }}"
when:
- ansible_pkg_mgr in ['yum', 'dnf']
- nodepool.stat.exists | bool
- name: Discover the openSUSE mirror URL when in nodepool
shell: |
source /etc/ci/mirror_info.sh
echo "${NODEPOOL_OPENSUSE_MIRROR}"
args:
executable: /bin/bash
register: _opensuse_mirror
delegate_to: localhost
changed_when: false
when:
- ansible_pkg_mgr == 'zypper'
- nodepool.stat.exists | bool
tags:
- skip_ansible_lint
- name: Set a fact to override the openSUSE mirror URL when in nodepool
set_fact:
opensuse_mirror: "{{ _opensuse_mirror.stdout }}"
# OpenStack infra doesn't mirror OBS repos so use the upstream one
opensuse_mirror_obs: "http://download.opensuse.org"
when:
- ansible_pkg_mgr == 'zypper'
- nodepool.stat.exists | bool
- name: Set the files to copy into the container cache for OpenStack-CI instances
set_fact:
lxc_container_cache_files:
- { src: '/etc/pip.conf', dest: '/etc/pip.conf' }
when:
- nodepool.stat.exists | bool
- name: Set a fact to disable yum's fastestmirror support when in nodepool
set_fact:
openstack_hosts_enable_yum_fastestmirror: no
when:
- nodepool.stat.exists | bool
- name: Discover the OpenStack-Infra pypi/wheel mirror
shell: |
source /etc/ci/mirror_info.sh
echo ${NODEPOOL_PYPI_MIRROR}
echo ${NODEPOOL_WHEEL_MIRROR}
args:
executable: /bin/bash
register: _pypi_wheel_mirror
delegate_to: localhost
changed_when: false
when:
- nodepool.stat.exists | bool
- name: Enable the use of the OpenStack-Infra pypi/wheel mirror
set_fact:
pip_default_index: "{{ _pypi_wheel_mirror.stdout_lines[0] }}"
pip_links:
- name: "infra_wheel_mirror"
link: "{{ _pypi_wheel_mirror.stdout_lines[1] }}"
when:
- nodepool.stat.exists | bool