Skip to content

Commit

Permalink
systemd/system: add oem cloud init service
Browse files Browse the repository at this point in the history
these services, based on the ignition execution result will enable or
not cloudinit based on OEM.

Signed-off-by: Mathieu Tortuyaux <[email protected]>
Co-authored-by: Kai Lüke <[email protected]>
  • Loading branch information
tormath1 and pothos committed Mar 2, 2022
1 parent 5f97a6a commit 31f97d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions systemd/system/enable-oem-cloudinit.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Enable cloudinit

[Service]
Type=oneshot
StandardInput=file:/etc/.ignition-result.json
ExecCondition=/usr/bin/jq -e '.userConfigProvided == false'
ExecCondition=/usr/bin/jq -e '.provisioningBootID | gsub(\"-\"; \"\") | . == $id' --arg id %b
ExecStart=/usr/bin/systemctl enable --now oem-cloudinit.service
RemainAfterExit=true

[Install]
WantedBy=multi-user.target
11 changes: 11 additions & 0 deletions systemd/system/oem-cloudinit.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Run cloudinit

[Service]
EnvironmentFile=/var/run/ignition.env
Type=oneshot
ExecCondition=/usr/bin/bash -xc 'OEMS=(aws gce rackspace-onmetal azure cloudsigma packet vmware digitalocean); echo $${OEMS[*]} | tr " " "\n" | grep -q -x -F "${OEM_ID}"'
ExecStart=/usr/bin/bash -xc '/usr/bin/coreos-cloudinit --oem="$(if [ "${OEM_ID}" = aws ]; then echo ec2-compat; else echo "${OEM_ID}" ; fi)"'

[Install]
WantedBy=multi-user.target

0 comments on commit 31f97d7

Please sign in to comment.