hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

not validating required shebang for cloud init files #142

Open tcurdt opened 5 years ago

tcurdt commented 5 years ago

Running

flash -f --hostname kube01 \
  --device /dev/disk3 \
  --bootconf kubes-boot.yml \
  --userdata kubes-init.yml \
  ~/Downloads/hypriotos-rpi-v1.9.0.img

bootconf gets applied

hdmi_drive=2 # HDMI sound
hdmi_group=2 # DMT
hdmi_mode=16 # 1024x768 60Hz
overscan_left=10
overscan_right=10
overscan_top=10
overscan_bottom=10
disable_splash=1
gpu_mem=16

using this file

hostname: kube01
locale: "en_US.UTF-8"
timezone: "Europe/Berlin"
manage_etc_hosts: true
apt_preserve_sources_list: true
package_upgrade: false

packages:
 - ntp

runcmd:
  - 'systemctl restart avahi-daemon'

users:
  - name: tcurdt
    primary-group: users
    shell: /bin/bash
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: users,docker,adm
    # password
    plain_text_passwd: tcurdt
    ssh_pwauth: true
    chpasswd: { expire: false }
    lock_passwd: false
    # pubkey
    # lock_passwd: true
    ssh-authorized-keys:
      - ssh-rsa AAAA...VqU2w==

the cloud init gives problems.

When booting it's strange that eth0 is not up. Then the cloud prints

__init__.py[WARNING]: Unhandled non-mulitpart (text/x-not-multipart) userdata: 'b'hostname: kube01'...'

It then waits and eventually creates some keys. Then login appears. Wrong/default hostname though. Then cloud init says en_US.UTF-8... done which means it's not ignoring the file completely (I guess). Then it regenerates a machine id and prints fingerprints for user debian. Later it says no authorized ssh keys fingerprints found for user debian

A little confused I am wondering - are things broken?

Then I found issue #138 and realized that all that was missing was the #cloud-config shebang.

It would be fantastic if this could be checked by the script - and not just that's a valid yml file.