/
usr
/
share
/
doc
/
cloud-init
/
examples
/
/usr/share/doc/cloud-init/examples
mkdir
upload
Name
Size
Mode
Actions
seed/
-
0755
rm
boothook.txt
80
0644
edit
dl
rm
cloud-config-add-apt-repos.txt
1573
0644
edit
dl
rm
cloud-config-ansible-controller.txt
7363
0644
edit
dl
rm
cloud-config-ansible-managed.txt
3823
0644
edit
dl
rm
cloud-config-ansible-pull.txt
341
0644
edit
dl
rm
cloud-config-apt.txt
12994
0644
edit
dl
rm
cloud-config-archive-launch-index.txt
802
0644
edit
dl
rm
cloud-config-archive.txt
239
0644
edit
dl
rm
cloud-config-boot-cmds.txt
406
0644
edit
dl
rm
cloud-config-ca-certs.txt
1184
0644
edit
dl
rm
cloud-config-chef-oneiric.txt
3455
0644
edit
dl
rm
cloud-config-chef.txt
4203
0644
edit
dl
rm
cloud-config-datasources.txt
2322
0644
edit
dl
rm
cloud-config-disk-setup.txt
9084
0644
edit
dl
rm
cloud-config-gluster.txt
456
0644
edit
dl
rm
cloud-config-install-packages.txt
383
0644
edit
dl
rm
cloud-config-launch-index.txt
570
0644
edit
dl
rm
cloud-config-lxd.txt
1814
0644
edit
dl
rm
cloud-config-mount-points.txt
1504
0644
edit
dl
rm
cloud-config-ntp.txt
835
0644
edit
dl
rm
cloud-config-reporting.txt
335
0644
edit
dl
rm
cloud-config-run-cmds.txt
963
0644
edit
dl
rm
cloud-config-ssh-keys.txt
2289
0644
edit
dl
rm
cloud-config-update-apt.txt
229
0644
edit
dl
rm
cloud-config-update-packages.txt
93
0644
edit
dl
rm
cloud-config-user-groups.txt
6823
0644
edit
dl
rm
cloud-config-wireguard.txt
1183
0644
edit
dl
rm
cloud-config-write-files.txt
1078
0644
edit
dl
rm
cloud-config-yum-repo.txt
897
0644
edit
dl
rm
cloud-config.txt
16559
0644
edit
dl
rm
include-once.txt
353
0644
edit
dl
rm
include.txt
434
0644
edit
dl
rm
kernel-command-line.txt
1029
0644
edit
dl
rm
network-config-v1-bonded-pair.yaml
428
0644
edit
dl
rm
network-config-v1-bonded-vlan.yaml
508
0644
edit
dl
rm
network-config-v1-bridge.yaml
638
0644
edit
dl
rm
network-config-v1-multiple-vlan.yaml
1208
0644
edit
dl
rm
network-config-v1-nameserver.yaml
403
0644
edit
dl
rm
network-config-v1-physical-3-nic.yaml
443
0644
edit
dl
rm
network-config-v1-physical-dhcp.yaml
100
0644
edit
dl
rm
network-config-v1-route.yaml
321
0644
edit
dl
rm
network-config-v1-subnet-dhcp.yaml
151
0644
edit
dl
rm
network-config-v1-subnet-multiple.yaml
364
0644
edit
dl
rm
network-config-v1-subnet-routes.yaml
527
0644
edit
dl
rm
network-config-v1-subnet-static.yaml
348
0644
edit
dl
rm
network-config-v1-vlan.yaml
253
0644
edit
dl
rm
part-handler-v2.txt
1562
0644
edit
dl
rm
part-handler.txt
2081
0644
edit
dl
rm
plain-ignored.txt
68
0644
edit
dl
rm
user-script.txt
125
0644
edit
dl
rm
Edit:
/usr/share/doc/cloud-init/examples/part-handler-v2.txt
(1562B)
#part-handler # vi: syntax=python ts=4 # this is an example of a version 2 part handler. # the differences between the initial part-handler version # and v2 is: # * handle_part receives a 5th argument, 'frequency' # frequency will be either 'always' or 'per-instance' # * handler_version must be set # # A handler declaring version 2 will be called on all instance boots, with a # different 'frequency' argument. handler_version = 2 def list_types(): # return a list of mime-types that are handled by this module return(["text/plain", "text/go-cubs-go"]) def handle_part(data, ctype, filename, payload, frequency): # data: the cloudinit object # ctype: '__begin__', '__end__', or the specific mime-type of the part # filename: the filename for the part, or dynamically generated part if # no filename is given attribute is present # payload: the content of the part (empty for begin or end) # frequency: the frequency that this cloud-init run is running for # this is either 'per-instance' or 'always'. 'per-instance' # will be invoked only on the first boot. 'always' will # will be called on subsequent boots. if ctype == "__begin__": print(f"my handler is beginning, frequency={frequency}") return if ctype == "__end__": print(f"my handler is ending, frequency={frequency}") return print(f"==== received ctype={ctype} filename={filename} ====") print(payload) print(f"==== end ctype={ctype} filename={filename}")
Save
cmd:
run