summaryrefslogtreecommitdiff
path: root/add-user-roles
blob: fa719b7c59397274ea8dda3aef77cd01fae193b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# add user with project-admin role to all projects
# 
# Before using this script, add yourself as user with i.e.
# keystone user-create --name varac --pass NSACANTGUESSTHIS --email varacanero@leap.se --enabled true   

ROLEID=$(keystone role-list | grep -i projectadmin | awk '{print $2}')
USERID=NULL

declare -a PROJECTS=('playground' 'bitmask testing' LEAP 'Bitmask clientdev' 'Bitmask development' 'Bitmask production');

for (( i = 0; i < ${#PROJECTS[@]}; i++ ))
do
  PROJECTID=$(keystone tenant-list | grep -i "${PROJECTS[$i]}" | awk '{print $2}')
  for user in drebs kwadronaut micah varac elijah
  do
    USERID=$(keystone user-list | grep -i $user | awk '{print $2}')
    keystone user-role-add --role-id $ROLEID --user-id $USERID --tenant-id $PROJECTID
  done
done