vmware-tanzu/vm-operator

docs: Provide Dockerfile example for validating Cloud-Init user data

Open

#63 opened on Feb 23, 2023

 (3 comments) (0 reactions) (0 assignees)Go (78 forks)auto 404
documentationgood first issuehelp wanted

Repository metrics

Stars
 (130 stars)
PR merge metrics
 (PR metrics pending)

Description

Getting cloud-init user data correct may prove difficult for users. The following Dockerfile can be used to validate the user data:

FROM ubuntu:latest

RUN apt-get update -y && \
    apt-get install -y cloud-init

ENTRYPOINT [ "cloud-init", "schema", "--config-file", "/cloud-config.yaml" ]

Let's imagine we build the following image from the above Dockerfile:

docker build -t civ .

Now, imagine the following cloud config file exists as "my-config.yaml":

#cloud-config
ssh_pwauth: true
users:
    - default
    - name: vmware
      sudo: ALL=(ALL) NOPASSWD:ALL
      lock_passwd: false
      passwd: '$1$salt$SOC44fVbA/ZxeIwD5yw1u1'
      shell: /bin/bash
write_files:
    - content: |
      "VMSVC Says Hello World"
      path: /helloworld

Let's run the validator on the above file:

$ docker run -it --rm -v $(pwd)/my-config.yaml:/cloud-config.yaml:ro civ
Error:
Cloud config schema errors: format-l13.c7: File /cloud-config.yaml is not valid yaml. while scanning a simple key
  in "<byte string>", line 13, column 7:
          "VMSVC Says Hello World"
          ^
could not find expected ':'
  in "<byte string>", line 14, column 7:
          path: /helloworld
          ^

We should add documentation to this repo's doc area with the above example.

Contributor guide