-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup role to initialize openshift-tests-private repo #30
Open
AdityaHonkalas
wants to merge
1
commit into
ocp-power-automation:main
Choose a base branch
from
AdityaHonkalas:init-setup-role
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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` as per the minimum requirement. | | ||
| 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 of the tests private repo. | | ||
| openshift_tests_private_branch | no | master | Branch to be used for specified test repo. | | ||
| 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 != "" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is'nt it better to use
dnf
instead? @pravin-dsilva