Design new role for zuul-based reproducer
This role creates a minimal bash script to launch the reproducer via zuul/nodepool and friends with the same variables as used in the CI job. Depends-On: https://review.rdoproject.org/r/#/c/18664/ Depends-On: https://review.openstack.org/#/c/635550 Story: https://tree.taiga.io/project/tripleo-ci-board/task/607 Change-Id: I9cdfa3e9d710257cdcd15979dcf0c65222ff3ac6
This commit is contained in:
parent
b34a511276
commit
891a714889
@ -100,6 +100,11 @@
|
||||
name: create-reproducer-script
|
||||
when: ansible_env.TOCI_JOBTYPE is defined
|
||||
|
||||
|
||||
- name: Create the zuul-based reproducer script
|
||||
include_role:
|
||||
name: create-zuul-based-reproducer
|
||||
|
||||
- name: upload to the artifact server using pubkey auth
|
||||
shell: rsync -av --quiet -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" {{ artcl_collect_dir }}/ {{ artcl_rsync_path }}/{{ lookup('env', 'BUILD_TAG') }}
|
||||
async: "{{ artcl_publish_timeout }}"
|
||||
|
83
roles/create-zuul-based-reproducer/README.md
Normal file
83
roles/create-zuul-based-reproducer/README.md
Normal file
@ -0,0 +1,83 @@
|
||||
create-zuul-based-reproducer
|
||||
============================
|
||||
|
||||
This role creates a launcher-playbook and a wrapper Bash script to
|
||||
allow users to reproduce CI jobs using a local Zuul installation.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
For the defaults of these variables, see the defaults/main.yml file in this role.
|
||||
|
||||
* reproducer_zuul_based_quickstart_script: Bash script to kick the generated launcher playbook
|
||||
* reproducer_zuul_based_quickstart_readme_file: The documentation file with user instructions
|
||||
* reproducer_zuul_based_launcher_playbook: Template to create a launcher playbook with variable
|
||||
to reproduce the job run
|
||||
* launcher_env_setup_playbook: Template to create a playbook to set up the launcher environment
|
||||
From the extras-common role:
|
||||
* artcl_collect_dir: "{{ local_working_dir }}/collected_files"
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
The role is run within the collect-logs role.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
This role generates a launcher-playbook:
|
||||
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Add the localhost to the inventory
|
||||
add_host:
|
||||
name: "localhost"
|
||||
groups: "localhost"
|
||||
ansible_host: 127.0.0.1
|
||||
ansible_connection: local
|
||||
|
||||
- name: Add the primary to the inventory
|
||||
add_host:
|
||||
name: "localhost"
|
||||
groups: "primary"
|
||||
ansible_fqdn: "localhost"
|
||||
ansible_user: "{{ lookup('env', 'USER') }}"
|
||||
ansible_private_key_file: "/home/{{ ansible_user }}/.ssh/{{ user_pri_key | default('id_rsa') }}"
|
||||
ansible_host: "localhost"
|
||||
|
||||
- import_playbook: playbooks/pre.yaml
|
||||
|
||||
- hosts: localhost
|
||||
vars:
|
||||
depends_on:
|
||||
- https://review.openstack.org/xxxxxx
|
||||
zuul_yaml: >-
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- tripleo-ci-centos-7-multinode-1ctlr-featureset010-dlrn-hash-tag
|
||||
|
||||
- job:
|
||||
name: tripleo-ci-centos-7-multinode-1ctlr-featureset010-dlrn-hash-tag
|
||||
parent: tripleo-ci-centos-7-multinode-1ctlr-featureset010
|
||||
vars:
|
||||
mirror_fqdn: mirror.regionone.rdo-cloud.rdoproject.org
|
||||
featureset_override:
|
||||
dlrn_hash_tag:
|
||||
8127e43f39ac9b9e14d4a5a10bcbf41f122f32d7_d2efe5df
|
||||
dlrn_hash_tag_newest:
|
||||
ca4990cebac0be87ee4a7273f519574bc1027c8f_a1ff18dc
|
||||
tasks:
|
||||
- include_role:
|
||||
name: ansible-role-tripleo-ci-reproducer
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Apache 2.0
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
OpenStack
|
5
roles/create-zuul-based-reproducer/defaults/main.yml
Normal file
5
roles/create-zuul-based-reproducer/defaults/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
reproducer_zuul_based_quickstart_script: reproducer-zuul-based-quickstart.sh.j2
|
||||
reproducer_zuul_based_quickstart_readme_file: "{{ artcl_collect_dir }}/README-reproducer-zuul-based-quickstart.html"
|
||||
reproducer_zuul_based_launcher_playbook: launcher-playbook.yaml.j2
|
||||
launcher_env_setup_playbook: launcher-env-setup-playbook.yaml.j2
|
3
roles/create-zuul-based-reproducer/meta/main.yml
Normal file
3
roles/create-zuul-based-reproducer/meta/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- extras-common
|
100
roles/create-zuul-based-reproducer/tasks/main.yml
Normal file
100
roles/create-zuul-based-reproducer/tasks/main.yml
Normal file
@ -0,0 +1,100 @@
|
||||
---
|
||||
- name: Check if collect directory exists
|
||||
stat:
|
||||
path: "{{ artcl_collect_dir }}"
|
||||
register: collect_dir
|
||||
|
||||
- name: Create collect directory
|
||||
file:
|
||||
path: "{{ artcl_collect_dir }}"
|
||||
state: directory
|
||||
when: not collect_dir.stat.exists
|
||||
|
||||
- name: Create the reproducer-quickstart directory
|
||||
file:
|
||||
path: "{{ artcl_collect_dir }}/reproducer-quickstart"
|
||||
state: directory
|
||||
|
||||
- name: Create the reproducer-quickstart/scripts directory
|
||||
file:
|
||||
path: "{{ artcl_collect_dir }}/reproducer-quickstart/scripts"
|
||||
state: directory
|
||||
|
||||
- name: Copy the generated toci templates and files
|
||||
copy:
|
||||
src: "/home/{{ undercloud_user }}/src/git.openstack.org/openstack/tripleo-ci/{{ item }}"
|
||||
dest: "{{ artcl_collect_dir }}/reproducer-quickstart/{{ item }}"
|
||||
mode: 0755
|
||||
with_items:
|
||||
- "toci_gate_test.sh"
|
||||
- "toci_quickstart.sh"
|
||||
- "scripts/common_vars.bash"
|
||||
- "scripts/oooq_common_functions.sh"
|
||||
|
||||
- name: Check if featureset-override exists
|
||||
stat:
|
||||
path: "/home/{{ undercloud_user }}/src/git.openstack.org/openstack/tripleo-ci/featureset-override.yaml"
|
||||
register: featureset_override_file
|
||||
|
||||
- name: Add the featureset-override if it exists
|
||||
copy:
|
||||
src: "/home/{{ undercloud_user }}/src/git.openstack.org/openstack/tripleo-ci/featureset-override.yaml"
|
||||
dest: "{{ artcl_collect_dir }}/reproducer-quickstart/featureset-override.yaml"
|
||||
mode: 0755
|
||||
when: featureset_override_file.stat.exists
|
||||
|
||||
- name: Check if releases.sh file exits
|
||||
stat:
|
||||
path: '/home/{{ undercloud_user}}/workspace/logs/releases.sh'
|
||||
register: releases_file_result
|
||||
|
||||
- name: Get releases.sh file output
|
||||
set_fact:
|
||||
releases_file_output: "{{ lookup('file', '/home/{{ undercloud_user}}/workspace/logs/releases.sh') | replace('export' , ' export') }}"
|
||||
when: releases_file_result.stat.exists
|
||||
|
||||
- name: Get featureset-override file output
|
||||
set_fact:
|
||||
featureset_override_file_output: "{{ lookup('file', '/home/{{ undercloud_user }}/src/git.openstack.org/openstack/tripleo-ci/featureset-override.yaml') }}"
|
||||
when: featureset_override_file.stat.exists
|
||||
|
||||
- name: Create the zuul-based launcher-env-setup-playbook from template
|
||||
template:
|
||||
src: "{{ launcher_env_setup_playbook }}"
|
||||
dest: "{{ artcl_collect_dir }}/launcher-env-setup-playbook.yaml"
|
||||
mode: 0755
|
||||
|
||||
- name: Create the zuul-based launcher-playbook from template
|
||||
template:
|
||||
src: "{{ reproducer_zuul_based_launcher_playbook }}"
|
||||
dest: "{{ artcl_collect_dir }}/launcher-playbook.yaml"
|
||||
mode: 0755
|
||||
|
||||
- name: Create the zuul-based reproducer file from template
|
||||
template:
|
||||
src: "{{ reproducer_zuul_based_quickstart_script }}"
|
||||
dest: "{{ artcl_collect_dir }}/reproducer-zuul-based-quickstart.sh"
|
||||
mode: 0755
|
||||
|
||||
- name: Copy the tripleo-quickstart install-deps script
|
||||
copy:
|
||||
src: "/home/{{ undercloud_user }}/src/git.openstack.org/openstack/tripleo-quickstart/{{ item }}"
|
||||
dest: "{{ artcl_collect_dir }}/{{ item }}"
|
||||
mode: 0755
|
||||
with_items:
|
||||
- "install-deps.sh"
|
||||
|
||||
- name: Tar the files needed for the zuul-based reproducer script
|
||||
archive:
|
||||
path:
|
||||
- "{{ artcl_collect_dir }}/launcher-env-setup-playbook.yaml"
|
||||
- "{{ artcl_collect_dir }}/launcher-playbook.yaml"
|
||||
- "{{ artcl_collect_dir }}/reproducer-zuul-based-quickstart.sh"
|
||||
- "{{ artcl_collect_dir }}/install-deps.sh"
|
||||
dest: "{{ artcl_collect_dir }}/reproducer-zuul-based-quickstart.tar"
|
||||
mode: 0755
|
||||
|
||||
- name: Create zuul-based reproducer script documentation from template
|
||||
template:
|
||||
src: README-reproducer-zuul-based-quickstart.html.j2
|
||||
dest: "{{ reproducer_zuul_based_quickstart_readme_file }}"
|
@ -0,0 +1,138 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>WARNING - WIP - NOT FOR GENERAL USE - README for Quickstart Job Zuul-based Reproducer Script</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1> WARNING - WIP - NOT FOR GENERAL USE - How to reproduce a job result using the Zuul-based reproducer playbooks and script</h1>
|
||||
<p>Check the top-level logs directory for a tar file <b>reproducer-zuul-based-quickstart.tar</b>.
|
||||
This tar archive contains three files:
|
||||
<ul>
|
||||
<li><code>launcher-env-setup-playbook.yaml</code> - a playbook to clone repos and set up
|
||||
an Ansible environment to launch jobs</li>
|
||||
<li><code>launcher-playbook.yaml - a playbook that installs and starts up Zuul, Gerrit and
|
||||
other required services, and also creates and launches a reproducer job using
|
||||
the same dlrn hashes as in CI</code></li>
|
||||
<li><code>reproducer-zuul-based-quickstart.sh - a Bash script to provide an interface
|
||||
to run the above playbooks with various options</code></li>
|
||||
</ul>
|
||||
Running these playbooks will set up Zuul, Gerrit, and related services in containers
|
||||
on the local system, and will then create a reproducer job which can be run on a
|
||||
cloud personal tenant or via libvirt on the local system.
|
||||
If no <b>reproducer-zuul-based-quickstart.tar</b> file is found, that usually means an
|
||||
infra failure before Quickstart could start or a problem in collecting logs.
|
||||
Check on IRC Freenode channel <i>#tripleo</i> to see if there's an ongoing infra
|
||||
issue.</p>
|
||||
|
||||
<h1>Setting up to run the Zuul-based reproducer</h1>
|
||||
<p>
|
||||
Prior to running the Zuul-based reproducer, the following setup steps are needed -
|
||||
( only need to be done once per local system):
|
||||
<ul>
|
||||
<li>Create a clouds.yaml - for example:
|
||||
<pre>
|
||||
<code>mkdir -p ~/.config/openstack
|
||||
vi ~/.config/openstack/clouds.yaml
|
||||
clouds:
|
||||
rdo-cloud:
|
||||
identity_api_version: 3
|
||||
region_name: regionOne
|
||||
auth:
|
||||
auth_url: https://phx2.cloud.rdoproject.org:13000/v3
|
||||
password: xxxxxxx
|
||||
project_name: user_name
|
||||
username: user_name
|
||||
user_domain_name: Default
|
||||
project_domain_name: Default
|
||||
regions:
|
||||
- name: regionOne
|
||||
values:
|
||||
networks:
|
||||
- name: 38.145.32.0/22
|
||||
routes_externally: true
|
||||
- name: private
|
||||
</code>
|
||||
</pre>
|
||||
Note that you will need a network named 'private' in the tenant connected to an
|
||||
external router.</li>
|
||||
<li>Create an ssh key pair without a pass phrase:
|
||||
The ssh key pair is configurable - see variables <code>ssh_path</code> and
|
||||
<code>user_pri_key</code>. The default key is:<code>~/.ssh/id_rsa[.pub]</code></li>
|
||||
<li>Check that you have access to the publicly shared nodepool images:
|
||||
There should be one image for CentOS 7, and one for Fedora 28.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h1>Running the Zuul-based reproducer - using the Bash script</h1>
|
||||
<p>
|
||||
wget the <b>reproducer-zuul-based-quickstart.tar</b> file. Note that
|
||||
the <code>launcher-env-setup-playbook.yaml</code> will set up
|
||||
clone repos and set up 'roles', 'playbooks', and 'library' directories
|
||||
from which the tasks will be executed.
|
||||
Once the files are extracted from the archive, you can run the Bash script
|
||||
with the various options. Run the script with <code>--help</code> option to
|
||||
output a list of available run options.
|
||||
</p>
|
||||
|
||||
<h1>Running the Zuul-based reproducer - using the playbooks directly</h1>
|
||||
<p>
|
||||
The Bash script is not required although it is the supported path.
|
||||
The playbooks can be run directly using <code>ansible-playbook</code>.
|
||||
The Bash script contains some package installation and Docker user/group setup
|
||||
that you will need to cover prior to running the playbooks directly.
|
||||
Please see the Bash scripts for details, especially if you are running the
|
||||
reproducer for the first time on teh local environment.
|
||||
The playbooks can be run as follows:
|
||||
<ul>
|
||||
<li><code>ansible-playbook ./launcher-env-setup-playbook.yaml</code></li>
|
||||
<li><code>ansible-playbook ./launcher-playbook.yaml $OPTIONS</code></li>
|
||||
</ul>
|
||||
The <code>launcher-playbook.yaml</code> includes comments on how to run the playbook
|
||||
with the same options listed in the Bash script section above.
|
||||
</p>
|
||||
|
||||
<h1>Ansible tags and running repeatedly</h1>
|
||||
<p>
|
||||
The Bash scripts runs with <code>--tags all</code> passed to the
|
||||
<code>launcher-playbook.yaml</code>.
|
||||
After the initial docker setup has run, it is not necessary to run through
|
||||
those setup steps for every reproducer. The <code>launcher-playbook.yaml</code>
|
||||
can be run with <code>--skip-tags start</code> after the initial run.
|
||||
</p>
|
||||
|
||||
<h1>Monitoring the launched job</h1>
|
||||
<p>
|
||||
The <code>launcher-playbook.yaml</code> will create and push a job
|
||||
to a test1 testproject repo in a temp directory. This job will start and the
|
||||
related Zuul infrastructure logs can be viewed in:</br>
|
||||
<pre>
|
||||
<code>cd ~/tripleo-ci-reproducer
|
||||
docker-compose logs --tail=10 -f
|
||||
# Just view the scheduler and executor logs:
|
||||
docker-compose logs --tail=10 -f scheduler executor</code>
|
||||
</pre>
|
||||
</br>
|
||||
To see the job progress, you can access the web consoles of:
|
||||
<ul>
|
||||
<li>Gerrit: http://localhost:8080</li>
|
||||
<li>Zuul: http://localhost:9000</li>
|
||||
<li>Logs: http://localhost:8000</li>
|
||||
</ul>
|
||||
If you are accessing a remote machine, replace <code>localhost</code> with the ip address.
|
||||
</p>
|
||||
|
||||
<h1>User notes</h1>
|
||||
<p>
|
||||
<ul>
|
||||
<li>Gerrit keys<br/>
|
||||
If your ssh keys have being created with a new version of OpenSSH, Zuul will
|
||||
fail when running with these keys as there is a Paramiko bug [1].
|
||||
It is recommended that keys be generated as follows:
|
||||
<code>ssh-keygen -m PEM -t rsa</code> - accepting the passwordless option.
|
||||
Then update the public keys used with Gerrit upstream and RDO Gerrit.</br>
|
||||
[1] https://storyboard.openstack.org/#!/story/2004842</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,58 @@
|
||||
# This playbook will clone repos and set up a directory
|
||||
# structure for running the launcher-playbook to start
|
||||
# the Zuul-based reproducer and run a job.
|
||||
|
||||
{% raw %}
|
||||
- name: setup
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Create directory structure
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
with_items:
|
||||
- git
|
||||
- roles
|
||||
- library
|
||||
- playbooks/tripleo-ci-reproducer
|
||||
|
||||
- name: Clone repos needed for reproducer
|
||||
git:
|
||||
repo: "{{ item }}"
|
||||
dest: "git/{{ item.replace('.git', '').split('/')[-1:]|join('/') }}"
|
||||
update: yes
|
||||
with_items:
|
||||
- https://git.openstack.org/openstack/tripleo-quickstart.git
|
||||
- https://github.com/rdo-infra/ansible-role-tripleo-ci-reproducer.git
|
||||
|
||||
- name: Copy roles and libraries for tripleo-quickstart
|
||||
synchronize:
|
||||
src: 'git/tripleo-quickstart/{{ item }}/'
|
||||
dest: '{{ item }}/'
|
||||
with_items:
|
||||
- roles
|
||||
- library
|
||||
|
||||
- name: Copy setup files from tripleo-quickstart
|
||||
synchronize:
|
||||
src: 'git/tripleo-quickstart/{{ item }}'
|
||||
dest: "./{{ item }}"
|
||||
with_items:
|
||||
- install-deps.sh
|
||||
|
||||
- name: requirements from ansible-role-tripleo-ci-reproducer
|
||||
synchronize:
|
||||
src: 'git/ansible-role-tripleo-ci-reproducer/{{ item }}'
|
||||
dest: './{{ item }}'
|
||||
with_items:
|
||||
- bindep.txt
|
||||
- requirements.txt
|
||||
|
||||
- name: Copy ansible-role-tripleo-ci-reproducer roles and playbooks
|
||||
synchronize:
|
||||
src: 'git/ansible-role-tripleo-ci-reproducer{{ item.src_dir }}'
|
||||
dest: '{{ item.dest_dir }}/'
|
||||
with_items:
|
||||
- { src_dir: '', dest_dir: 'roles' }
|
||||
- { src_dir: '/playbooks/tripleo-ci-reproducer/', dest_dir: 'playbooks/tripleo-ci-reproducer' }
|
||||
{% endraw %}
|
@ -0,0 +1,82 @@
|
||||
# First install Ansible and run the launcher-env-setup-playbook.
|
||||
#
|
||||
# From the same dir, run:
|
||||
# >> ansible-playbook launcher-playbook.yaml -vv
|
||||
#
|
||||
# To run the libvirt option (available for non-OVB jobs):
|
||||
# Clone https://github.com/openstack/tripleo-quickstart and run:
|
||||
# >> export NODEPOOL_MIRROR=mirror.mtl01.inap.openstack.org
|
||||
# >> ansible-playbook launcher-playbook.yaml \
|
||||
# -e nodepool_provider=libvirt
|
||||
#
|
||||
# To run on a different cloud defined in clouds.yaml ( default is rdo-cloud):
|
||||
# >> ansible-playbook launcher-playbook.yaml \
|
||||
# -e cloud_name='<custom cloud>'
|
||||
#
|
||||
# To force the job into failing status in order to hold the nodes (temporary option):
|
||||
# >> ansible-playbook launcher-playbook.yaml \
|
||||
# -e force_post_failure=true
|
||||
#
|
||||
# If your upstream gerrit user or rdo gerit user (and/or keys) are different
|
||||
# from your current $USER, there are options to set for each of those values.
|
||||
# See the reproducer-zuul-based-quickstart.sh for the options details.
|
||||
|
||||
{% raw %}
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Add the localhost to the inventory
|
||||
add_host:
|
||||
name: "localhost"
|
||||
groups: "localhost"
|
||||
ansible_host: 127.0.0.1
|
||||
ansible_connection: local
|
||||
|
||||
- name: Add the primary to the inventory
|
||||
add_host:
|
||||
name: "localhost"
|
||||
groups: "primary"
|
||||
ansible_fqdn: "localhost"
|
||||
ansible_user: "{{ lookup('env', 'USER') }}"
|
||||
ansible_private_key_file: "/home/{{ ansible_user }}/.ssh/{{ user_pri_key | default('id_rsa') }}"
|
||||
ansible_host: "localhost"
|
||||
{% endraw %}
|
||||
|
||||
- import_playbook: playbooks/tripleo-ci-reproducer/pre.yaml
|
||||
|
||||
- hosts: localhost
|
||||
vars:
|
||||
depends_on:
|
||||
- {{ zuul.change_url }}
|
||||
zuul_yaml: >-
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- {{ zuul.job }}-dlrn-hash-tag
|
||||
|
||||
- job:
|
||||
name: {{ zuul.job }}-dlrn-hash-tag
|
||||
parent: {{ zuul.job }}
|
||||
vars:
|
||||
{% raw -%}
|
||||
mirror_fqdn: {{ lookup('env', 'NODEPOOL_MIRROR') | default('mirror.regionone.rdo-cloud.rdoproject.org', true) }}
|
||||
{% endraw -%}
|
||||
{% if releases_file_output is defined -%}
|
||||
ready_releases_file: |
|
||||
{{ releases_file_output | replace('export', ' export') }}
|
||||
{% endif -%}
|
||||
featureset_override:
|
||||
{% if featureset_override_file_output is defined -%}
|
||||
{{ featureset_override_file_output | indent(14) }}
|
||||
{% endif -%}
|
||||
{% if dlrn_hash is defined or ('undercloud' in hostvars and 'dlrn_hash' in hostvars['undercloud']) -%}
|
||||
dlrn_hash_tag:
|
||||
{{ hostvars['undercloud'].dlrn_hash }}
|
||||
{% endif -%}
|
||||
{% if dlrn_hash_newest is defined or ('undercloud' in hostvars and 'dlrn_hash_newest' in hostvars['undercloud']) -%}
|
||||
dlrn_hash_tag_newest:
|
||||
{{ hostvars['undercloud'].dlrn_hash_newest }}
|
||||
{%- endif %}
|
||||
|
||||
tasks:
|
||||
- include_role:
|
||||
name: ansible-role-tripleo-ci-reproducer
|
@ -0,0 +1,269 @@
|
||||
#!/bin/bash
|
||||
|
||||
# See documentation for using the reproducer script:
|
||||
# README-reproducer-zuul-based-quickstart.html
|
||||
# (in the same top-level logs directory as this reproducer script).
|
||||
|
||||
: ${WORKSPACE:=$(mktemp -d -t reproduce-tmp.XXXXX)}
|
||||
: ${LIBVIRT:=0}
|
||||
: ${CLOUD_NAME:="rdo-cloud"}
|
||||
: ${FORCE_POST_FAILURE:=0}
|
||||
: ${UPSTREAM_GERRIT_USER:="$USER"}
|
||||
: ${RDO_GERRIT_USER:="$USER"}
|
||||
: ${USER_SSH_KEY:="id_rsa"}
|
||||
: ${USER_SSH_PUB_KEY:="$USER_SSH_KEY.pub"}
|
||||
: ${SSH_KEY_PATH:="/home/$USER/.ssh"}
|
||||
: ${UPSTREAM_GERRIT_SSH_KEY:="id_rsa"}
|
||||
: ${RDO_GERRIT_SSH_KEY:="id_rsa"}
|
||||
: ${EXTRA_PARAMS:=""}
|
||||
|
||||
usage () {
|
||||
echo "Usage: $0 [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " -w, --workspace <dir>"
|
||||
echo " directory where the repos and directories"
|
||||
echo " are created. Defaults to creating a directory in /tmp"
|
||||
echo " -l, --libvirt"
|
||||
echo " Runs a 2-node multinode job or singlenode job on a"
|
||||
echo " single virthost using libvirt to create the nodes."
|
||||
echo " If a singlenode reproducer is run, two VMs will still be created."
|
||||
echo " -c, --cloud-name"
|
||||
echo " Host cloud, specified in the clouds.yaml, to target"
|
||||
echo " Defaults to rdo-cloud"
|
||||
echo " -f, --force-post-failure"
|
||||
echo " Force job to fail so that the nodes will be held."
|
||||
echo " Temporary solution"
|
||||
echo " -ug, --upstream-gerrit-user"
|
||||
echo " Set the upstream gerrit user required to clone repos."
|
||||
echo " Defaults to the current $USER"
|
||||
echo " -rg, --rdo-gerrit-user"
|
||||
echo " Set the upstream RDO user required to clone RDO-related repos."
|
||||
echo " Defaults to the current $USER"
|
||||
echo " -k, --ssh-key"
|
||||
echo " private ssh key used to set up an access nodes."
|
||||
echo " Defaults to id_rsa."
|
||||
echo " -kp, --ssh-key-public"
|
||||
echo " public ssh key used to set up an access nodes."
|
||||
echo " Defaults to $USER_SSH_KEY.pub"
|
||||
echo " -skp, --ssh-key-path"
|
||||
echo " Path to directory where user ssh keys are stored."
|
||||
echo " Defaults to /home/$USER/.ssh"
|
||||
echo " -ugk, --upstream-gerrit-key"
|
||||
echo " Set the upstream gerrit private key."
|
||||
echo " Defaults to the $USER_SSH_KEY."
|
||||
echo " -rgk, --rdo-gerrit-key"
|
||||
echo " Set the upstream RDO user key."
|
||||
echo " Defaults to the $USER_SSH_KEY."
|
||||
echo " -e, --extra-params"
|
||||
echo " File or/and parameters used to override default"
|
||||
echo " parameters for playbooks. Multiple files"
|
||||
echo " can be passed [-e @file1.yml -e @file2.yml ...]"
|
||||
echo " and arguments [-e var=value -e var2=value2 ...]"
|
||||
echo " -h, --help print this help and exit"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
# Input argument assignments
|
||||
while [ "x$1" != "x" ]; do
|
||||
|
||||
case "$1" in
|
||||
--workspace|-w)
|
||||
# realpath fails if /some/path doesn't exist. It is created later
|
||||
WORKSPACE=$(realpath $2 || echo -n $2)
|
||||
shift
|
||||
;;
|
||||
|
||||
--libvirt|-l)
|
||||
LIBVIRT=1
|
||||
;;
|
||||
|
||||
--cloud-name|-c)
|
||||
CLOUD_NAME=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--force-post-failure|-f)
|
||||
FORCE_FAILURE=1
|
||||
;;
|
||||
|
||||
--upstream-gerrit-user|-ug)
|
||||
UPSTREAM_GERRIT_USER=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--rdo-gerrit-user|-rg)
|
||||
RDO_GERRIT_USER=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--ssh-key|-k)
|
||||
USER_SSH_KEY=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--ssh-key-public|-kp)
|
||||
USER_SSH_PUB_KEY=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--ssh-key-path|-skp)
|
||||
SSH_KEY_PATH=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--upstream-gerrit-key|-ugk)
|
||||
UPSTREAM_GERRIT_SSH_KEY=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--rdo-gerrit-key|-rgk)
|
||||
RDO_GERRIT_SSH_KEY=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
--extra-params|-e)
|
||||
[[ ${2::1} == "@" ]] && EXTRA_PARAMS+=("-e @$(realpath ${2#@}) ") || EXTRA_PARAMS+=("-e ${2} ")
|
||||
shift
|
||||
;;
|
||||
|
||||
--help|-h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
|
||||
--) shift
|
||||
break
|
||||
;;
|
||||
|
||||
-*) echo "ERROR: unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
|
||||
*) break
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
set -x
|
||||
|
||||
# Install rpms and other requirements
|
||||
# Currently, only python2 is supported
|
||||
export USER_PYTHON_OVERRIDE=python2
|
||||
export USER_OVERRIDE_SUDO_CHECK=1
|
||||
curl -o bindep.txt https://raw.githubusercontent.com/rdo-infra/ansible-role-tripleo-ci-reproducer/master/bindep.txt
|
||||
|
||||
source install-deps.sh
|
||||
# install just enough python
|
||||
install_deps
|
||||
# install bindep
|
||||
install_bindep
|
||||
# checks the $PWD for a file named
|
||||
# bindep.txt and installs
|
||||
# dependencies listed in the file.
|
||||
install_package_deps_via_bindep
|
||||
|
||||
# Start from a clean workspace
|
||||
export WORKSPACE
|
||||
mkdir -p $WORKSPACE
|
||||
rsync -a *-playbook.yaml $WORKSPACE
|
||||
cd $WORKSPACE
|
||||
|
||||
# Set up docker groups
|
||||
if ! groups | grep docker; then
|
||||
echo "$USER is not in the docker group."
|
||||
sudo groupadd docker
|
||||
sudo usermod -aG docker $USER
|
||||
echo "Add user immediately to the docker group."
|
||||
echo "This will exit the script, please re-execute."
|
||||
exec sg docker newgrp `id -gn`
|
||||
fi
|
||||
|
||||
# Check the Docker config
|
||||
if [[ -f /etc/docker/daemon.json ]]; then
|
||||
if cat /etc/docker/daemon.json | grep '"group": "docker"'; then
|
||||
echo "docker group is already added to /etc/docker/daemon.json"
|
||||
elif (( $(cat /etc/docker/daemon.json | wc -m) > 3 )); then
|
||||
echo "/etc/docker/daemon.json is populated.
|
||||
Exit this script and either clear the file or add the docker group."
|
||||
exit 1
|
||||
else
|
||||
echo "The docker group will be added to /etc/docker/daemon.json."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for passwordless sudo on the local system
|
||||
sudo -n true && passwordless_sudo="1" || passwordless_sudo="0"
|
||||
if [[ "$passwordless_sudo" == "0" ]]; then
|
||||
echo " Passwordless sudo id used in:
|
||||
https://github.com/rdo-infra/ansible-role-tripleo-ci-reproducer/playbooks/tripleo-ci-reproducer/pre.yaml
|
||||
to set up the Docker config and to start and enable Docker.
|
||||
Without passwordless sudo, the playbook will fail.
|
||||
|
||||
There are three options to proceed:
|
||||
1. Enable passwordless sudo and rerun the script to complete the install and job launch
|
||||
2. Edit the launcher.yaml playbook to pass the sudo password
|
||||
>> --extra-vars ansible_sudo_pass='yourPassword'
|
||||
3. Read the pre.yaml playbook and execute the steps manually.
|
||||
When you rerun the script, those steps will be skipped during the playbook execution.
|
||||
"
|
||||
fi
|
||||
# Run the playbook to set up the launcher env
|
||||
ansible-playbook \
|
||||
$WORKSPACE/launcher-env-setup-playbook.yaml \
|
||||
-vv \
|
||||
${EXTRA_PARAMS[@]}
|
||||
|
||||
# Set the options selected into EXTRA_PARAMS
|
||||
if [[ "$LIBVIRT" == "1" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e nodepool_provider=libvirt "
|
||||
export NODEPOOL_MIRROR=mirror.mtl01.inap.openstack.org
|
||||
fi
|
||||
|
||||
if [[ "$LIBVIRT" == "0" && "$CLOUD_NAME" != "rdo-cloud" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e cloud_name=$CLOUD_NAME "
|
||||
fi
|
||||
|
||||
if [[ "$FORCE_POST_FAILURE" == "1" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e force_post_failure=true "
|
||||
fi
|
||||
|
||||
if [[ "$UPSTREAM_GERRIT_USER" != "$USER" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e upstream_gerrit_user=$UPSTREAM_GERRIT_USER "
|
||||
fi
|
||||
|
||||
if [[ "$RDO_GERRIT_USER" != "$USER" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e rdo_gerrit_user=$RDO_GERRIT_USER "
|
||||
fi
|
||||
|
||||
if [[ "$USER_SSH_KEY" != "id_rsa" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e user_pri_key=$USER_SSH_KEY "
|
||||
fi
|
||||
|
||||
if [[ "$USER_SSH_PUB_KEY" != "$USER_SSH_KEY.pub" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e user_pub_key=$USER_SSH_PUB_KEY "
|
||||
fi
|
||||
|
||||
if [[ "$SSH_KEY_PATH" != "/home/$USER/.ssh" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e ssh_path=$SSH_KEY_PATH "
|
||||
fi
|
||||
|
||||
if [[ "$UPSTREAM_GERRIT_SSH_KEY" != "$USER_SSH_KEY" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e upstream_gerrit_key=$UPSTREAM_GERRIT_SSH_KEY "
|
||||
fi
|
||||
|
||||
if [[ "$RDO_GERRIT_SSH_KEY" != "$USER_SSH_KEY" ]]; then
|
||||
EXTRA_PARAMS="$EXTRA_PARAMS -e rdo_gerrit_key=$RDO_GERRIT_SSH_KEY "
|
||||
fi
|
||||
|
||||
|
||||
# Run the launcher playbook
|
||||
ansible-playbook \
|
||||
$WORKSPACE/launcher-playbook.yaml \
|
||||
-vv \
|
||||
--tags all \
|
||||
${EXTRA_PARAMS[@]}
|
Loading…
Reference in New Issue
Block a user