Problem
When a user is created with incorrect information or the creation process is interrupted, the user account may be partially provisioned in Terraform Enterprise. In the UI, these user accounts may appear incomplete, and the option to delete them is disabled or 'dimmed'.
Cause
The user record in the Terraform Enterprise database is incomplete or contains invalid attributes. This prevents the application from managing the user through the standard UI controls.
Solutions
The following solutions require accessing the Rails console on the Terraform Enterprise instance to manage the user records directly.
Solution 1: Delete the User via the Rails Console
This solution directly removes the user record from the database.
- Access the Terraform Enterprise instance using SSH.
Connect to the Rails console. The command varies based on your Terraform Enterprise version.
For Terraform Enterprise
v202205-1(619) and newer, run the following command.$ sudo docker exec -it tfe-atlas /usr/bin/init.sh /app/scripts/wait-for-token -- bash -i -c 'cd /app && ./bin/rails c'
For older versions, run the following command.
$ sudo docker exec -it ptfe_atlas /usr/bin/init.sh /app/scripts/wait-for-token -- bash -i -c 'cd /app && ./bin/rails c'
From the Rails console prompt, find the user to confirm their existence and retrieve their
User ID. You can list all users or find a specific user by email.## List all users User.all ## Find a specific user User.find_by(email: "email.address@example.com")
- Note the
User IDfrom the command output. Delete the user by providing their
User IDto theUser.deletecommand.User.delete(USER_ID_NUMBER)
- Verify the user was deleted by running the command from step 3 again.
- Repeat the process for any other affected users.
Solution 2: Manually Validate and Save the User
In some cases, you may need to correct the user record before it can be managed or deleted. This involves setting a valid username and password so the record can be saved correctly.
- Access the Terraform Enterprise instance and connect to the Rails console as described in Solution 1.
Find the affected user.
user = User.find_by(email: "email.address@example.com")
Set the
username,password, andpassword_confirmationattributes. Thepasswordandpassword_confirmationmust match for the record to be valid.user.username = 'tempusername' user.password = user.password_confirmation = "a-temporary-password"
Check if the user object is now valid.
user.valid?
This command should return
true.Save the changes to the user record. This command runs validations and should return
true.user.save!
After saving the user, you should be able to manage or delete them through the Terraform Enterprise UI or by using Solution 1.
Outcome
After following one of the solutions, the affected user accounts are removed from the Terraform Enterprise UI. You can now re-create the users with the correct information.