I am trying to use packer for creating managed images on azure. I want a script to be executed after the VM is launched. Just as in case of AWS instances, a linux instance has
/var/lib/cloud/scripts/per-instance to run scripts once the instance is launched and
per-boot for executing scripts whenever the instance is booted. Similarly, what can be done in case of Ubuntu VM on azure?
If the command should be executed at every reboot, you could add an entry to
@reboot as time to execute.
Or you could use
systemd with an
# /etc/systemd/system/rc-local.service [Unit] After = network-online.target Wants = network-online.target [Service] Type = oneshot RemainAfterExit = yes ExecStart = <your-command> ExecStart = <your-second-command> # ... [Install] WantedBy = multi-user.target
Would specifying the path of a script instead of a command work?
Similarly can we do the same with
systemd? Or is it even possible to write all the commands for
Can we do something like in AWS linux AMI such as adding the file to
per-instance and its executed after the instance is launched. The logs are seen in
Should both be possible.
Could you possibly provide an insight on this approach for a VM (ubuntu)?