> On Monday, May 15, 2017 at 3:20:10 AM UTC-7, Denriful wrote:
> consul.service:
> |
> [Unit]
> Description=Setup Consul Cluster
>
> [Service]
> Type=oneshot
> ExecStart=/opt/bin/consul-install.sh
> RemainAfterExit=true
>
> [Install]
> WantedBy=multi-user.target
>
> |
>
> Then the node is booted there is no running consul service
> i need to run "systemctl start consul.service" to start it.
>
> How to run just created systemd service on first boot?
>
If you enable the service file (e.g. using ignition's 'enable' option
when creating it or using `systemctl enable`) it should run on boot boot.
You'll probably also have to have 'After=network-online.target' and
'Requires=network-online.target' in order to ensure the 'wget' in the
script works.
One other cool trick you can use is adding>
ConditionPathExists=!/opt/bin/consul
to the unit which downloads agent so it only runs once.
This assumes you do split out running the agent to its own unit, which
you probably should.
Best,
Euan