validations-common/tests/prepare-test-host.yml
Gael Chamoulaud (Strider) ab26d8263a
[Testing Infra] Apply here the improvements done to tripleo-validations
This patch brings out the improvements done from tripleo-validations to
validations-common regarding the molecule testing infrastructure with
the UBI8 images.

This patch integrates molecule fix after release of cryptography3.4.
See https://review.opendev.org/c/openstack/tripleo-validations/+/774747

Related-Bug: #1915101
Co-Authored-By: David Vallee Delisle <dvd@redhat.com>
Change-Id: I2e5ebebdd48e4013aa87868a22807e91feb3ffab
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-04-01 10:16:07 +02:00

67 lines
2.0 KiB
YAML

---
# 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: pre prepare
hosts: all
gather_facts: false
tasks:
- name: set basic user fact
fail:
msg: >-
The variable `ansible_user` set this option and try again. On the
CLI this can be defined with "-e ansible_user=${USER}"
when:
- ansible_user is undefined
- name: set basic home fact
fail:
msg: >-
The variable `ansible_user_dir` set this option and try again. On
the CLI this can be defined with "-e ansible_user_dir=${HOME}"
when:
- ansible_user_dir is undefined
- name: Ensure the user has a .ssh directory
file:
path: "{{ ansible_user_dir }}/.ssh"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: "0700"
- name: Create ssh key pair
openssh_keypair:
path: "{{ ansible_user_dir }}/.ssh/id_rsa"
size: 2048
- name: Slurp pub key
slurp:
src: "{{ ansible_user_dir ~ '/.ssh/id_rsa.pub' }}"
register: pub_key
- name: Ensure can ssh to can connect to localhost
authorized_key:
user: "{{ ansible_user }}"
key: "{{ pub_key['content'] | b64decode }}"
- name: Get the zuul/zuul-jobs repo
git:
repo: https://opendev.org/zuul/zuul-jobs
dest: "{{ ansible_user_dir }}/zuul-jobs"
version: master
force: true