ããã«ã¡ã¯ãmakiã§ãã
å
ææå¹ã§éå¬ããPHP Matsuri 2013 ã§ã¯ãAnsibleã«ã¤ã㦠LT çºè¡¨ãã¦ãã¾ããã
çºè¡¨ã¹ã©ã¤ãã¯Slideshareã«ããã¦ããã¾ãã
Ansibleã¨ã¯
- æ§æ管çãã¼ã«(ChefãPuppetçã¨åã)
- playbookã¨ããèæ¬ãã¡ã¤ã«(Chefã§ããrecipe)ã«ãããããã¨ãyamlå½¢å¼ã§æ¸ãã¦å®è¡ããã ã
- å¥ã«Vagrantã¨ã®é¢ä¿ãå¿ é ãããªã
vagrant provision
ãããansible-playbook
ãåä½å®è¡ã®ã»ãã便å©ãªãã¨ãå¤ã
READMEã«ã¯è¨è¨ææ³ã¨ãã¦ãã®ããã«æ¸ããã¦ãã¾ãã
- ã¨ã£ã¦ãã·ã³ãã«ãªã»ããã¢ãã
- ããã©ã«ãã§è¶ éãã¦ä¸¦åå¦çãã§ãã
- ãµã¼ãã¼ããã¼ã¢ã³ããããªããsshdã ã
- ã¯ã©ã¤ã¢ã³ãã®boxã«è¿½å ã§å¿ è¦ãªãã®ãªã©ãªã
- ã©ããªè¨èªã§ãã¢ã¸ã¥ã¼ã«ãæ¸ããã¨ãã§ãã
- ã¹ã¯ãªããä½æã®ããã«ç¨æãããã¹ãããªapi
- rootã¦ã¼ã¶ã§ãªãã¦ã使ãã
- ã¨ã£ã¦ãç°¡åãªè¨å®ç®¡çã§å©ç¨ã§ããã
é£ãããã¨ã¯ä½ããªããæã
ããããã¨ã¯yamlå½¢å¼ã®è¨å®ãã¡ã¤ã«ãæ¸ãã¦å®è¡ããã ãã§ãã
ä»åã¯ã120以ä¸ããæ¨æºã¢ã¸ã¥ã¼ã«ã®ä¸ãããç¹ã«ãã使ããã®ãï¼ã¤å³é¸ãã¦ãç´¹ä»ãã¾ãã
command
shell ã³ãã³ããå®è¡ãããå ´åã«ä½¿ç¨ã <, >, | ã使ç¨ããå ´åã¯ãshell ã®æ¹ã使ãã
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
chdir | ã³ãã³ãã®å®è¡åã« æå®ãã£ã¬ã¯ããªã¸cdãã | |
creates | æå®ã®ãã¡ã¤ã«åãåå¨ãããªããcommandã®å®è¡ãã¹ããããã | |
removes | æå®ã®ãã¡ã¤ã«åãåå¨ããªããªããcommandã®å®è¡ãã¹ããããã |
ä¾:
- command: /usr/bin/make_database.sh arg1 arg2 creates=/path/to/database
file
ãã¡ã¤ã«ãã·ã³ããªãã¯ãªã³ã¯ããã£ã¬ã¯ããªã®å±æ§è¨å®ã»åé¤ãè¡ã
copy
,template
,assemble
ã¢ã¸ã¥ã¼ã«ãåæ§ã®ãã©ã¡ã¼ã¿ãæå®å¯è½
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
path | ãã¡ã¤ã«ã®ãã¹ | |
mode | ãã¼ããã·ã§ã³è¨å® | |
owner | ææè | |
group | ã°ã«ã¼ã | |
recurse | yes no |
å帰çï¼state=directory ã®ã¿æå¹ï¼ |
src | state=link ã®ã¿ |
|
state | file link directory hard absent |
ä¾:
- file: path=/etc/foo.conf owner=foo group=foo mode=0644 - file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
copy
ãã¼ã«ã«ç«¯æ«ã®files
ãã£ã¬ã¯ããªã«ããsrc
ã®ãã¡ã¤ã«ã ãªã¢ã¼ãã®dest
ã«ã³ãã¼ãã
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
src | ã³ãã¼å ï¼ãã¼ã«ã«ï¼ | |
dest | ã³ãã¼å ï¼ãªã¢ã¼ãï¼ | |
others | fileã¢ã¸ã¥ã¼ã«ã®ãã©ã¡ã¼ã¿(owner ,group ,mode ç)ãæå®å¯è½ |
ä¾:
copy: src=/srv/myfiles/foo.conf dest=/etc/foo.conf owner=foo group=foo mode=0644
template
- ãã¼ã«ã«ç«¯æ«ã®
templates
ãã£ã¬ã¯ããªã«ããsrc
ã®ãã¡ã¤ã«ããã³ãã¬ã¼ãã¨ãã¦ããªã¢ã¼ãã®dest
ã«ãã¡ã¤ã«ãçæãã - ãã³ãã¬ã¼ãã¨ã³ã¸ã³ã¨ãã¦jinja2 ã使ããã¦ãã
vars
ã§æå®ããå¤ãæ¿å ¥ãããã¨ãå¯è½{{ user_name }}
ãããã¯${{user_name}}
ã®å½¢å¼
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
src | ã³ãã¼å ï¼ãã¼ã«ã«ï¼ | |
dest | ã³ãã¼å ï¼ãªã¢ã¼ãï¼ | |
others | ãã®ä»fileã¢ã¸ã¥ã¼ã«åæ§ã®ãã©ã¡ã¼ã¿ãæå®å¯è½ |
ä¾:
- template: src=/mytemplates/foo.j2 dest=/etc/file.conf owner=bin group=wheel mode=0644
get_url
httpçµç±ã§ãã¡ã¤ã«ããã¦ã³ãã¼ãããå ´åã«ä½¿ç¨ãã
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
url | DLããããã¡ã¤ã«ã®url | |
dest | ãã¡ã¤ã«ã®ä¿åå | |
others | ãã®ä»fileã¢ã¸ã¥ã¼ã«åæ§ã®ãã©ã¡ã¼ã¿ãæå®å¯è½ |
ä¾:
- get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf mode=0440
git
git clone ã®å¦çãè¡ã
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
repo | ãªãã¸ããª(ssh,httpsçãå©ç¨å¯è½) | |
dest | cloneå | |
depth | å±¥æ´åå¾æ° æä½1 |
|
update | yes no |
yes ï¼ããã©ã«ãå¤ï¼ã®å ´åpullãè¡ã |
ä¾:
- git: repo=ssh://[email protected]/mylogin/hello.git dest=/home/mylogin/hello
yum
yumã³ãã³ããå©ç¨ãã¦ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã
ãã©ã¡ã¼ã¿ | é¸æè¢ | 説æ |
---|---|---|
name | ããã±ã¼ã¸å | |
state | present latest absent |
present :ã¤ã³ã¹ãã¼ã«æ¸ã¿ãªããã®ã¾ã¾latest :æ°ããã®ãããã°upgradeabsent :ããã±ã¼ã¸åé¤ |
ä¾:
- yum: name=tree state=present - yum: name=vim state=latest
â»Debianç³»(Debian/Ubuntu)ã®å ´åã¯aptã¢ã¸ã¥ã¼ã«ãç¨æããã¦ãã
ã¾ã¨ã
Ansibleãåãã¦ã®æ¹ã§ãããã ãè¦ããã°æåã®ã¹ãããã¯ãªã¢ã¨è¨ã£ã¦è¯ãã§ãããã
å
¬å¼ããã¥ã¡ã³ãã«ã¯ä»ã«ãå¤ãã®ä¾¿å©ãªã¢ã¸ã¥ã¼ã«ãæ²è¼ããã¦ãã¾ãã
ä»åç´¹ä»ããã¢ã¸ã¥ã¼ã«ã«æ
£ãã¦ããããä¸åº¦ããã¥ã¡ã³ããèªãã¨è¯ãã¨æãã¾ãã
Ansible Modules
æå¾ã«Ansibleã«ã¤ãã¦å¦ã¶éã«åèã«ãããµã¤ããç´¹ä»ãã¾ãã
- æ§æ管çãã¼ã« Ansible ã«ã¤ã㦠– apatheia.info
- ansibleã使ã£ã¦ã¿ã â ããã¯ãã¨ãªãæ¸ãããã
Yamlå½¢å¼ã®è¨è¿°ã¯ã«ã¼ã«ãåç´ãªã®ã§ã2ã¤3ã¤ã¿ã¹ã¯ãæ¸ãã¦ã¿ãã¨ããã«æ
£ããã¨æãã¾ãã
Chef ã® Recipeï¼Rubyï¼ ã«æ«æãã¦ãã¾ã£ãæ¹ããããä¸åº¦ææ¦ãã¦ã¿ã¾ãããï¼