docs/cloud-init.md
f4d17450
 Overview
 =================
fc7b4b68
 ```cloud-init``` is the defacto multi-distribution package that handles early initialization of a cloud instance.
f4d17450
 
 In-depth documentation for cloud-init is available here: https://cloudinit.readthedocs.org/en/latest/
 
 Supported installations
 =================
fc7b4b68
 ```Photon Container OS (Minimal)```
 
 ```Photon Full OS (All)```
f4d17450
 
 Supported capabilities
 =================
fc7b4b68
 ```Photon``` supports ```cloud-init``` starting with the following capabilities
f4d17450
 <dl>
fc7b4b68
 <dt>```run commands```</dt>
f4d17450
 <dd>execute a list of commands with output to console.</dd>
fc7b4b68
 <dt>```configure ssh keys```</dt>
f4d17450
 <dd>add entry to ~/.ssh/authorized_keys for the configured user</dd>
fc7b4b68
 <dt>```install package```</dt>
f4d17450
 <dd>install additional packages on first boot</dd>
fc7b4b68
 <dt>```configure networking```</dt>
f4d17450
 <dd>update /etc/hosts, hostname etc</dd>
fc7b4b68
 <dt>```write files```</dt>
f4d17450
 <dd>write arbitrary file(s) to disk</dd>
fc7b4b68
 <dt>```add yum repo```</dt>
f4d17450
 <dd>add a yum repository to /etc/yum.repos.d</dd>
fc7b4b68
 <dt>```create groups and users```</dt>
f4d17450
 <dd>add groups and users to the system. set user/group properties</dd>
fc7b4b68
 <dt>```run yum upgrade```</dt>
f4d17450
 <dd>upgrade all packages</dd>
fc7b4b68
 <dt>```reboot```</dt>
f4d17450
 <dd>reboot or power off when done with cloud-init</dd>
 </dl>
 
 Getting Started
 =================
fc7b4b68
 photon cloud config has ```ec2 datasource``` turned on by default so an ```ec2``` configuration is accepted.
 However, for testing, the following methods provide ways to do ```cloud-init``` with ```photon``` standalone.
f4d17450
 
 Using a seed iso
 ----------------
fc7b4b68
 This will be using the ```nocloud``` datasource. In order to init this way, an iso file needs to be created with a meta-data and an user-data file as shown below
 ```
f4d17450
 $ { echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data
 $ printf "#cloud-config\nhostname: testhost\n" > user-data
 $ genisoimage  -output seed.iso -volid cidata -joliet -rock user-data meta-data
fc7b4b68
 ```
f4d17450
 
fc7b4b68
 Attach the above generated seed.iso to your machine and reboot for the init to take effect.
 In this case, the hostname is set to ```testhost```
f4d17450
 
 Using a seed disk file
 ----------------
 To init using local disk files, do the following
fc7b4b68
 ```
f4d17450
 mkdir /var/lib/cloud/seed/nocloud
 cd /var/lib/cloud/seed/nocloud
 $ { echo instance-id: iid-local01; echo local-hostname: cloudimg; } > meta-data
 $ printf "#cloud-config\nhostname: testhost\n" > user-data
fc7b4b68
 ```
f4d17450
 Reboot the machine and the hostname will be set to `testhost`
 
 Frequencies
 -----------
fc7b4b68
 cloud-init modules have pre-determined frequencies. Based on the frequency setting, multiple runs will yield different results.
f4d17450
 For the scripts to run always, remove instances folder before reboot.
fc7b4b68
 ```
f4d17450
 rm -rf /var/lib/cloud/instances
fc7b4b68
 ```
f4d17450
 
 Module frequency info
fc7b4b68
 ------------------------------------
 Name                  |  Frequency
 ----------------------|-------------
f4d17450
 disable_ec2_metadata  | Always
fc7b4b68
 users_groups          | Instance
 write_files           | Instance
 update_hostname       | Always
 final_message         | Always
 resolv_conf           | Instance
 growpart              | Always
 update_etc_hosts      | Always
 power_state_change    | Instance
 phone_home            | Instance