VMware vRealize Automation 7.x is the latest version of VMware’s cloud automation software. With the new version comes a change in the way tenants (and user roles for same) are setup. In previous versions you would do the following to create a tenant
- Log into the default tenant
- Create a new tenant
- Add an identity store
- Add domain users/groups as tenant & IaaS admins
- Log into the new tenant as a tenant and IaaS admin and start configuring the tenant
With vRA 7.x the procedure changes (and becomes more cumbersome IMO)
- Log into the default tenant
- Create a new tenant
- Create a local user for the tenant
- Add the local user as a tenant & IaaS admin
- Log into the new tenant as the local user
- Setup identity store directories
- Log back into the default tenant
- Edit the new tenant
- Add domain users/groups as tenant & IaaS admins
- Log into the new tenant as a tenant and IaaS admin and start configuring the tenant
So when it comes to trying to automate tenant creation its not as easy as it used to be for 6.x. For 6.x I’ve used cloud client (if you’re not familiar with CloudClient i’d recommend checking it out here https://developercenter.vmware.com/tool/cloudclient/4.1.0 )
The CloudClient commands required for 6.x are as follows:
- Firstly login to CloudClient
vra login userpass --server vra-vip.domain.local --user administrator@vsphere.local --password Password123! --tenant vsphere.local
- Next create the tenant
vra tenant add --name NewTenant --url newtenant
- Next add the identity store for AD authentication
vra tenant identitystore add --tenantname NewTenant --name Domain.local --url ldap://domain.local --groupbasedn 'ou=vRA,DC=domain,DC=local' --domain domain.local --userdn 'cn=adbind_vra,OU=vRA,DC=domain,DC=local' --password Password123! --type AD --userbasedn 'ou=vRA,DC=domain,DC=local'
- Next add Tenant administrators to the new tenant
vra tenant admin update --tenantname NewTenant --role TENANT_ADMIN --action ADD --users vRA_Tenant_Admins@domain.local
- Next add IaaS Administrators to the new tenant
vra tenant admin update --tenantname NewTenant --role IAAS_ADMIN --action ADD --users vRA_IaaS_Admins@domain.local
So enter vRA 7.x. Using CloudClient the first 2 steps are the same as before
- Firstly login to CloudClient
vra login userpass --server vra-vip.domain.local --user administrator@vsphere.local --password Password123! --tenant vsphere.local
- Next create the tenant
vra tenant add --name NewTenant --url newtenant
- Next we need to create a local user in the tenant. I couldn’t find a function in CloudClient to create the local user. I checked the developer API guide and I also tried the excellent community module PowervRA http://www.jonathanmedd.net/2016/03/introducing_powervra.html but no joy so i enlisted the help of my colleague Sean Leahy @leahy_s to query the REST API. We ran the add user operation manually and monitored the process in FireFox (Press F12 to get access to the browser console debugger.) Manually enter the user details and click Ok and you will see a POST operation in the console. See below
- Click on the POST operation and inspect the REST information. In the headers tab you can see the Content-Type is application/json and in the params tab you can see the post data
- Using the API guide we found the required REST method to get an authentication token from vRA that will allow us to POST data. In this example i’m using Advanced REST client in Chrome to retrieve the auth token from vRA. So the URL to POST to is https://vra-appliance-FQDN/identity/api/tokens and the credentials payload needs to be JSON formatted. See below
- The response back should contain a base64 encoded string that will be used as an authorization token to post the new user.
- So again using Advanced REST client in chrome (or your preferred method) we need to do a POST operation to create the user. This time you need to use URL https://vra-appliance-FQDN/identity/api/tenants/NewTenant/principals. In the headers you need Accept set to Application/json and Authorization set to the base64 encoded token string we got in the previous step. IMPORTANT: You must prefix the token with Bearer or it will not work! See below
- Here is the full JSON payload as you cant see it all in the screenshot
{"@type": "User", "firstName": "vRA", "lastName": "Admin", "emailAddress": "vraadmin@domain.local", "description": "vRA Admin", "locked": false, "disabled": false, "password": "Password123!", "domain": "vsphere.local", "userName":"vraadmin", "principalId": {"domain": "vsphere.local", "name": "vraadmin"} }
- Ok deep breaths…if you’re still with me you can now proceed to adding the user to the tenant and IaaS administrator groups!
- In the interest of trying out different tools I decided to try using PowervRA for this task. (I will revisit this using the REST API directly next week) I wont go into installing PowervRA. There are good instructions here https://github.com/jakkulabs/PowervRA
- In PowervRA run the following commands
Add-vRAPrincipalToTenantRole -TenantId NewTenant -PrincipalId vraadmin@vsphere.local -RoleId CSP_TENANT_ADMIN Add-vRAPrincipalToTenantRole -TenantId NewTenant -PrincipalId vraadmin@vsphere.local -RoleId COM_VMWARE_IAAS_IAAS_ADMINISTRATOR
Not sure why the complete difference in RoleId name format but thats the only way i could get it to work!
So now we have a tenant with a local user that is both tenant admin & IaaS admin but we still dont have an AD directory service to authenticate AD users. So for this we will again leverage the REST API. Using the same auth token as before, this time we need to hit https://vra-appliance-FQDN/identity/api/tenants/NewTenant/directories
- Here is the full JSON payload as you cant see it all in the screenshot
{ @type: "IdentityStore", domain: "domain.local", name: "Domain.local", alias: "Domain", type: "AD", userNameDn: "cn=adbind_vra,OU=EHC,DC=domain,DC=local", password: "Password123!", url: "ldap://domain.local:389", groupBaseSearchDn: "ou=EHC,DC=domain,DC=local", userBaseSearchDn: "ou=EHC,DC=domain,DC=local" }
- We can now go and add our domain users as Tenant admins and IaaS admins to allow domain users to log into the new tenant! So its a longer process than 6.x but its still doable (even if parts of it are undocumented in the API guide!). I will be working on scripting this for multiple tenants so hopefully keep an eye out for a follow up post as i fumble my way through using the vRealize Automation REST API! 🙂
Special thanks again to my colleague Sean Leahy for the REST pointers!