I am provisioning a vagrant machine using ansible;
The question is whether it is possible to run some kind of post-processing (either in ansible or in any other form of vagrant provisioning) so as to remove the vagrant user at the end of the day (or at least disable it)?
Will this break the vagrant process/provisioning itself?
This Vagrantfile demonstrates it's possible:
$script = <<-SCRIPT
useradd -m -p $(openssl passwd -1 password) user
usermod --expiredate 1 vagrant
sed -i "s/^PasswordAuthentication no$/PasswordAuthentication yes/" /etc/ssh/sshd_config
service sshd restart
SCRIPT
VAGRANTFILE_API_VERSION = '2'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/bionic64'
config.vm.provision 'shell', inline: $script
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With