-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from siddharthvipul/staging
add openshift template and playbook to create openshift resources
- Loading branch information
Showing
2 changed files
with
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This playbook is to use templates/openshift-resources.j2 and extra vars | ||
# (project details) and apply the resources created from the template. | ||
# ansible-playbook playbooks/adhoc-openshift-resources.yaml -e "host=ocp-ci-management" -e "@projects_vars.yaml" | ||
# | ||
# Example of project_vars.yaml | ||
# ``` | ||
# project_name: billionDollarProject | ||
# project_admins: | ||
# - admin1 | ||
# - admin2 | ||
# | ||
# bug_id: '000000' #bug id is the place/id where the project is requested | ||
# ``` | ||
|
||
|
||
- hosts: "{{ host }}" | ||
become: true | ||
become_user: "{{ ocp_service_account }}" | ||
|
||
tasks: | ||
# generate the template for project to be created | ||
- name: apply the template | ||
template: | ||
src: openshift-resources.j2 | ||
dest: "/home/{{ ocp_service_account }}/ocp_configs/{{ project_name }}.yaml" | ||
|
||
# apply created openshift resources | ||
- name: oc apply resources | ||
command: "/home/{{ ocp_service_account }}/bin/oc apply -f /home/{{ ocp_service_account }}/ocp_configs/{{ project_name }}.yaml" |
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,34 @@ | ||
--- | ||
kind: Namespace | ||
apiVersion: v1 | ||
metadata: | ||
name: "{{project_name}}" | ||
annotations: | ||
openshift.io/description: "{{ project_name }}" | ||
openshift.io/display-name: "{{ project_name }}" | ||
openshift.io/requester: [email protected] | ||
labels: | ||
bug-id: "{{bug_id}}" | ||
--- | ||
kind: Group | ||
apiVersion: user.openshift.io/v1 | ||
metadata: | ||
name: "{{project_name}}-admins" | ||
users: | ||
{% for item in project_members %} | ||
- "{{ item }}" | ||
{% endfor %} | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: "{{project_name}}-admins" | ||
namespace: "{{project_name}}" | ||
subjects: | ||
- kind: Group | ||
apiGroup: rbac.authorization.k8s.io | ||
name: "{{project_name}}-admins" | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: admin |