By looking at runcmd code (/usr/lib/python2.6/site-packages/cloudinit/config/cc_runcmd.py) I noticed there's no 'frequency' specified in comparison to other. Beside the only thing that scripts does is to save the scripts given as shells script under /var/lib/cloud/instance/scripts/runcmd .
So if I verbosely specify the modules, I MUST set the frequency.
cloud_config_modules:
- mounts
- locale
- set-passwords
- timezone
- [ runcmd, always ]
cloud_final_modules:
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- [ scripts-user, always ]
- ssh-authkey-fingerprints
and the scripts created by this particular can be run by 'scripts-user', so I need to specify i.e.
- [ scripts-user, always ]
to make runcmd scripts working
Is it proper way to do so ? The documentation (at least current 0.7.7) lacks proper explanation of runcmd and user-scripts and how they can be utilized
I also don't understand difference between all the mode, once (first time the instance boot), instance(???), always ( that I understand), ????boot(that one exist? it doesn't seem to work...
EDIT:
ok, i have found in cloudinit/settings.py:
# Valid frequencies of handlers/modules
PER_INSTANCE = "once-per-instance"
PER_ALWAYS = "always"
PER_ONCE = "once"
and beside I found an explanation in this script:
[root@euca-10-254-97-216 ~]# cloud-init-per -h
Usage: cloud-init-per frequency name cmd [ arg1 [ arg2 [ ... ] ]
run cmd with arguments provided.
This utility can make it easier to use boothooks or bootcmd
on a per "once" or "always" basis.
If frequency is:
* once: run only once (do not re-run for new instance-id)
* instance: run only the first boot for a given instance-id
* always: run every boot
But I don't catch the difference between 'once' and 'instance'. So if the same image (rather snapshot) with new instance id in the case 'once' it won't start ? in case 'instance' it will ?
Cloud-init config is provided in two places: /etc/cloud/cloud. cfg. /etc/cloud/cloud.
cloud-init is a software package that automates the initialization of cloud instances during system boot. You can configure cloud-init to perform a variety of tasks. Some sample tasks that cloud-init can perform include: Configuring a host name. Installing packages on an instance.
So cloud-init will retrieve your user-data from an attached ISO image (from a file named user-data. txt ). When cloud-init runs, it will typically populate /var/lib/cloud-init/instance with any information retrieved from the cloud provider, so you should find a copy of the user data in that directory.
By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched.
I think the difference matters if you are creating an image that will be used to launch more instances.
Imagine you run the cloud-init scripts to set an instance. Later you make an image of that instance from which you can launch more instances.
When you start a new instance from the image:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With