[patch] Fix initial user creation facilities support #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes support for facilities in the
mas-devops-create-initial-users-for-saasscript run by the ibm-create-initial-users. Gitops Job. See walkthrough for details.Fix issues causing the script to fail when facilities app is installed
When facilities app installed, users created by the script would fail to sync with facilities due to:
and with manage due to:
This PR fixes these issues by ensuring:
addressesandphoneNumbersare set (to an empty list) when the user is created.PREMIUMfor primary users andBASEfor secondary users)Allow user_id to be (optionally) specified, otherwise default to using email (as before)
There is also a need to be able to use this script to create the special
FACILITIESADMINuser. To support this, the assumption that created user emails and ids are always the same has been removed by adding an additionalidfield to the inputs. This field is optional. If absent, email will continue to be used as the id for backwards compatibility.In the initial users secret JSON, the new
idfield is a fourth optional element, e.g.:Will use
user1@email.comas the user's ID and email (as before)Will use
facilitiesadmin@email.comas the user's email, butfacilitiesadminas their ID.Testing
Unit tests updated
Verified manually by running the script from my laptop against a MAS 9.1.5 (Manage 9.1.5, Facilities 9.1.4) instance:
initial user secret:
$ mas-devops-create-initial-users-for-saas \ --mas-instance-id masaudit \ --mas-workspace-id main \ --log-level INFO \ --initial-users-secret-name initialusertest \ --manage-api-port 8443 \ --coreapi-port 8444 \ --admin-dashboard-port 8445 2025-12-16 16:01:32,221 root [MainThread] INFO Configuration: 2025-12-16 16:01:32,221 root [MainThread] INFO -------------- 2025-12-16 16:01:32,221 root [MainThread] INFO mas_instance_id: masaudit 2025-12-16 16:01:32,221 root [MainThread] INFO mas_workspace_id: main 2025-12-16 16:01:32,221 root [MainThread] INFO initial_users_yaml_file: None 2025-12-16 16:01:32,221 root [MainThread] INFO initial_users_secret_name: initialusertest 2025-12-16 16:01:32,221 root [MainThread] INFO log_level: 20 2025-12-16 16:01:32,221 root [MainThread] INFO coreapi_port: 8444 2025-12-16 16:01:32,221 root [MainThread] INFO admin_dashboard_port: 8445 2025-12-16 16:01:32,221 root [MainThread] INFO manage_api_port: 8443 2025-12-16 16:01:32,221 root [MainThread] INFO 2025-12-16 16:01:32,226 root [MainThread] INFO Loading initial_users configuration from secret initialusertest 2025-12-16 16:01:32,233 botocore.credentials [MainThread] INFO Found credentials in environment variables. 2025-12-16 16:01:37,529 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for manage to become ready and available: 600.00 seconds remaining 2025-12-16 16:01:39,019 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for facilities to become ready and available: 600.00 seconds remaining 2025-12-16 16:01:40,306 mas.devops.users.MASUserUtils [MainThread] INFO 2025-12-16 16:01:40,307 mas.devops.users.MASUserUtils [MainThread] INFO Syncing primary user with email initialusertest1@suite.maximo.com 2025-12-16 16:01:41,756 mas.devops.users.MASUserUtils [MainThread] INFO Creating new user initialusertest1@suite.maximo.com 2025-12-16 16:01:47,411 mas.devops.users.MASUserUtils [MainThread] INFO Linking user initialusertest1@suite.maximo.com to local IDP (email_password: True) 2025-12-16 16:01:50,266 mas.devops.users.MASUserUtils [MainThread] INFO Adding user initialusertest1@suite.maximo.com to main (is_workspace_admin: True) 2025-12-16 16:01:51,560 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for manage to become ready and available: 600.00 seconds remaining 2025-12-16 16:02:03,460 mas.devops.users.MASUserUtils [MainThread] INFO Setting user initialusertest1@suite.maximo.com role for manage to MANAGEUSER 2025-12-16 16:02:05,093 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for facilities to become ready and available: 600.00 seconds remaining 2025-12-16 16:02:08,235 mas.devops.users.MASUserUtils [MainThread] INFO Setting user initialusertest1@suite.maximo.com role for facilities to PREMIUM 2025-12-16 16:02:09,499 mas.devops.users.MASUserUtils [MainThread] INFO Awaiting user initialusertest1@suite.maximo.com sync status "SUCCESS" for app manage: 600.00 seconds remaining 2025-12-16 16:02:35,599 mas.devops.users.MASUserUtils [MainThread] INFO User initialusertest1@suite.maximo.com sync has not been completed yet for app manage (currrently PENDING): 573.90 seconds remaining 2025-12-16 16:02:41,757 mas.devops.users.MASUserUtils [MainThread] INFO Awaiting user initialusertest1@suite.maximo.com sync status "SUCCESS" for app facilities: 600.00 seconds remaining 2025-12-16 16:02:45,265 mas.devops.users.MASUserUtils [MainThread] INFO Reusing existing Manage API Key for user MAXADMIN 2025-12-16 16:02:52,203 mas.devops.users.MASUserUtils [MainThread] INFO Adding user initialusertest1@suite.maximo.com to Manage group MAXADMIN 2025-12-16 16:02:55,422 mas.devops.users.MASUserUtils [MainThread] INFO Completed sync of primary user initialusertest1@suite.maximo.com 2025-12-16 16:02:55,423 mas.devops.users.MASUserUtils [MainThread] INFO 2025-12-16 16:02:55,423 mas.devops.users.MASUserUtils [MainThread] INFO Syncing primary user with email initialusertest2@suite.maximo.com 2025-12-16 16:02:56,727 mas.devops.users.MASUserUtils [MainThread] INFO Creating new user initialusertest2 2025-12-16 16:03:01,765 mas.devops.users.MASUserUtils [MainThread] INFO Linking user initialusertest2 to local IDP (email_password: True) 2025-12-16 16:03:04,814 mas.devops.users.MASUserUtils [MainThread] INFO Adding user initialusertest2 to main (is_workspace_admin: True) 2025-12-16 16:03:05,997 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for manage to become ready and available: 600.00 seconds remaining 2025-12-16 16:03:17,487 mas.devops.users.MASUserUtils [MainThread] INFO Setting user initialusertest2 role for manage to MANAGEUSER 2025-12-16 16:03:19,074 mas.devops.users.MASUserUtils [MainThread] INFO Waiting for facilities to become ready and available: 600.00 seconds remaining 2025-12-16 16:03:21,940 mas.devops.users.MASUserUtils [MainThread] INFO Setting user initialusertest2 role for facilities to PREMIUM 2025-12-16 16:03:23,326 mas.devops.users.MASUserUtils [MainThread] INFO Awaiting user initialusertest2 sync status "SUCCESS" for app manage: 600.00 seconds remaining 2025-12-16 16:03:50,054 mas.devops.users.MASUserUtils [MainThread] INFO User initialusertest2 sync has not been completed yet for app manage (currrently PENDING): 573.27 seconds remaining 2025-12-16 16:03:56,466 mas.devops.users.MASUserUtils [MainThread] INFO Awaiting user initialusertest2 sync status "SUCCESS" for app facilities: 600.00 seconds remaining 2025-12-16 16:03:59,804 mas.devops.users.MASUserUtils [MainThread] INFO Reusing existing Manage API Key for user MAXADMIN 2025-12-16 16:04:04,530 mas.devops.users.MASUserUtils [MainThread] INFO Adding user initialusertest2 to Manage group MAXADMIN 2025-12-16 16:04:07,186 mas.devops.users.MASUserUtils [MainThread] INFO Completed sync of primary user initialusertest2@suite.maximo.com 2025-12-16 16:04:07,186 root [MainThread] INFO Removing synced user initialusertest1@suite.maximo.com from initialusertest secret 2025-12-16 16:04:07,186 root [MainThread] INFO Removing synced user initialusertest2@suite.maximo.com from initialusertest secret 2025-12-16 16:04:07,186 root [MainThread] INFO Updating secret initialusertestBoth users were created successfully with expected access rights, and it was possible to login as them.