Skip to content

Commit 3b42057

Browse files
committed
Improve cloud-init on bare metal article
1 parent 230b8c8 commit 3b42057

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

content/articles/cloud-init/bare-metal-after-boot.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ This article shows how to manually invoke cloud-init on an on-premises machine (
1212

1313
This article is a *starting point*. We'll provide the necessary cloud-init data using a standard HTTP server. You can later add features like HTTPS and dynamic data if needed.
1414

15+
> [!WARNING]
16+
> Cloud-init usually works, but it can sometimes be tricky and frustrating to use.
17+
>
18+
> For example, it may hang or fail to detect the datasource, and troubleshooting these issues - especially when the datasource isn't picked up - can be very difficult.
19+
>
20+
> This is likely because cloud-init was not designed to run after the system has already booted. So keep in mind: it may work, or it may not.
21+
1522
## The Datasource
1623

1724
The **datasource** specifies what cloud-init should do.
@@ -141,15 +148,18 @@ $ curl http://<your-server>:8080/cloud-init/meta-data
141148
After that, you can invoke cloud-init with the following commands:
142149

143150
```sh
144-
$ cloud-init clean --logs --machine-id --seed
145-
$ cloud-init init
146-
$ cloud-init modules --mode=config
147-
$ cloud-init modules --mode=final
148-
$ touch /etc/cloud/cloud-init.disabled
151+
$ cloud-init clean --logs --machine-id --seed # reset cloud-init
152+
$ /usr/lib/cloud-init/ds-identify --force # force datasource detection
153+
$ cloud-init init # run stage 'init'
154+
$ cloud-init modules --mode=config # run stage 'config'
155+
$ cloud-init modules --mode=final # run stage 'final'
156+
$ touch /etc/cloud/cloud-init.disabled # disable cloud-init
149157
```
150158

151159
The first command (`cloud-init clean`) resets cloud-init so it behaves as if it has never run.
152160

161+
After that, we force cloud-init to [detect the datasource](https://cloudinit.readthedocs.io/en/latest/howto/identify_datasource.html) from the config. This command is sometimes necessary (for unknown reasons).
162+
153163
The next three commands execute the [three cloud-init stages](https://cloudinit.readthedocs.io/en/latest/explanation/boot.html): `init`, `config`, and `final`.
154164

155165
The last command ensures cloud-init [doesn't run again](https://cloudinit.readthedocs.io/en/latest/howto/disable_cloud_init.html) the next time the system is rebooted.
@@ -181,3 +191,9 @@ cloud-init status --long
181191
less /var/log/cloud-init.log
182192
less /var/log/cloud-init-output.log
183193
```
194+
195+
## Full Example
196+
197+
I have created a working example that uses the information of this article. You can find it on GitHub:
198+
199+
<https://github.com/skrysm/cloud-init-onprem-poc>

0 commit comments

Comments
 (0)