From ccafc8949833b3fa014a3b545e7df0f34dd0991f Mon Sep 17 00:00:00 2001 From: David Kirwan Date: Mon, 22 Aug 2022 12:06:36 +0100 Subject: [PATCH] communishift: Added task for creating Openshift Role, RoleBindings Signed-off-by: David Kirwan Signed-off-by: Lenka Segura Signed-off-by: Patrik Polakovic --- .../tasks/create-role-binding.yml | 40 +++++++++++++++++++ roles/communishift/tasks/create-role.yml | 19 +++++++++ roles/communishift/tasks/main.yml | 2 + 3 files changed, 61 insertions(+) create mode 100644 roles/communishift/tasks/create-role-binding.yml create mode 100644 roles/communishift/tasks/create-role.yml diff --git a/roles/communishift/tasks/create-role-binding.yml b/roles/communishift/tasks/create-role-binding.yml new file mode 100644 index 0000000000..cf1c8c46ac --- /dev/null +++ b/roles/communishift/tasks/create-role-binding.yml @@ -0,0 +1,40 @@ +--- +- name: Create a k8s RoleBinding for group namespace permissions + community.okd.k8s: + api_key: "{{ communishift_ocp_api_token }}" + host: "{{ communishift_ocp_api_host }}" + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: RoleBinding + metadata: + name: "{{ communishift_project_name }}-group-rolebinding" + namespace: "{{ communishift_project_name }}" + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: admin + subjects: + - apiGroup: rbac.authorization.k8s.io + kind: Group + name: "{{ communishift_project_name }}-admins" + +- name: Create a k8s RoleBinding for storage permissions + community.okd.k8s: + api_key: "{{ communishift_ocp_api_token }}" + host: "{{ communishift_ocp_api_host }}" + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: RoleBinding + metadata: + name: "{{ communishift_project_name }}-efs-rolebinding" + namespace: "{{ communishift_project_name }}" + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: "{{ communishift_project_name }}-efs-role" + subjects: + - apiGroup: rbac.authorization.k8s.io + kind: Group + name: "{{ communishift_project_name }}-admins" diff --git a/roles/communishift/tasks/create-role.yml b/roles/communishift/tasks/create-role.yml new file mode 100644 index 0000000000..8594c0265a --- /dev/null +++ b/roles/communishift/tasks/create-role.yml @@ -0,0 +1,19 @@ +--- +- name: Create a k8s Role + community.okd.k8s: + api_key: "{{ communishift_ocp_api_token }}" + host: "{{ communishift_ocp_api_host }}" + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: Role + metadata: + name: "{{ communishift_project_name }}-efs-role" + namespace: "{{ communishift_project_name }}" + rules: + - apiGroups: + - aws-efs.managed.openshift.io + resources: + - '*' + verbs: + - '*' diff --git a/roles/communishift/tasks/main.yml b/roles/communishift/tasks/main.yml index bc3e2d30b5..1cf8e3dc93 100644 --- a/roles/communishift/tasks/main.yml +++ b/roles/communishift/tasks/main.yml @@ -9,3 +9,5 @@ - include_tasks: create-group.yml - include_tasks: create-efs.yml - include_tasks: create-efs-secret.yml +- include_tasks: create-role.yml +- include_tasks: create-role-binding.yml