tobiko/roles/tests/provision.yaml
Eduardo Olivares e21d209587 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>
2021-03-09 13:40:29 +00:00

148 lines
3.6 KiB
YAML

---
- hosts: all
tasks:
- name: 'disable tempfs on Fedora'
become: yes
command: systemctl mask tmp.mount # noqa 303
when: ansible_distribution == 'Fedora'
ignore_errors: yes
- name: Register as user '{{ rh_username }}' and auto-subscribe to available content
become: yes
redhat_subscription:
state: present
username: '{{ rh_username }}'
password: '{{ rh_password }}'
auto_attach: yes
when:
- rh_username is defined
- (rh_username | length) > 0
- hosts: primary
tasks:
- name: "copy /etc/resolv.conf"
become: yes
copy:
src: /etc/resolv.conf
dest: /etc/resolv.conf
owner: root
group: root
mode: '0644'
- name: "make /etc/hosts"
become: yes
template:
src: 'hosts.j2'
dest: '/etc/hosts'
owner: root
mode: '0644'
- name: "make ~/.ssh/config file with all Vagrant nodes"
template:
src: 'ssh_config.j2'
dest: '/home/vagrant/.ssh/config'
owner: vagrant
mode: '0600'
- name: "generate local SSH key '{{ ssh_key_file }}'"
openssh_keypair:
path: '{{ ssh_key_file }}'
type: rsa
size: 4096
state: present
force: no
delegate_to: localhost
- name: "copy '{{ ssh_key_file }}' file to host"
copy:
src: '{{ ssh_key_file }}{{ item }}'
dest: '/home/vagrant/.ssh/id_rsa{{ item }}'
owner: vagrant
group: vagrant
mode: '0600'
loop:
- ''
- '.pub'
- hosts: all
tasks:
- name: "update APT database"
apt:
update_cache: yes
cache_valid_time: 3600
become: yes
when:
- ansible_os_family == 'Debian'
- name: "set authorized SSH key taken from '{{ ssh_key_file }}'"
authorized_key:
user: vagrant
state: present
key: "{{ lookup('file', ssh_key_file + '.pub') }}"
- name: "ensure deploy tools are installed"
become: true
package: name='{{ item }}'
loop:
- git
- rsync
- hosts: primary
tasks:
- name: "check ICMP connectivity"
shell: |
set -xe
ping -c 1 '{{ item.1.ip }}'
ping -c 1 '{{ item.1.hostname }}'
changed_when: false
register: check_icmp_connectivity
loop: '{{ vagrant_nodes | dictsort }}'
- name: "check SSH connectivity via hostname"
shell: |
set -xe
ssh '{{ item.1.ip }}' hostname
ssh '{{ item.1.hostname }}' hostname
ssh '{{ item.0 }}' hostname
changed_when: false
register: check_ssh_connectivity
loop: '{{ vagrant_nodes | dictsort }}'
- name: "set test_inventory_hostvars_yaml fact"
set_fact:
test_inventory_hostvars_yaml: |
---
{% for name, node in (vagrant_nodes | dictsort) %}
{{ name }}:
ansible_host: {{ node.hostname }}
{% endfor %}
- name: "set test_inventory_hostvars fact"
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
roles:
- role: tobiko-inventory
tasks:
- name: "copy '{{ tobiko_src_dir }}' to '{{ tobiko_dir }}'"
synchronize:
src: "{{ tobiko_src_dir | realpath }}/."
dest: "{{ tobiko_dir }}"
use_ssh_args: yes
recursive: yes
rsync_opts:
- '--exclude-from={{ tobiko_src_dir }}/.gitignore'