Exemplo de cloud-config
#cloud-config
repo_update: true
repo_upgrade: all
package_upgrade: true
packages:
- httpd24
- php56
- mysql55-server
- php56-mysqlnd
runcmd:
- service httpd start
- chkconfig httpd on
- groupadd www - [ sh, -c, "usermod -a -G www ec2-user" ]
- [ sh, -c, "chown -R root:www /var/www" ]
- chmod 2775 /var/www
- [ find, /var/www, -type, d, -exec, chmod, 2775, {}, + ]
- [ find, /var/www, -type, f, -exec, chmod, 0664, {}, + ]
- [ sh, -c, 'echo "" > /var/www/html/phpinfo.php' ]
Exemplo de utilização do User-Data
AWS : https://docs.aws.amazon.com/pt_br/AWSEC2/latest/UserGuide/user-data.html
OpenStack : https://docs.openstack.org/nova/queens/user/user-data.html
$ openstack server create --image ubuntu-cloudimage --flavor 1 \
--user-data mydata.file VM_INSTANCE
Obs: É possível executar diretamente um bash no cloud-init
#!/bin/bash
echo “Sua execução”
Oficial : http://cloud-init.org/
== Documentos: ==
* http://cloudinit.readthedocs.io/en/latest/
* http://cloudinit.readthedocs.io/en/latest/topics/hacking.html
* http://cloudinit.readthedocs.io/en/latest/topics/examples.html
* https://help.ubuntu.com/community/CloudInit
* https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/4/html/End_User_Guide/user-data.html
* https://raymii.org/s/tutorials/Automating_Openstack_with_Cloud_init_run_a_script_on_VMs_first_boot.html
* Ubuntu Cloud-Init : https://www.youtube.com/watch?v=-zL3BdbKyGY