Skip to content

Commit 997a278

Browse files
committed
keystone: create k8s service account group and roles
1 parent 8100348 commit 997a278

4 files changed

Lines changed: 75 additions & 0 deletions

File tree

ansible/roles/keystone_bootstrap/defaults/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,22 @@ keystone_bootstrap_groups:
6868
# role: member
6969
# - project: shared-services
7070
# role: reader
71+
72+
# k8s service account groups and their project role assignments
73+
# Each group can have project_roles with an optional domain to scope the project lookup
74+
keystone_bootstrap_k8s_groups:
75+
- name: k8s-serviceaccounts
76+
desc: 'Kubernetes Service Accounts'
77+
project_roles:
78+
- project: service
79+
domain: service
80+
role: admin
81+
- project: service
82+
domain: service
83+
role: service
84+
- project: baremetal
85+
domain: infra
86+
role: admin
87+
- project: baremetal
88+
domain: infra
89+
role: service
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# Copyright (c) 2026 Rackspace Technology, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
# not use this file except in compliance with the License. You may obtain
6+
# a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
16+
- name: Create k8s service account group mappings
17+
ansible.builtin.include_tasks: k8s_group.yml
18+
loop: "{{ keystone_bootstrap_k8s_groups }}"
19+
loop_control:
20+
loop_var: group_item
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
# Copyright (c) 2026 Rackspace Technology, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
# not use this file except in compliance with the License. You may obtain
6+
# a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
16+
- name: Create k8s group
17+
openstack.cloud.identity_group:
18+
name: "{{ group_item.name }}"
19+
description: "{{ group_item.desc }}"
20+
state: present
21+
register: _k8s_group
22+
23+
- name: Assign role to k8s group for project
24+
openstack.cloud.role_assignment:
25+
group: "{{ _k8s_group.group.id }}"
26+
project: "{{ role_item.project }}"
27+
project_domain: "{{ role_item.domain | default(omit) }}"
28+
role: "{{ role_item.role }}"
29+
state: present
30+
loop: "{{ group_item.project_roles | default([]) }}"
31+
loop_control:
32+
loop_var: role_item
33+
when: dont_set_roles is not defined

ansible/roles/keystone_bootstrap/tasks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
- name: Define SSO
1111
ansible.builtin.include_tasks: sso.yml
1212

13+
- name: Define k8s service account groups
14+
ansible.builtin.include_tasks: k8s.yml
15+
1316
- name: Define misc keystone
1417
ansible.builtin.include_tasks: misc.yml

0 commit comments

Comments
 (0)