- if [ -n "$COMPUTE_NODE_PASSWORD" ]; then
- printf "password: ""%s" "$COMPUTE_NODE_PASSWORD" >> $name-userdata.yaml
- printf "\nchpasswd: {expire: False}\n" >> $name-userdata.yaml
- printf "ssh_pwauth: True\n" >> $name-userdata.yaml
+ if [ -n "$password" ]; then
+ if [ -n "$username" ]; then
+ passwd=$(mkpasswd --method=SHA-512 --rounds 4096 "$password")
+ printf "users:" >> $name-userdata.yaml
+ printf "\n - name: ""%s" "$username" >> $name-userdata.yaml
+ printf "\n lock_passwd: False" >> $name-userdata.yaml # necessary to allow password login
+ printf "\n passwd: ""%s" "$passwd" >> $name-userdata.yaml
+ printf "\n sudo: \"ALL=(ALL) NOPASSWD:ALL\"" >> $name-userdata.yaml
+ else
+ printf "password: ""%s" "$password" >> $name-userdata.yaml
+ fi
+ printf "\nchpasswd: {expire: False}\n" >> $name-userdata.yaml
+ printf "ssh_pwauth: True\n" >> $name-userdata.yaml