Skip to content
Snippets Groups Projects
agent_userdata.tmpl 1003 B
Newer Older
#cloud-config

# SSH config
no_ssh_fingerprints: false
ssh:
  emit_keys_to_console: false

# update and upgrade instance
Rob Kooper's avatar
Rob Kooper committed
package_update: true
package_upgrade: true

# files to be created on the system
write_files:
- path: /etc/rancher/rke2/config.yaml
  permissions: "0600"
  owner: root:root
  content: |
    server: https://${rke2_server_0_private_ip}:9345
    token: ${rke2_secret}
- path: /opt/rke2/run_rke2.sh
  permissions: "0755"
  owner: root:root
  content: |
    #!/bin/bash
    %{ for ip in rke2_private_ip }
    echo "${ip} ${name} $$(hostname) $$(hostname -f)"  >> /etc/hosts
    %{ endfor }
    while ! ping -c 1 -w 0  mirrorlist.centos.org > /dev/null ; do echo "Sleep 10s"; sleep 10; done
    yum -y install iscsi-initiator-utils nfs-utils
    curl -sfL https://get.rke2.io | INSTALL_RKE2_VERSION="${rke2_version}" INSTALL_RKE2_TYPE="agent" sh -
    systemctl enable rke2-agent
    systemctl start rke2-agent

# run this command once the system is booted
runcmd:
- /opt/rke2/run_rke2.sh