I am attempting to grant passwordless sudo privileges to a user created during Ubuntu 14.04 install. However when the image is created none of the changes related to sudo exist. Here are the relevant parts of the preseed file:
# Create Vagrant User
d-i passwd/user-fullname string Vagrant User
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true
# Setup passwordless sudo for vagrant user
d-i preseed/late_command string echo "vagrant ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/vagrant
d-i preseed/late_command string chmod 0440 /target/etc/sudoers.d/vagrant
I have also tried
d-i preseed/late_command string in-target echo "vagrant ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/vagrant
When the image finishes /etc/sudoers.d/vagrant will not exist anywhere.
even if I run the commands:
d-i preseed/late_command string mkdir /stuff
d-i preseed/late_command string in-target mkdir /stuff
the stuff directory will not exist.
I know the commands are being run because I made a typo once and saw an error during install. All other preseed commands seem to be working.
I have read about the in-target directive and that the installer will create a /target that has the finial filesystem however I seem unable to make these work.
using packer I have run a shell script provisioned that does the same echo and that works.
The problem is that a preseed file can only have one preseed/late_command
section, not multiple.
If you need to execute multiple commands, you can have them as a single late_command separated with ;
e.g.
d-i preseed/late_command string \
in-target cmd1 args ... ; \
in-target cmd2 args ... ; \
...
In this particular case, this is what was working for me:
d-i preseed/late_command string \
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /target/etc/sudoers.d/vagrant ; \
in-target chmod 440 /etc/sudoers.d/vagrant ;
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