Skip to content

Commit

Permalink
add cloud-init-firstboot service
Browse files Browse the repository at this point in the history
cloud-init-firstboot service will do initial tasks
  * create and set up default user
  * get and process metadata/userdata from datasources
  * disable root login
this service will run once (firstboot)

cloud-init service won't run at the first boot
but it will do at next boot times
	* verify/fix/resize/grow up partitions and filesystems
	* get and process userdata from datasources (TODO: optional)
  • Loading branch information
Julio Montes committed Nov 20, 2015
1 parent 71d7ebe commit 89cbfb4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ depcomp
install-sh
missing
stamp-h1
data/cloud-init.service
data/cloud-init*.service
clr-cloud-init-*.tar.xz
clr-cloud-init-*/
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AM_CFLAGS = -std=gnu99 -fstack-protector -Wall -pedantic \
EXTRA_DIST = \
LICENSE \
COPYING \
data/cloud-init-firstboot.service.in
data/cloud-init.service.in

DISTCHECK_CONFIGURE_FLAGS = \
Expand Down Expand Up @@ -60,7 +61,7 @@ cloud_init_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS) $(YAML_CFLAGS) $(JSON_GLIB_CFLAG
cloud_init_LDADD = $(GLIB_LIBS) $(YAML_LIBS) $(CURL_LIBS) $(JSON_GLIB_LIBS) $(PARTED_LIBS) $(BLKID_LIBS)
SYSTEMD_DIR=$(prefix)/lib/systemd/system/
systemdsystemunitdir = @SYSTEMD_SYSTEMUNITDIR@
systemdsystemunit_DATA = data/cloud-init.service
systemdsystemunit_DATA = data/cloud-init-firstboot.service data/cloud-init.service

systemdsystemunit-install-local:
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/multi-user.target.wants/
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AC_INIT([clr-cloud-init],[2],[dev@clearlinux.org])
AM_INIT_AUTOMAKE([foreign -Wall -Werror -Wno-portability silent-rules subdir-objects color-tests no-dist-gzip dist-xz])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_FILES([Makefile
data/cloud-init-firstboot.service
data/cloud-init.service])
AC_CONFIG_HEADERS([config.h])

Expand Down
19 changes: 19 additions & 0 deletions data/cloud-init-firstboot.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Initial cloud-init job (firstboot)
After=local-fs.target network.target
Before=sshd.service sshd-keygen.service
Requires=network.target
Wants=local-fs.target sshd.service sshd-keygen.service
ConditionFirstBoot=yes

[Service]
Type=oneshot
ExecStart=@prefix@/bin/cloud-init --first-boot
RemainAfterExit=yes
TimeoutSec=0

# Output needs to appear in instance console output
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target
6 changes: 3 additions & 3 deletions data/cloud-init.service.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[Unit]
Description=Initial cloud-init job (metadata service crawler)
Description=cloud-init job
After=local-fs.target network.target
Before=sshd.service sshd-keygen.service
Requires=network.target
Wants=local-fs.target sshd.service sshd-keygen.service
ConditionFirstBoot=yes
ConditionFirstBoot=no

[Service]
Type=oneshot
ExecStart=@prefix@/bin/cloud-init --first-boot
ExecStart=@prefix@/bin/cloud-init
RemainAfterExit=yes
TimeoutSec=0

Expand Down

0 comments on commit 89cbfb4

Please sign in to comment.