-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup role for openshift-tests-private repository
Signed-off-by: Aditya Honkalas <[email protected]>
- Loading branch information
1 parent
facf1b8
commit e857ecd
Showing
7 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
## openshift-tests-private-setup vars | ||
openshift_tests_private_setup_enable: false | ||
golang_install_tarball: "https://go.dev/dl/go1.19.4.linux-ppc64le.tar.gz" | ||
openshift_tests_private_basedir: "~/ocp-validation" | ||
openshift_tests_private_clone_url: "https://github.com/openshift/openshift-tests-private" | ||
openshift_tests_private_branch: "master" | ||
openshift_tests_private_make_build_target: "~/ocp-validation/openshift-tests-private" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
|
||
- name: openshift-tests-private repository setup role | ||
hosts: bastion | ||
roles: | ||
- openshift-tests-private-setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
openshift-tests-private-setup | ||
========== | ||
|
||
This role initializes the following steps to setup `openshift-tests-private` test repository. | ||
- Installing development tools | ||
- Creating sub-directory | ||
- Clonning the git repository | ||
- Installing golang | ||
- Running make build in the target directory | ||
|
||
This role can be included in the other roles for initializing the above pre-requisites. | ||
|
||
|
||
Requirements | ||
------------ | ||
|
||
- The cluster is in a known good state, without any errors. | ||
|
||
|
||
Role Variables | ||
-------------- | ||
|
||
| Variable | Required | Default | Comments | | ||
|-------------------------------------------|----------|--------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------| | ||
| openshift_tests_private_setup_enable | no | false | Set the flag `true` to run this playbook. | | ||
| golang_install_tarball | no | `https://go.dev/dl/go1.19.4.linux-ppc64le.tar.gz` | Golang tarball for `ppc64le` arch with version `>= 1.18`, the default is given for version `1.19.4`. | | ||
| openshift_tests_private_basedir | no | `~/ocp-validation` | Base directory path to clone the `openshift-tests-private` repo. It will get created if path not exists or not provided. | | ||
| openshift_tests_private_clone_url | no | `https://github.com/openshift/openshift-tests-private` | Git clone URL, the default has been set for `openshift-tests-private` repository. | | ||
| openshift_tests_private_branch | no | master | Git branch name, the default branch name has been set as `master`. | | ||
| openshift_tests_private_make_build_target | no | `~/ocp-validation/openshift-tests-private` | Target directory for make build command. | | ||
|
||
|
||
Environment Variables | ||
--------------------- | ||
|
||
| Variable | Required | Comments | | ||
|----------------------|----------------|------------------------------------------------------------------------| | ||
| GITHUB_USERNAME | yes | Public GitHub account username to which the repository access granted. | | ||
| GITHUB_ACCESS_TOKEN | yes | GitHub personal access token to clone the repository. | | ||
|
||
|
||
**Note- The above environment variables are required to be set to provide your GitHub credentials.** | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
``` | ||
- name: openshift-tests-private repository setup role | ||
hosts: bastion | ||
roles: | ||
- openshift-tests-private-setup | ||
``` | ||
|
||
|
||
Steps to use this role | ||
---------------------- | ||
|
||
To use this role in other roles to setup `openshift-tests-private` repo, use the `include_role` module and supply the role variables in the `vars` as below: | ||
|
||
``` | ||
- name: Include the openshift-tests-private-setup role | ||
include_role: | ||
name: openshift-tests-private-setup | ||
vars: | ||
golang_install_tarball: "https://go.dev/dl/go1.19.4.linux-ppc64le.tar.gz" | ||
openshift_tests_private_basedir: "~/ocp-validation" | ||
openshift_tests_private_clone_url: "https://github.com/openshift/openshift-tests-private" | ||
openshift_tests_private_branch: "master" | ||
openshift_tests_private_make_build_target: "~/ocp-validation/openshift-tests-private" | ||
``` | ||
|
||
To run this role indenpendently add host in the inventory file, set the role variables in the `ocp4-playbooks-extras/examples/openshift_tests_private_vars.yaml` and run the below sample command from `ocp4-playbooks-extras`. | ||
|
||
|
||
Sample Command | ||
--------------- | ||
|
||
ansible-playbook -i inventory -e @openshift_tests_private_setup_vars.yaml ~/ocp4-playbooks-extras/playbooks/openshift-tests-private-setup.yaml | ||
|
||
|
||
License | ||
------- | ||
|
||
See LICENCE.txt | ||
|
||
|
||
Author Information | ||
------------------ | ||
|
||
[email protected] | ||
|
8 changes: 8 additions & 0 deletions
8
playbooks/roles/openshift-tests-private-setup/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
## init-setup default vars | ||
golang_install_tarball: "https://go.dev/dl/go1.19.4.linux-ppc64le.tar.gz" | ||
openshift_tests_private_basedir: "~/ocp-validation" | ||
openshift_tests_private_clone_url: "https://github.com/openshift/openshift-tests-private" | ||
openshift_tests_private_branch: "master" | ||
openshift_tests_private_make_build_target: "~/ocp-validation/openshift-tests-private" |
64 changes: 64 additions & 0 deletions
64
playbooks/roles/openshift-tests-private-setup/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
|
||
## Test initialization setup playbook | ||
|
||
- set_fact: | ||
github_username: "{{ lookup('ansible.builtin.env','GITHUB_USERNAME') }}" | ||
github_personal_access_token: "{{ lookup('ansible.builtin.env','GITHUB_ACCESS_TOKEN') }}" | ||
|
||
# Check the environment vars for git username and personal access token | ||
- fail: | ||
msg: "Please ensure that you have been set the environment variables GITHUB_USERNAME and GITHUB_ACCESS_TOKEN" | ||
when: github_username == "" or github_personal_access_token == "" | ||
|
||
- name: Install the development tools | ||
yum: | ||
name: | ||
- git | ||
- "@Development tools" | ||
state: present | ||
when: | | ||
(ansible_distribution == "CentOS") or | ||
(ansible_distribution == "RedHat") or | ||
(ansible_distribution == "Fedora") | ||
- name: Include a golang installation role | ||
include_role: | ||
name: golang-installation | ||
vars: | ||
go_tarball: "{{ golang_install_tarball }}" | ||
golang_path: "/usr/local/" | ||
|
||
- name: Check if the given base-directory path already exists | ||
stat: | ||
path: "{{ openshift_tests_private_basedir }}" | ||
register: basedir_path_status | ||
|
||
- name: Create a base directory for openshift-test-private | ||
file: | ||
path: "{{ openshift_tests_private_basedir }}" | ||
state: directory | ||
mode: 0755 | ||
when: not basedir_path_status.stat.exists | ||
|
||
- name: Clone the git repo | ||
git: | ||
repo: "https://{{ github_username }}:{{ github_personal_access_token }}@github.com/{{ openshift_tests_private_clone_url | urlsplit('path') }}" | ||
dest: "{{ repo_dest_path }}" | ||
version: "{{ openshift_tests_private_branch }}" | ||
force: true | ||
vars: | ||
repo_dest_path: "{{ [openshift_tests_private_basedir, openshift_tests_private_clone_url.split('/')[-1]] | join('/') }}" | ||
when: | ||
- openshift_tests_private_clone_url != "" | ||
- openshift_tests_private_branch != "" | ||
- github_username != "" | ||
- github_personal_access_token != "" | ||
|
||
- name: Run make build command at target | ||
make: | ||
chdir: "{{ openshift_tests_private_make_build_target }}" | ||
target: build | ||
environment: | ||
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin" | ||
when: openshift_tests_private_make_build_target != "" |