ããã«ã¡ã¯ï¼AWSãã¼ã ã®æ³ç¬ã§ãï¼
ã©ãããæè¿å¼ç¤¾ã®ã¨ã³ã¸ãã¢ããã°ã§ä½ããã£ãã¿ããã§ãããå¾æ¥è«ã¯ãæ¬äººã«ãä»»ãããã¨ãã¾ããããã
ã¨ããããã§ãç§ã¯EC2ã¤ã³ã¹ã¿ã³ã¹ãèµ·åããæã«è¨å®ãèªåååºæ¥ãCloudInitã«ã¤ãã¦æ¸ãããã¨æãã¾ãã
CloudInitã¯ãã¨ãã¨Ubuntuãç±æ¥ã®ã½ããã¦ã§ã¢ã§ãããAmazon Linuxã§ãæ¨æºã§ã¤ã³ã¹ãã¼ã«ããã¦ãããèµ·åæã«æå®ããUserDataããåæè¨å®ãèªååãããã¨ãåºæ¥ã¾ãã
ã¤ã³ã¹ã¿ã³ã¹ã®èªåæ§æã ã¨ChefãPuppetãæåã§ãããç°¡åãªãã®ãªãè¨è¿°æ¹æ³ãã·ã³ãã«ãªCloudiInitã便å©ã§ãã UserDataã¯ã¤ã³ã¹ã¿ã³ã¹ãèµ·åããã¨ãã«ã以ä¸ã®é¨åã«ããã¹ããè²¼ä»ããã¨æå®ãåºæ¥ã¾ãã
ã¾ããec2-apitoolsã®ec2-run-instancesã³ãã³ãã使ç¨ããå ´åã¯-f(--user-data-file)ã使ç¨ãã¦ããã¹ããã¡ã¤ã«ããUserDataãæå®ããäºãå¯è½ã§ãã
ãã®å ´åã®ã³ãã³ãå®è¡ä¾ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
$ ec2-run-instances ami-XXXXXX -k your_key -g your_group --instance-type t1.micro -b /dev/sda1=:30 -f cloudinit-file.txt
å ·ä½çã«æå®ããUserDataã§ãããç§ã¯ä»¥ä¸ã®ããã«æå®ããäºãå¤ãã§ãã â»è¨å®ããå 容ã¯ä»¥ä¸ã®è¡¨ãã覧ãã ããã
#cloud-config repo_upgrade: all runcmd: - [cp, /usr/share/zoneinfo/Asia/Tokyo, /etc/localtime] - [resize2fs, /dev/xvda1]
2è¡ç®yum updateãå®è¡ãããªãã·ã§ã³ã«ãªãã¾ãã Amazon Linuxã¯ããã©ã«ãã§securityãæå®ããã¦ããã¾ãããç§ã¯ã»ã¨ãã©ææ°ã«ãã¦ãã¾ãã®ã§ã"repo_upgrade: all"ãæå®ãã¾ãã
è¡æ° | å 容 |
---|---|
1è¡ç® | CloudInitã§UserDataã使ç¨ããå ´åã¯1è¡ç®ã«ãã®ããã«è¨è¿°ãã¾ãã |
3è¡ç® | 以ä¸ã®è¡ãèµ·åå¾ã«å®è¡ããã³ãã³ãã§ããäºãæ示ãã¾ãã |
4è¡ç® | ã¿ã¤ã ã¾ã¼ã³ã®è¨å®ããã¦ãã¾ãã â»Amazon Linuxã®ããã©ã«ãã¯UTC |
5è¡ç® | ec2-run-instancesã³ãã³ãã®-b(--block-device-mapping)ãªãã·ã§ã³ã§ã«ã¼ãããã¤ã¹(EBS)ãæ¡å¼µããå ´åã«ããã¡ã¤ã«ã·ã¹ãã ã®ãµã¤ãºãå¤æ´ãã¦ãã¾ãã |
å種ããã±ã¼ã¸ã®ã¤ã³ã¹ãã¼ã«å ´åã¯ä»¥ä¸ã®ããã«ãæå®ä¸ããã
#cloud-config packages: - httpd - php
ã¡ãªã¿ã«Ubuntu11.10ã«ã¤ã³ã¹ãã¼ã«ããã¦ããCloudInitã§ãã¨ä»¥ä¸ã®ããã«æå®ããäºãåºæ¥ã¾ãã
#cloud-config apt_update: true hostname: hoge resize_rootfs: True timezone: "Asia/Tokyo"
Cloudinitã使ç¨ããã¨ãã°ã¤ã³ããäºãªãè¨å®ãåºæ¥ã¾ãããä½æ¥æ¼ããé²ããã®ã§éå®ãã¾ãã:-)