I am trying to run the following preseed file on a ubuntu 16.04 server machine (during a packer build):
d-i preseed/late_command string \
in-target mkdir -v -p -m 0440 "/etc/sudoers.d"; \
in-target echo "%vagrant ALL=(ALL) NOPASSWD: ALL" | tee -a /etc/sudoers.d/vagrant; \
in-target echo "Defaults:vagrant !requiretty" | tee -a /etc/sudoers.d/vagrant; \
in-target chmod 440 /etc/sudoers.d/vagrant;
In /var/log/installer/syslog I can see the following error:
log-output: sh:
log-output: tee: not found
When I change the "| tee -a" part to ">>" like so:
d-i preseed/late_command string \
in-target mkdir -v -p -m 0440 "/etc/sudoers.d"; \
in-target echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant; \
in-target echo "Defaults:vagrant !requiretty" >> /etc/sudoers.d/vagrant; \
in-target chmod 440 /etc/sudoers.d/vagrant;
It suddenly starts complaining it cannot find the directory, without saying anything about the mkdir line - so it's neither creating the directory, nor not finding it:
log-output: sh: can't create /etc/sudoers.d/vagrant: nonexistent directory
log-output: sh: can't create /etc/sudoers.d/vagrant: nonexistent directory
log-output: chmod:
log-output: cannot access '/etc/sudoers.d/vagrant'
log-output: : No such file or directory
I have been looking into other scripts on github. Also I added the following line to the preseed.cfg file:
d-i pkgsel/include string openssh-server coreutils wget sudo
I even tried to install coreutils as in-target command, to make sure tee should be available. Been on this for a few days now, rebuilding ubuntu time after time, only to find the same errors in the syslog. If anyone could shed some light on this - it must be something simple, but I'm not seeing it...