Correct how the image_serve validation works

It now detects the correct vhost name directly in the httpd
configuration, allowing to avoid some "404" in case we use the IP
directly.

Change-Id: Ieee084c8f232e9bd66abae5596ce69986642f718
(cherry picked from commit cb3658c816)
This commit is contained in:
Cédric Jeanneret 2020-07-30 13:38:39 +02:00 committed by Gael Chamoulaud
parent 81bc1fc95f
commit 459aa4e620
9 changed files with 100 additions and 59 deletions

View File

@ -0,0 +1,21 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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: tripleo-ansible
scm: git
src: https://opendev.org/openstack/tripleo-ansible
version: master
trackbranch: master

View File

@ -1,2 +1,3 @@
---
container_registry_port: 8787
container_registry_httpd_config: "/etc/httpd/conf.d/image-serve.conf"

View File

@ -35,8 +35,28 @@
debug:
msg: "Detected faulty port!"
- name: Run validation for wrong config file
block:
- name: Run validation for wrong config file
include_role:
name: image_serve
vars:
container_registry_httpd_config: /fake-image-serve.conf
rescue:
- name: Clear host errors
meta: clear_host_errors
- name: Status message
debug:
msg: "Detected wrong config file!"
- name: Ensure we detect faulty tree
block:
- name: Stopping httpd
systemd:
name: httpd
state: stopped
- name: run validation for 404
include_role:
name: image_serve

View File

@ -7,9 +7,12 @@ log: true
platforms:
- name: centos7
hostname: centos7
etc_hosts:
undercloud.ctlplane.mydomain.tld: "127.0.0.1"
image: centos:7
override_command: true
command: python -m SimpleHTTPServer 8787
command: /sbin/init
privileged: true
pkg_extras: python-setuptools python-enum34 python-netaddr epel-release ruby PyYAML
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
@ -21,9 +24,12 @@ platforms:
- name: centos8
hostname: centos8
etc_hosts:
undercloud.ctlplane.mydomain.tld: "127.0.0.1"
image: centos:8
override_command: true
command: python3 -m http.server 8787
command: /sbin/init
privileged: true
pkg_extras: python*-setuptools python*-enum34 python*-netaddr ruby epel-release python*-PyYAML
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
@ -35,7 +41,8 @@ provisioner:
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_LIBRARY: "../../../../library"
ANSIBLE_LIBRARY: ../../../../library
ANSIBLE_ROLES_PATH: ../../../../roles/roles.galaxy/tripleo-ansible/tripleo-ansible/tripleo_ansible/roles
scenario:
test_sequence:

View File

@ -17,38 +17,9 @@
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: install hiera
package:
name: hiera
- name: create hiera tree
file:
path: /etc/puppet
state: directory
- name: populate hiera.yaml
copy:
dest: /etc/puppet/hiera.yaml
content: |
:backends:
- yaml
:yaml:
:datadir: "/etc/puppet/"
:hierarchy:
- "common"
- name: populate hiera content
copy:
dest: /etc/puppet/common.yaml
content: |
tripleo_undercloud_conf_file: /undercloud.conf
- name: populate undercloud.conf
copy:
dest: /undercloud.conf
content: |
[DEFAULT]
local_ip = 127.0.0.1
- name: Container registry installation
include_role:
name: tripleo_image_serve
vars:
tripleo_container_registry_host: undercloud.ctlplane.mydomain.tld

View File

@ -1,33 +1,29 @@
---
- name: Get the path of tripleo undercloud config file
become: true
hiera:
name: "tripleo_undercloud_conf_file"
- name: Ensure we have the httpd config
stat:
path: "{{ container_registry_httpd_config }}"
register: registry_config
- name: Get local_ip value from the undercloud.conf file
become: true
validations_read_ini:
path: "{{ tripleo_undercloud_conf_file }}"
section: DEFAULT
key: local_ip
ignore_missing_file: true
register: local_ip
- name: Fail early if no httpd config is present
when: not registry_config.stat.exists
fail:
msg: "Unable to find vhost config {{ container_registry_httpd_config }}. Exiting now."
- name: Set container registry host
set_fact:
container_registry_host: >-
{{ local_ip.value|default('0.0.0.0', true)|ipaddr('address') }}
- name: Extract vhost name from httpd config
command: |
awk -F '[ >:]*' '/VirtualHost/ {print $2; exit}' {{ container_registry_httpd_config }}
register: virthost_name
- name: Ensure port is open
wait_for:
port: "{{ container_registry_port }}"
host: "{{ container_registry_host }}"
host: "{{ virthost_name.stdout }}"
timeout: 10
- name: Ensure registry does answer
uri:
method: HEAD
url: "http://{{ container_registry_host }}:{{ container_registry_port }}/v2/index.json"
url: "http://{{ virthost_name.stdout }}:{{ container_registry_port }}/v2/index.json"
status_code:
- 200
- 204

View File

View File

@ -28,5 +28,15 @@
requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt"
virtualenv: "{{ ansible_user_dir }}/test-python"
virtualenv_site_packages: true
tasks:
- name: Get Ansible Galaxy roles
command: >-
{{ ansible_user_dir }}/test-python/bin/ansible-galaxy install
-fr
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-role-requirements.yml
environment:
ANSIBLE_ROLES_PATH: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/roles/roles.galaxy"
roles:
- role: ensure-docker

View File

@ -3,17 +3,32 @@
- hosts: all
environment:
ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/zuul-output/logs/ansible-execution.log"
pre_tasks:
- name: Set project path fact
set_fact:
tripleo_validations_project_path: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/tripleo-validations'].src_dir }}"
- name: Set role path fact
set_fact:
tripleo_validations_roles_paths:
- "{{ tripleo_validations_project_path }}/roles/roles.galaxy/tripleo-ansible/tripleo_ansible/roles"
- "{{ tripleo_validations_project_path }}/roles/roles.galaxy/tripleo-ansible/tripleo-ansible/tripleo_ansible/roles"
- "{{ tripleo_validations_project_path }}/roles"
- "/usr/share/ansible/roles"
tasks:
- name: Run role test job
shell: |-
. {{ ansible_user_dir }}/test-python/bin/activate
. {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-test-env.rc
. {{ tripleo_validations_project_path }}/ansible-test-env.rc
pytest --color=no \
--html={{ ansible_user_dir }}/zuul-output/logs/reports.html \
--self-contained-html \
--ansible-args='{{ tripleo_job_ansible_args | default("") }}' \
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py
{{ tripleo_validations_project_path }}/tests/test_molecule.py
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/roles/{{ tripleo_validations_role_name }}"
chdir: "{{ tripleo_validations_project_path }}/roles/{{ tripleo_validations_role_name }}"
executable: /bin/bash
changed_when: false
environment:
ANSIBLE_ROLE_PATH: "{{ tripleo_validations_roles_paths | join(':') }}"