3

Background: I have several RPis which I need to re-image. I use the stock Raspbian and they get their IPs via DHCP. This makes it difficult (in my specific environment) to know which IP they received, and then to configure them.

Today this configuration is automated via Ansible but the first connection is complicated (due to the lack of knowledge of the IP). I would like to move to SaltStack, where the connection is initiated by the client (the RPi in my case).

The question: the SaltStack software still needs to be installed and I would like to "drop" this installation script somewhere on the SD with the image. One thing I do not want to do is to modify the stock Raspbian (rebuild it), just have myinstallation.sh (which would have the relevant commands and configuration) launched either as part of the first boot, or as part of any boot (I would remove it during the configuration).

Is such a functionality available? Or a similar approach?

WoJ
  • 543
  • 2
  • 6
  • 15

1 Answers1

2

As per comments, it is simple enough to create a boot service that runs only once, or runs until some criteria have been satisfied, then it simply disables itself (systemctl disable ...).

However, from the sound of things, you don't want to have to run the image in order to install and enable a new service. Technically this is not necessary; all you have to do to enable a systemd service is create symlink to the service file in an appropriate /etc/systemd/system/ subdirectory (e.g., graphical.target.wants if the system will be running a GUI or multi-user.target.wants otherwise).

If that seems like too much work, rather than adding a file you can replace one: /etc/rc.local, and start whatever from there.

goldilocks
  • 60,325
  • 17
  • 117
  • 234