diff --git a/doc/rtd/explanation/format/mime.rst b/doc/rtd/explanation/format/mime.rst index 829367eb964..f5ecfa040bc 100644 --- a/doc/rtd/explanation/format/mime.rst +++ b/doc/rtd/explanation/format/mime.rst @@ -77,4 +77,27 @@ Create user-data containing 3 shell scripts: $ cloud-init devel make-mime -a always.sh:x-shellscript-per-boot -a instance.sh:x-shellscript-per-instance -a once.sh:x-shellscript-per-once +Per-frequency shell scripts +--------------------------- + +Cloud-init supports three MIME content types for controlling how often a +shell script runs, corresponding to the run frequencies described in +:ref:`module_frequency`: + +``text/x-shellscript-per-boot`` + The script runs on **every boot**. Useful for tasks that must be + repeated each time the instance starts, such as mounting ephemeral + storage or refreshing dynamic configuration. + +``text/x-shellscript-per-instance`` + The script runs **once per instance-id**. A new instance-id is + assigned each time a new instance is provisioned. + +``text/x-shellscript-per-once`` + The script runs **once**, tracked by a semaphore in + :file:`/var/lib/cloud/sem`. If cloud-init state is preserved — for + example, when an image is created from a running instance — the + semaphore persists and the script will not run again on instances + booted from that image. + .. _make-mime: https://github.com/canonical/cloud-init/blob/main/cloudinit/cmd/devel/make_mime.py