Package: openstack-debian-images
Version: 0.9
Severity: wishlist

Dear Maintainer,
I'd like to introduce a new option to this package. This would allow to
change the default ("debian") user name created by cloud-init when it is
run. 

This patch introduce the option --login to this intent.

Configure the user login for the default cloud-init user


-- System Information:
Debian Release: 7.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages openstack-debian-images depends on:
ii  debootstrap      1.0.48+deb7u1
ii  dpkg             1.16.15
ii  extlinux         2:4.05+dfsg-6+deb7u1
ii  initramfs-tools  0.109.1
ii  kpartx           0.4.9+git0.4dfdaf2b-7~deb7u2
ii  mbr              1.1.11-5+b1
ii  parted           2.3-12
ii  qemu-utils       1.1.2+dfsg-6a+deb7u3

openstack-debian-images recommends no packages.

openstack-debian-images suggests no packages.

-- no debconf information
diff --git a/build-openstack-debian-image b/build-openstack-debian-image
index 65e6eb7..573ad1d 100755
--- a/build-openstack-debian-image
+++ b/build-openstack-debian-image
@@ -14,6 +14,7 @@ Options are:
  --image-size|-is <image-size> (default: 1G)
  --automatic-resize|-ar
  --automatic-resize-space|-ars <suplementary-space> (default: 50M)
+ --login|-l <userlogin> (default: debian)
  --password|-p <root-password> (dangerous option: avoid it if possible)
 For more info: man $0"
 	exit 1
@@ -97,6 +98,15 @@ for i in $@ ; do
 			usage
 		fi
 	;;
+	"--login"|"-l")
+		if [ -z "${2}" ] ; then
+			echo "No parameter defining the user login"
+			usage
+		fi
+		USER_LOGIN=${2}
+		shift
+		shift
+	;;
 	"--password"|"-p")
 		if [ -z "${2}" ] ; then
 			echo "No parameter defining the root password"
@@ -129,6 +139,9 @@ fi
 if [ -z "${AUTOMATIC_RESIZE_SPACE}" ] ; then
 	AUTOMATIC_RESIZE_SPACE=50
 fi
+if [ -z "${USER_LOGIN}" ] ; then
+	USER_LOGIN=debian
+fi
 
 NEEDED_PACKAGES=sudo,adduser,locales,extlinux,openssh-server,linux-image-amd64,euca2ools,file,kbd
 if [ "${RELEASE}" = "jessie" ] ; then
@@ -216,8 +229,8 @@ fi
 # is always the same.
 sed -i "s/PermitRootLogin yes/PermitRootLogin without-password/" ${MOUNT_DIR}/etc/ssh/sshd_config
 
-# Add a default "debian" user which is used by cloud-init by default
-chroot ${MOUNT_DIR} adduser --gecos Debian-cloud-init-user --disabled-password --quiet debian
+# Add a default user which is used by cloud-init by default
+chroot ${MOUNT_DIR} adduser --gecos Cloud-init-user --disabled-password --quiet ${USER_LOGIN}
 
 # Adds the "debian" user to sudoers, since that is the way
 # cloud-init grant access
@@ -326,6 +339,9 @@ datasource_list: [ Ec2 ]" >${MOUNT_DIR}/etc/cloud/cloud.cfg.d/90_dpkg.cfg
 echo "mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2']" >>${MOUNT_DIR}/etc/cloud/cloud.cfg
 echo "manage_etc_hosts: true" >>${MOUNT_DIR}/etc/cloud/cloud.cfg
 
+# Set the cloud init default user (required for the keypair to be put in the right home directory)
+sed -i "s/name: debian/name: ${USER_LOGIN}/" ${MOUNT_DIR}/etc/cloud/cloud.cfg
+
 # Setting-up initramfs
 chroot ${MOUNT_DIR} update-initramfs -u
 
diff --git a/build-openstack-debian-image.1 b/build-openstack-debian-image.1
index ec1b6b7..2ae2496 100644
--- a/build-openstack-debian-image.1
+++ b/build-openstack-debian-image.1
@@ -19,11 +19,13 @@ during the boot process, cloud\-init will resize the root partition on the fly
 recent kernel allow that for ext3).
 
 Cloud\-init is setup to use an Ec2 metadata server, which is what OpenStack is
-compatible with. A "debian" user will be used to receive the ssh key from the
-user data blob. This user is setup without a password (eg: adduser
-\-\-disabled\-password).  Once logged as this "debian" user in your new virtual
-machine, you can "sudo" to root from that user, without needing a password. The
-root password is "password" by default, and ssh into the root user without
+compatible with. A "debian" (configurable with the use of the
+.B --login
+option) user will be used to receive the ssh key from the user data blob.
+This user is setup without a password (eg: adduser \-\-disabled\-password).
+Once logged as this "debian" user in your new virtual machine, you can
+"sudo" to root from that user, without needing a password. The root
+password is "password" by default, and ssh into the root user without
 using an ssh keypair is disabled by default (PermitRootLogin without-password
 is set in /etc/ssh/sshd_config).
 
@@ -115,6 +117,13 @@ to the minimum. If this option is ommited, then 50G is used. If
 isn't used, then it is useless to set this option, which will be ignored.
 
 .LP
+.B \-\-login|\-l
+.I <user-login>
+.IP
+
+Change the login name (default to debian) for the user created by Cloud-Init.
+
+.LP
 .B \-\-password|\-p
 .I <root-password>
 .IP

Reply via email to