Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Presentation in FRAOSUG on the 18th of Mai 2021

Was ist es?

  • Dateiformat zum Automatisieren von Installationen in einer Cloud Umgebung
  • Script ausfuehrungs umgebung nach firstboot
  • Framework zum custom images vorbereiten (appliance vendor)

Wo findet man das normalerweise?

  • Cloud Umgebungen AWS, Azure, DigitalOcean, OpenStack, Alibaba…

Konzepte

  • Datasources
  • Metadata
  • userData
  • network config
  • Datasource Chaining

Beispiel Linux VM mit NoCloud Datasource auf bHyve und OpenIndiana

Images

Convert QCOW

qemu-img convert -O raw bionic-server-cloudimg-amd64.img bionic-server-cloudimg-amd64.raw.img

Docs

bHyve Init Patch

  • included in April Updates

Demo mit config

Zoneconfig

create -b
set zonepath=/zones/vmname
set brand=bhyve
set autoboot=false
set ip-type=exclusive
add fs
set dir="/vm/iso"
set special="/vm/iso"
set type="lofs"
add options ro
add options nodevices
end
add net
set physical="vmnamel0"
end
add device
set match="/dev/zvol/rdsk/rpool/vm/vmnamed0"
end
add attr
set name="bootdisk"
set type="string"
set value="rpool/vm/vmnamed0"
end
add attr
set name="acpi"
set type="string"
set value="off"
end
add attr
set name="ram"
set type="string"
set value="12G"
end
add attr
set name="vcpus"
set type="string"
set value="4"
end
add attr
set name="cdrom"
set type="string"
set value="/vm/iso/vmname-seed.iso"
end

Copy image to ZVOL

dd if=/vm/images/bionic-server-cloudimg-amd64.raw.img of=/dev/zvol/rdsk/rpool/vm/vmnamed0 bs=1M

Metadata

instance-id: iid-d2103519-4a23-e6b9-a2de-bc650f669e86
local-hostname: vmname

userData

#cloud-config

users:
  - name: toasty
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_authorized_keys:
      - ssh-rsa <snip>
    groups: admin
    passwd: "<snip>"
    lock_passwd: false
    shell: "/bin/bash"

package_update: true
package_upgrade: true

growpart:
  mode: auto
  devices: ['/']

Network config

version: 1
config:
   - type: physical
     name: vmnamel0
     mac_address: "<snip>"
     subnets:
        - type: static
          address: <snip>
          netmask: <snip>
          gateway: <snip>
   - type: nameserver
     address:
        - 9.9.9.9
        - 149.112.112.112
     search:
        - domain.example

Iso bauen

genisoimage -output vmname-seed.iso -volid cidata -joliet -rock user-data meta-data network-config

Chaining moeglichkeit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment