- kubectl patch baremetalhost $name -n metal3 --type merge \
- -p '{"spec":{"image":{"url":"","checksum":""}}}'
-}
-
-function set_compute_ssh_config {
- get_default_interface_ipaddress default_addr
- cat << EOF
-- path: /root/.ssh/config
- owner: root:root
- permissions: '0600'
- content: |
- Host bootstrapmachine $default_addr
- HostName $default_addr
- IdentityFile /opt/ssh_id_rsa
- User $USER
-- path: /etc/apt/sources.list
- owner: root:root
- permissions: '0665'
- content: |
- deb [trusted=yes] ssh://$USER@$default_addr:$LOCAL_APT_REPO ./
-EOF
-}
-
-# documentation for the values below may be found at
-# https://cloudinit.readthedocs.io/en/latest/topics/modules.html
-function create_userdata {
- name="$1"
- username="$2"
- password="$3"
- COMPUTE_NODE_FQDN="$name.akraino.icn.org"
-
- # validate that the user isn't expecting the deprecated
- # COMPUTE_NODE_PASSWORD to be used
- if [ "$password" != "${COMPUTE_NODE_PASSWORD:-$password}" ]; then
- cat <<EOF
-COMPUTE_NODE_PASSWORD "$COMPUTE_NODE_PASSWORD" not equal to nodes.json $name password "$password".
-Unset COMPUTE_NODE_PASSWORD and retry.
-EOF
- exit 1
- fi
-
- printf "#cloud-config\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
- fi
-
- if [ -n "$COMPUTE_NODE_FQDN" ]; then
- printf "fqdn: ""%s" "$COMPUTE_NODE_FQDN" >> $name-userdata.yaml
- printf "\n" >> $name-userdata.yaml
- fi
- printf "disable_root: false\n" >> $name-userdata.yaml
- printf "ssh_authorized_keys:\n - " >> $name-userdata.yaml
-
- if [ ! -f $HOME/.ssh/id_rsa.pub ]; then
- yes y | ssh-keygen -t rsa -N "" -f $HOME/.ssh/id_rsa