-
-
Save kgrvamsi/01e846da6ee9c41a166909d1271da7ab to your computer and use it in GitHub Desktop.
cloud-init config creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Bridge for VMs (default on Fedora is virbr0) | |
| BRIDGE=virbr0 | |
| # Cloud init files | |
| USER_DATA=user-data | |
| META_DATA=meta-data | |
| CI_ISO=$1-cidata.iso | |
| # cloud-init config: set hostname, remove cloud-init package, | |
| # and add ssh-key | |
| cat > $USER_DATA << _EOF_ | |
| #cloud-config | |
| # Hostname management | |
| preserve_hostname: False | |
| hostname: $1 | |
| fqdn: $1.example.local | |
| # Remove cloud-init when finished with it | |
| runcmd: | |
| - [ yum, -y, remove, cloud-init ] | |
| # Configure where output will go | |
| output: | |
| all: ">> /var/log/cloud-init.log" | |
| # configure interaction with ssh server | |
| ssh_svcname: ssh | |
| ssh_deletekeys: True | |
| ssh_genkeytypes: ['rsa', 'ecdsa'] | |
| # Install my public ssh key to the first user-defined user configured | |
| # in cloud.cfg in the template (which is centos for CentOS cloud images) | |
| ssh_authorized_keys: | |
| - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBil2QzORhDcnKiVVNpO5daOSYVp8nshcIc7aTEkdlqCRir2Oni8BEStK7x7bvh0jrp9KptlHPeos87fQs//VXEb1FEprL2c6fPWmVdtjmYw3yzSkaFKMksL7FdUoEiwF6t8pQAg2mU0Qj9emSHBKg5ttdGqNoSvXc92k7iOzgauda7jdNak+Dx9dPhR3FJwHMcZSlQHO4cweZcK63bZitxlFkJ/FJdry/TBirDhRcXslOJ3ECU2xiyRXJVPs3VNLjMdOTTAoMmZj+GraUBbQ9VIqe683xe02sM83th5hj2C4gW3qXUoFkNLfKAMRxXLRMEwI3ABFB/AAUhACxyTJp giovanni@throwaway | |
| _EOF_ | |
| echo "instance-id: $1; local-hostname: $1" > $META_DATA | |
| # Create CD-ROM ISO with cloud-init config | |
| echo "$(date -R) Generating ISO for cloud-init..." | |
| genisoimage -output $CI_ISO -volid cidata -joliet -r $USER_DATA $META_DATA &>> $1.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment