Browse Source

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>
changes/99/776499/16
Eduardo Olivares 3 months ago
parent
commit
e21d209587
10 changed files with 57 additions and 17 deletions
  1. +8
    -0
      infrared_plugin/plugin.spec
  2. +11
    -6
      roles/tests/Vagrantfile
  3. +4
    -2
      roles/tests/provision.yaml
  4. +1
    -2
      roles/tests/test_infrared_plugin.yaml
  5. +1
    -1
      roles/tobiko-common/defaults/main.yaml
  6. +7
    -0
      roles/tobiko-configure/defaults/main.yaml
  7. +11
    -0
      roles/tobiko-configure/tasks/main.yaml
  8. +2
    -1
      roles/tobiko-inventory/defaults/main.yaml
  9. +3
    -3
      roles/tobiko-inventory/tasks/main.yaml
  10. +9
    -2
      roles/tobiko-inventory/templates/test_inventory.j2

+ 8
- 0
infrared_plugin/plugin.spec 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:


+ 11
- 6
roles/tests/Vagrantfile 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,


+ 4
- 2
roles/tests/provision.yaml 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'

+ 1
- 2
roles/tests/test_infrared_plugin.yaml 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:


+ 1
- 1
roles/tobiko-common/defaults/main.yaml 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'


+ 7
- 0
roles/tobiko-configure/defaults/main.yaml 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: ''

+ 11
- 0
roles/tobiko-configure/tasks/main.yaml 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: |


+ 2
- 1
roles/tobiko-inventory/defaults/main.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'

+ 3
- 3
roles/tobiko-inventory/tasks/main.yaml 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:


+ 9
- 2
roles/tobiko-inventory/templates/test_inventory.j2 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 %}

Loading…
Cancel
Save