Subject: alpine linux v3.18 + pxe (ram live) + cloud-init (tiny-cloud) = install

From: don Rumata <[email-masked]>
Date: Thu, 9 Nov 2023 16:34:03 +0300

Hi!

How can I make it so that cloud-init is executed on pxe boot? Here is my 
file structure and settings:

pxe config:

```
label alpine-with-scipt
     menu label Alpine with my script
     kernel alpine-installer/boot/vmlinuz-lts
     initrd alpine-installer/boot/initramfs-lts
     append modules=loop,squashfs,sd-mod,usb-storage 
modloop=http://10.10.10.10/alpine-installer/boot/modloop-lts 
alpine_repo=alpine_repo=http://dl-cdn.alpinelinux.org/alpine/latest-stable/main 
ssh_key=http://10.10.10.10/soft/authorized_keys ip=dhcp 
apkovl=http://10.10.10.10/cloud-init/tmp/alpine-test-01.tar.gz
```

I added 
ds=nocloud-net;s=http://10.10.10.10/cloud-init/tmp/var/lib/cloud, but it 
didn't work

`alpine-test-01.tar.gz`:

tree structure:

```
.
├── etc
│   ├── apk
│   │   └── world
│   ├── cloud
│   │   └── cloud.cfg
│   ├── init.d
│   │   └── local.stop
│   ├── network
│   │   └── interfaces
│   ├── runlevels
│   │   └── default
│   │       └── local.stop -> /etc/init.d/local.stop
│   └── tiny-cloud.conf
└── var
     └── lib
         └── cloud
             └── user-data
```

`./etc/apk/world`:

```
tiny-cloud
tiny-cloud-alpine
tiny-cloud-openrc
tiny-cloud-nocloud
tiny-cloud-network
nano
htop

# https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud#requirements
e2fsprogs-extra
openssh-server
partx
sfdisk
yx
```

`./etc/init.d/local.stop`:

```
#!/sbin/openrc-run

start () {
tiny-cloud --enable
}
```

`./etc/network/interfaces`:

```
iface eth0 inet dhcp
     udhcpc_opts -O search
```

`./etc/tiny-cloud.conf`:

```
# Tiny Cloud configuration
# /etc/tiny-cloud.conf

# REQUIRED: The instance's cloud provider
# valid: aws, azure, gcp, oci, nocloud
CLOUD=nocloud

TINY_CLOUD_LOGS=/var/log
```

`./var/lib/cloud/user-data`:

```
#cloud-config

cloud_final_modules:
   - rightscale_userdata
   - scripts-per-once
   - scripts-per-boot
   - scripts-per-instance
   - scripts-user
   - keys-to-console
   - phone-home
   - final-message
   - always

packages:
   install:
   - mc

#autoinstall:
# user-data:
write_files:
       - path: /etc/22222222222
         content: |
           qweasdzxcqweasdzxc
runcmd:
   - touch /etc/runcmd_$(date)

chpasswd:
   list: |
      root:myrootpassword
      cloud-user:mypassword
   expire: False
```

---

From: Natanael Copa <[email-masked]>
Date: Thu, 9 Nov 2023 16:51:22 +0100

On Thu, 9 Nov 2023 16:34:03 +0300

> file structure and settings:

FYI, there are cloud-init and tiny-cloud. It looks like you are trying
to use tiny-cloud. doing that from pxe boot is currently not supported,
but should be relatively easy to fix.

Could you please add an issue to
https://gitlab.alpinelinux.org/alpine/mkinitfs/-/issues

I think we can make this work without needing any apkovl, we simply
need to make the initramfs enable tiny-cloud when it finds `ds=...`,
similar to what we do when it finds cidata disk label.

Thanks!
-nc
> ds=nocloud-net;s=http://10.10.10.10/cloud-init/tmp/var/lib/cloud, but
> it didn't work
> 
> `alpine-test-01.tar.gz`:
> 
> tree structure:
> 
> ```
> .
> *** etc
> *   *** apk
> *   *   *** world
> *   *** cloud
> *   *   *** cloud.cfg
> *   *** init.d
> *   *   *** local.stop
> *   *** network
> *   *   *** interfaces
> *   *** runlevels
> *   *   *** default
> *   *       *** local.stop -> /etc/init.d/local.stop
> *   *** tiny-cloud.conf
> *** var
>      *** lib
>          *** cloud
>              *** user-data
> ```
> 
> `./etc/apk/world`:
> 
> ```
> tiny-cloud
> tiny-cloud-alpine
> tiny-cloud-openrc
> tiny-cloud-nocloud
> tiny-cloud-network
> nano
> htop
>

---

From: don Rumata <[email-masked]>
Date: Fri, 10 Nov 2023 12:35:11 +0300

Done: https://gitlab.alpinelinux.org/alpine/mkinitfs/-/issues/49