Set undercloud_ssh_hostname on tobiko.conf

Tobiko IR tasks failed on some downstream environments when the
undercloud hostname was not undercloud-0

When this happens, the tobiko IR command can be executed with
--undercloud-host or --underclout-ssh-host options

RHOSENTDFG-1695

Change-Id: Ife055b62682044bdc446e6447ef9da562fe4bb73
Co-Author: Eduardo Olivares Toledo <eolivare@redhat.com>
This commit is contained in:
Eduardo Olivares 2021-02-18 18:11:12 +01:00
parent b9868d44ca
commit e21d209587
10 changed files with 57 additions and 17 deletions

View File

@ -117,6 +117,14 @@ subparsers:
type: Value
help: Test case timeout in seconds
ansible_variable: test_case_timeout
undercloud_host:
type: Value
help: inventory hostname of the undercloud host
ansible_variable: undercloud_hostname
undercloud_ssh_host:
type: Value
help: hostname or IP address to be used to connect to undercloud host
ansible_variable: undercloud_ssh_hostname
- title: Run stage
options:

View File

@ -27,8 +27,12 @@ UPPER_CONSTRAINTS_FILE = ENV.fetch(
NODES = {
'primary' => {'ip' => '172.18.161.6',
'hostname' => 'primary'},
'secondary' => {'ip' => '172.18.161.7',
'hostname' => 'secondary'},
'secundary' => {'ip' => '172.18.161.7',
'hostname' => 'secundary'},
}
GROUPS = {
'undercloud' => ['secundary']
}
@ -96,10 +100,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
libvirt.memory = MEMORY
end
# Spawn secondary VMs
config.vm.define 'secondary' do |node|
node.vm.hostname = NODES['secondary']['hostname']
node.vm.network "private_network", ip: NODES['secondary']['ip']
# Spawn secundary VMs
config.vm.define 'secundary' do |node|
node.vm.hostname = NODES['secundary']['hostname']
node.vm.network "private_network", ip: NODES['secundary']['ip']
end
# Spawn primary VM and run test cases on it
@ -113,6 +117,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
ansible.limit = "all"
ansible.extra_vars = {
'vagrant_nodes' => NODES,
'vagrant_groups' => GROUPS,
'ssh_key_file' => SSH_KEY_FILE,
'rh_username' => RH_USERNAME,
'rh_password' => RH_PASSWORD,

View File

@ -126,8 +126,10 @@
set_fact:
test_inventory_hostvars:
'{{ test_inventory_hostvars_yaml | from_yaml }}'
test_inventory_groups: '{{ vagrant_groups }}'
- debug: var=test_inventory_hostvars
- debug: var=test_inventory_groups
- hosts: primary
@ -138,8 +140,8 @@
- name: "copy '{{ tobiko_src_dir }}' to '{{ tobiko_dir }}'"
synchronize:
src: "{{ tobiko_src_dir | realpath }}/."
dest: "{{ tobiko_dir | realpath }}"
dest: "{{ tobiko_dir }}"
use_ssh_args: yes
recursive: yes
rsync_opts:
- '--exclude-from={{ tobiko_src_dir | realpath }}/.gitignore'
- '--exclude-from={{ tobiko_src_dir }}/.gitignore'

View File

@ -36,10 +36,9 @@
register: include_platform_vars
- name: "run Tox InfraRed plugin"
command:
shell:
cmd: >
'{{ tox_executable }}' -e infrared --
--host secondary
--collect-dir '{{ test_collect_dir }}'
chdir: '{{ test_dir }}'
environment:

View File

@ -8,7 +8,7 @@ test_become: '{{ not (test_no_become | bool) }}'
# --- Test deploy options -----------------------------------------------------
test_deploy_home: '{{ ansible_user_dir | realpath }}/src'
test_deploy_home: '{{ ansible_user_dir }}/src'
git_base: 'https://opendev.org'

View File

@ -9,9 +9,16 @@ test_default_conf:
testcase:
timeout: "{{ test_case_timeout }}"
tripleo:
undercloud_ssh_hostname: "{{ undercloud_ssh_hostname }}"
test_log_debug: false
test_case_timeout: 7200.
# OpenStack client credentials
stackrc_file: '{{ ansible_user_dir }}/overcloudrc'
undercloud_hostname: '{{ groups.get("undercloud", []) | first | default("undercloud-0") }}'
undercloud_ssh_hostname: ''

View File

@ -1,5 +1,16 @@
---
- name: "pick undercloud SSH shotname from inventory"
set_fact:
undercloud_ssh_hostname: >-
{{ hostvars[undercloud_hostname].ansible_hostname |
default(undercloud_hostname) }}
when:
- (undercloud_ssh_hostname | length) == 0
- (undercloud_hostname | length) > 0
- undercloud_hostname in hostvars
- name: "list configuration options"
set_fact:
test_conf_yaml: |

View File

@ -2,4 +2,5 @@
test_inventory_user: '{{ ansible_user }}'
test_inventory_hostvars: {}
test_inventory_file: '{{ test_dir | realpath }}/ansible_hosts'
test_inventory_groups: {}
test_inventory_file: '{{ test_dir }}/ansible_hosts'

View File

@ -45,15 +45,15 @@
- hostvars[hostname][varname] is defined
- test_inventory_hostvars[hostname][varname] is not defined
- debug: var=test_inventory_hostvars
- debug: var=test_inventory_file
- name: "ensures inventory directory exists"
file:
path: '{{ test_inventory_file | dirname }}'
state: directory
- debug: var=test_inventory_hostvars
- debug: var=test_inventory_groups
- name: "writes inventory file to: '{{ test_inventory_file }}'"
template:

View File

@ -1,8 +1,15 @@
[all]
{% for name, vars in (test_inventory_hostvars | dictsort) %}
{{ name }} ansible_host={{ vars.ansible_host }}
{% for host, vars in (test_inventory_hostvars | dictsort) %}
{{ host }} ansible_host={{ vars.ansible_host }}
{% endfor %}
[all:vars]
ansible_python_interpreter = {{ test_inventory_python_interpreter }}
ansible_user = {{ test_inventory_user }}
{% for group, hosts in (test_inventory_groups | dictsort) %}
[{{ group }}]
{% for host in hosts %}
{{ host }}
{% endfor %}
{% endfor %}