Merge "Allow to specify root password when building guest image"
This commit is contained in:
commit
a1275bbc43
@ -0,0 +1,5 @@
|
||||
This element assigns a password to the root account in the image and enables
|
||||
password login via ssh.
|
||||
|
||||
This is useful when booting outside of a cloud environment (e.g. manually via
|
||||
kvm) and for testing.
|
11
integration/scripts/files/elements/root-passwd/post-install.d/99-setup
Executable file
11
integration/scripts/files/elements/root-passwd/post-install.d/99-setup
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$DIB_PASSWORD" ]; then
|
||||
echo "Error during setup password for root"
|
||||
exit 1
|
||||
fi
|
||||
sed -i "s/disable_root: true/disable_root: false/" /etc/cloud/cloud.cfg
|
||||
install-packages augeas-tools openssh-server openssh-client
|
||||
augtool -s set /files/etc/ssh/sshd_config/PasswordAuthentication yes
|
||||
augtool -s set /files/etc/ssh/sshd_config/PermitRootLogin yes
|
||||
augtool -s set /files/etc/ssh/ssh_config/PasswordAuthentication yes
|
||||
echo -e "$DIB_PASSWORD\n$DIB_PASSWORD\n" | passwd
|
@ -13,6 +13,7 @@ function build_guest_image() {
|
||||
local image_output=$5
|
||||
local image_type=${image_output##*.}
|
||||
local working_dir=$(dirname ${image_output})
|
||||
local root_password=${TROVE_ROOT_PASSWORD}
|
||||
|
||||
local elementes="base vm"
|
||||
local trove_elements_path=${PATH_TROVE}/integration/scripts/files/elements
|
||||
@ -60,6 +61,11 @@ function build_guest_image() {
|
||||
elementes="$elementes guest-agent"
|
||||
elementes="$elementes ${guest_os}-docker"
|
||||
|
||||
if [[ -n ${root_password} ]]; then
|
||||
elementes="$elementes root-passwd"
|
||||
export DIB_PASSWORD=${root_password}
|
||||
fi
|
||||
|
||||
# Build the image
|
||||
disk-image-create -x \
|
||||
-a amd64 \
|
||||
|
Loading…
Reference in New Issue
Block a user