ansible-role-container-regi.../zuul.d/playbooks/pre.yml
Alex Schultz 91f652a932 Fixing ci
* adding task names to satisfy lint
* fixing requirements for test setup

Change-Id: Ic7f019c5f58b456cb36c62283bf72a195d82c299
2021-06-28 13:14:27 -06:00

98 lines
2.8 KiB
YAML

---
- hosts: all
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: Set project path fact
set_fact:
container_registry_project_path: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/ansible-role-container-registry'].src_dir }}"
- 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
user:
name: "{{ ansible_user }}"
generate_ssh_key: true
ssh_key_bits: 2048
ssh_key_file: "{{ ansible_user_dir }}/.ssh/id_rsa"
- 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: Ensure output dirs
file:
path: "{{ ansible_user_dir }}/zuul-output/logs"
state: directory
- 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
- name: Ensure virtualenv is installed
include_role:
name: ensure-virtualenv
- name: Set python_v fact to py2 or py3
set_fact:
python_v: "{{ ansible_facts['distribution_major_version'] is version('8', '>=') | ternary('py3', 'py2') }}"
cacheable: true
- name: Install python3-setuptools
package:
name: "python3-setuptools"
state: present
become: true
when: python_v == "py3"
- name: Install python-setuptools
package:
name: "python-setuptools"
state: present
become: true
when: python_v == "py2"
- name: Ensure pbr available
pip:
name: pbr
virtualenv: "{{ ansible_user_dir }}/test-python"
virtualenv_site_packages: true
- name: Setup test-python
pip:
requirements: "{{ container_registry_project_path }}/molecule-requirements.txt"
virtualenv: "{{ ansible_user_dir }}/test-python"
virtualenv_site_packages: true
extra_args: >-
--constraint "{{ container_registry_project_path }}/ansible-requirements.txt"