I continually find that certain things "just don't work" when run as preseed/late_command in an Ubuntu Bionic preseed file. (The same applies to autoinstall for Ubuntu Focal.) In this particular case, I'm attempting to run an Ansible Role (specifically, the Canonical Ubuntu 18.04 LTS for Ansible STIG) against the target as a late_command:
d-i preseed/late_command string \
in-target /usr/bin/curl -fsSL -o /opt/stig.zip {{ di_preseed.stig_role_url }}; \
in-target /usr/bin/unzip -qq /opt/stig.zip -d /opt; \
in-target /usr/bin/unzip -qq /opt/ubuntu1804STIG-ansible.zip -d /opt; \
in-target /bin/sh -c -- 'cd /opt && ANSIBLE_LOG_PATH=/var/log/ansible.log /bin/sh enforce.sh'
Here enforce.sh is just a wrapper around ansible-playbook.
This install from ISO on Virtualbox fails with:
Failed to run preseeded command ... <command> finished with exit code 2
I am still able to log in to the box as ubuntu and become root. I see that Ansible was successfully installed (it is originally specified in pkgsel/include).
I then open up /var/log/installer/syslog on the target and find that ansible-playbook failed when it could not find rsyslog.service:
This is confusing as rsyslog.service is most certainly enabled and active after the install, which I can confirm with systemctl (status|is-active) rsyslog.
So what I'm seeking to understand here is:
- Why is Ansible unable to find
rsyslog.serviceduring install even though it appears to be enabled? - What factors are different about the installation that result in things seeming to commonly break or not be available?
- Would I be better of running this as an onboot script under init.rc, then last line it removes itself after done?
Related: Certain commands (e.g. modprobe or usermod) fail as late-commands in Ubuntu autoinstall
