Skip to content

Commit

Permalink
Merge pull request #8 from siddharthvipul/staging
Browse files Browse the repository at this point in the history
add openshift template and playbook to create openshift resources
  • Loading branch information
arrfab authored Jun 23, 2020
2 parents c30289b + 689af1c commit e5328c7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions adhoc-openshift-resources.yaml
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"
34 changes: 34 additions & 0 deletions templates/openshift-resources.j2
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

0 comments on commit e5328c7

Please sign in to comment.