Cloud Init - XCP, proxy

Cloud init xcp-ng proxy

Remember:

  • add http_proxy and https_proxy to the environment

  • add no_proxy to the environment

  • add privateInterface and privateAddress to the host if needed

  • ensure that there is default route on interface

  • consider firewall settings

#cloud-config
users:
 - name: root
   lock_passwd: false
   ssh_authorized_keys:
     - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKcGHk43LnUeM4MZne9Za3R3iA7mvFNI10AKcOtID2i+ user@key
write_files:
  - path: /etc/NetworkManager/system-connections/enX0.nmconnection
    owner: root:root
    permissions: '0600'
    content: |
      [connection]
      id=enX0
      type=ethernet
      autoconnect-priority=-999
      interface-name=enX0

      [ethernet]

      [ipv4]
      address1=10.0.0.10/27,10.0.0.1
      dns=10.0.0.11;10.0.0.12;
      method=manual
      route1=10.0.0.96/12,10.0.0.180

      [ipv6]
      addr-gen-mode=eui64
      method=auto

      [proxy]
  - path: /etc/bashrc
    content: |
      psg() {
      /bin/ps -ef |grep $* | grep -v grep | grep -v /usr/local/bin/psg
      }
      l() {
      ls -alh
      }
    append: true
runcmd:
  - [ systemctl, disable, --now, --no-block, firewalld ]
  - localectl set-locale C.UTF-8
  - grubby --update-kernel ALL --args selinux=0
  - setenforce 0
  - |
    cat >> /etc/hosts <<EOF
    10.0.0.10 k0adm02
    10.0.0.11 k0adm03
    10.0.0.12 k0wrk03
    10.0.0.13 k0wrk02
    10.0.0.14 k0wrk01
    10.0.0.15 k0adm01
    EOF
  - [ nmcli, general, hostname, {name} ]
  - rm -rf /etc/machine-id
  - rm -rf /var/lib/dbus/machine-id
  - systemd-machine-id-setup
  - nmcli connection reload
  - nmcli connection up enX0
  - [ systemctl, restart, --no-block, sshd ]
  - swapoff -a
  - sed -e '/swap/ s/^#*/#/' -i /etc/fstab
  - systemctl mask swap.target
  - systemctl enable xe-linux-distribution --now