Removing install user with Packer

ansiblepackeruser-management

When a VM is first created, it gets an install user that is used to run the provisioning. I want to remove this user at the last step because it's not necessarily secure and it's unnecessary. However, Packer runs all of the provisioners as this user. I've tried using Ansible, but it still seems to be using this user in some capacity and thus the Ansible playbook cannot actually remove it without failing (saying that there programs still running as the given user). Rather than bumble around, I'm asking if anyone has any ideas as to how to achieve this goal, which should be simple and has turned out not to be.

Best Answer

Schedule a cron job to remove the user with @reboot option or add a few lines to rc scripts to do the same.