ãµãŒããŒç®¡çããããã¯ãŒã¯èšå®ãã¢ããªã±ãŒã·ã§ã³ããã々ããããã®äœæ¥ãæåã§è¡ãã®ã¯ãæéããããããã¥ãŒãã³ãšã©ãŒã®ãªã¹ã¯ã䌎ããŸãããïŒ ð€ ãããªæ©ã¿ã解決ããŠãããã®ããAnsibleã§ãïŒ Ansibleã¯ããªãŒãã³ãœãŒã¹ã®æ§æ管çã»èªååããŒã«ã§ãITã€ã³ãã©ã®æ§ç¯ãéçšãåçã«å¹çåããŸãã ãã®èšäºã§ã¯ãAnsibleåå¿è ã®æ¹åãã«ãAnsibleã®åºæ¬ããç°¡åãªäœ¿ãæ¹ãŸã§ãã¹ããããã€ã¹ãããã§è§£èª¬ããŠãããŸãããã®èšäºãèªãã°ãããªããAnsibleã䜿ã£ãèªååã®äžçãžã®æãéããã¯ãã§ãïŒðª
ð Ansibleã®ã¡ãªããïŒãªãAnsibleã䜿ãã®ãïŒ
- ã·ã³ãã«ã§ç¿åŸãããã: Ansibleã®èšå®ãã¡ã€ã«ïŒPlaybookïŒã¯YAML圢åŒã§èšè¿°ãããŸããYAMLã¯äººéãèªã¿æžãããããã·ã³ãã«ãªæ§æãªã®ã§ãããã°ã©ãã³ã°çµéšãæµ ãæ¹ã§ãæ¯èŒç容æã«åŠç¿ãå§ããããšãã§ããŸããåŠç¿ã³ã¹ããäœãã®ã¯å€§ããªé åã§ãã
- ãšãŒãžã§ã³ãã¬ã¹: Ansibleã¯ã管ç察象ã®ãã·ã³ïŒãããŒãžãããŒãïŒã«ç¹å¥ãªãœãããŠã§ã¢ïŒãšãŒãžã§ã³ãïŒãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãããSSHïŒLinux/Unixç³»ïŒãWinRMïŒWindowsïŒãšãã£ãæšæºçãªãããã³ã«ã§æ¥ç¶ãããããå°å ¥ãéåžžã«ç°¡åã§ãããšãŒãžã§ã³ãã®ç®¡çãã¢ããããŒãã®æéããªãã®ã¯å¬ãããã€ã³ãã§ããã
- åªçæ§ (ã¹ããšããã): Ansibleã®å€ãã®æäœïŒã¢ãžã¥ãŒã«ïŒã¯ãåªçæ§ããæã£ãŠããŸããåªçæ§ãšã¯ããããæäœãäœåç¹°ãè¿ããŠããçµæãåãã«ãªãããšããæ§è³ªã§ããäŸãã°ããããã±ãŒãžãã€ã³ã¹ããŒã«ããããšããã¿ã¹ã¯ã¯ããŸã ã€ã³ã¹ããŒã«ãããŠããªããã°ã€ã³ã¹ããŒã«ãå®è¡ããæ¢ã«ã€ã³ã¹ããŒã«æžã¿ã§ããã°äœãããŸãããããã«ãããPlaybookãäœåºŠå®è¡ããŠããã·ã¹ãã ãæå³ããç¶æ ã«åæããããšãä¿èšŒãããå®å šã«ç¹°ãè¿ãå®è¡ã§ããŸãã
- 匷åãªèªååæ©èœ: ãµãŒããŒèšå®ã ãã§ãªãããããã¯ãŒã¯æ©åšã®èšå®ãã¯ã©ãŠãã€ã³ãã©ã®ããããžã§ãã³ã°ãã¢ããªã±ãŒã·ã§ã³ã®ãããã€ãã»ãã¥ãªãã£ããªã·ãŒã®é©çšãè€éãªã¯ãŒã¯ãããŒã®ãªãŒã±ã¹ãã¬ãŒã·ã§ã³ãªã©ãå¹ åºãITããã»ã¹ãèªååã§ããŸãã
- è±å¯ãªã¢ãžã¥ãŒã«ãšã³ãã¥ããã£: Ansibleã«ã¯ãæ§ã ãªæäœãè¡ãããã®ãã¢ãžã¥ãŒã«ããå€æ°çšæãããŠããŸãïŒãã¡ã€ã«æäœãããã±ãŒãžç®¡çããµãŒãã¹ç®¡çãããŒã¿ããŒã¹æäœãªã©ïŒããŸãã掻çºãªãªãŒãã³ãœãŒã¹ã³ãã¥ããã£ãååšããå€ãã®ãŠãŒã¶ãŒãäœæããåå©çšå¯èœãªèšå®éïŒããŒã«ïŒãAnsible Galaxyã§å ±æãããŠããŸããããã«ãããè»èŒªã®åçºæãé¿ããå¹ççã«èªååãé²ããããšãã§ããŸãã
- ã³ã¹ãåæž: æäœæ¥ã«ããæéã®ãããäœæ¥ãèªååããããšã§ã人件費ãéçšã³ã¹ããåæžã§ããŸãããŸãããªãŒãã³ãœãŒã¹ã§ãããããã©ã€ã»ã³ã¹è²»çšãããããªãç¹ãé åã§ãïŒåçšçã®Ansible Automation PlatformãååšããŸãïŒã
- å質åäž: èªååã«ãããæäœæ¥ã«ãããã¥ãŒãã³ãšã©ãŒãåæžããèšå®ã®äžè²«æ§ãä¿ã€ããšãã§ããŸããããã«ãããã·ã¹ãã ã®å®å®æ§ãä¿¡é Œæ§ãåäžããŸãã
â ïž æ³šæç¹: Ansibleã¯éåžžã«åŒ·åã§ãããèšå®ãã¡ã€ã«ïŒPlaybookïŒã®èšè¿°ãééãããšãå€æ°ã®ç®¡ç察象ããŒãã«æå³ããªãå€æŽãå ããŠããŸãå¯èœæ§ããããŸãã圱é¿ç¯å²ã倧ãããªãå¯èœæ§ããããããPlaybookã®ãã¹ããããŒãžã§ã³ç®¡çããã£ããè¡ãããšãéèŠã§ãã
ð§ Ansibleã®ä»çµã¿ãšæ§æèŠçŽ
Ansibleãã©ã®ããã«åäœããã®ãããã®äž»èŠãªæ§æèŠçŽ ãèŠãŠãããŸãããã
æ§æèŠçŽ | 説æ |
---|---|
ã³ã³ãããŒã«ããŒã (Control Node) | Ansibleãã€ã³ã¹ããŒã«ãããã³ãã³ããPlaybookãå®è¡ãããã·ã³ãéåžžã管çè ã®ããŒã«ã«ãã·ã³ãå°çšã®ç®¡çãµãŒããŒãããã«ããããŸããAnsibleãå®è¡ããã«ã¯Pythonãå¿ èŠã§ãã |
ãããŒãžãããŒã (Managed Node / Host) | Ansibleã«ãã£ãŠç®¡çããã察象ã®ãã·ã³ïŒãµãŒããŒããããã¯ãŒã¯æ©åšãã¯ã©ãŠãã€ã³ã¹ã¿ã³ã¹ãªã©ïŒããããã®ããŒãã«ã¯ãéåžžSSHïŒLinux/UnixïŒãŸãã¯WinRMïŒWindowsïŒã§æ¥ç¶å¯èœã§ããå¿ èŠããããŸããPythonå®è¡ç°å¢ãå¿ èŠã«ãªãå Žåãå€ãã§ãããšãŒãžã§ã³ãã®ã€ã³ã¹ããŒã«ã¯äžèŠã§ãã |
ã€ã³ãã³ã㪠(Inventory) | ãããŒãžãããŒãã®ãªã¹ããå®çŸ©ãããã¡ã€ã«ãIPã¢ãã¬ã¹ããã¹ãåãèšè¿°ããããŒããã°ã«ãŒãåããããšãå¯èœã§ããã©ã®ããŒãã«å¯ŸããŠæäœãå®è¡ããããæå®ããããã«äœ¿ãããŸããéçãªãã¡ã€ã«ïŒINI圢åŒãYAML圢åŒïŒã ãã§ãªããåçã«çæããããšãå¯èœã§ãã |
ã¢ãžã¥ãŒã« (Module) | ç¹å®ã®ã¿ã¹ã¯ãå®è¡ããããã®éšåïŒã³ãŒãïŒãäŸãã°ãããã±ãŒãžãã€ã³ã¹ããŒã«ãã `apt` ã `yum` ã¢ãžã¥ãŒã«ããã¡ã€ã«æäœãè¡ã `copy` ã `file` ã¢ãžã¥ãŒã«ããµãŒãã¹ã管çãã `service` ã¢ãžã¥ãŒã«ãªã©ãå€æ°ã®ã¢ãžã¥ãŒã«ãæšæºã§æäŸãããŠããŸãããŠãŒã¶ãŒãç¬èªã®ã¢ãžã¥ãŒã«ãäœæããããšãå¯èœã§ããã¢ãžã¥ãŒã«ã¯ã³ã³ãããŒã«ããŒããããããŒãžãããŒãã«è»¢éãããŠå®è¡ãããå®è¡åŸã«åé€ãããŸãã |
ã¿ã¹ã¯ (Task) | ç¹å®ã®ã¢ãžã¥ãŒã«ãç¹å®ã®ãã©ã¡ãŒã¿ã§å®è¡ãããåäžã®æäœåäœãPlaybookå ã§å®çŸ©ãããŸãã |
Playbook (ãã¬ã€ããã¯) | èªååããã¿ã¹ã¯ïŒæé ïŒãYAML圢åŒã§èšè¿°ãããã¡ã€ã«ãã©ã®ãã¹ãïŒã€ã³ãã³ããªå ã®ããŒããã°ã«ãŒãïŒã«å¯ŸããŠãã©ã®ã¿ã¹ã¯ïŒã¢ãžã¥ãŒã«ïŒããã©ã®ãããªé åºã§å®è¡ããããå®çŸ©ããŸããAnsibleã«ããèªååã®äžæ žãšãªãèŠçŽ ã§ããåªçæ§ãæã€ããã«æžãããšãæšå¥šãããŸãã |
Play (ãã¬ã€) | Playbookå ã§å®çŸ©ããããç¹å®ã®ãã¹ãã°ã«ãŒãã«å¯Ÿããäžé£ã®ã¿ã¹ã¯ã®ãŸãšãŸããPlaybookã¯äžã€ä»¥äžã®Playã§æ§æãããŸãã |
ããŒã« (Role) | Playbookãåå©çšããããããããã«ãé¢é£ããã¿ã¹ã¯ããã¡ã€ã«ããã³ãã¬ãŒããå€æ°ãªã©ãç¹å®ã®ãã£ã¬ã¯ããªæ§é ã«ãŸãšãããã®ãäŸãã°ããWebãµãŒããŒèšå®ãããŒã«ããããŒã¿ããŒã¹èšå®ãããŒã«ã®ããã«ãç¹å®ã®åœ¹å²ããšã«äœæããŸããè€éãªPlaybookãæŽçãã管çããããããã®ã«åœ¹ç«ã¡ãŸãã |
Ansible Galaxy | Ansibleã®ããŒã«ãå ±æã»æ€çŽ¢ã§ãããããµã€ããã³ãã¥ããã£ã«ãã£ãŠäœæãããå€ãã®äŸ¿å©ãªããŒã«ãèŠã€ããŠå©çšããããèªäœã®ããŒã«ãå ¬éãããã§ããŸãã |
ãã©ã°ã€ã³ (Plugin) | Ansibleã®ã³ã¢æ©èœãæ¡åŒµããããã®ã³ãŒããæ¥ç¶æ¹æ³ïŒConnection PluginïŒãã€ã³ãã³ããªãœãŒã¹ïŒInventory PluginïŒãå€æ°åŠçïŒVars PluginïŒãåºå圢åŒïŒCallback PluginïŒãªã©ãæ§ã ãªçš®é¡ã®ãã©ã°ã€ã³ããããŸãã |
Ansible Vault | ãã¹ã¯ãŒããAPIããŒãªã©ã®æ©å¯æ å ±ãæå·åããŠPlaybookãå€æ°ãã¡ã€ã«å ã§å®å šã«ç®¡çããããã®æ©èœã |
Ansible Automation Platform (AAP) / AWX | Ansibleããã倧èŠæš¡ãã€çµç¹çã«å©çšããããã®WebããŒã¹ã®UIãAPIãRBACïŒããŒã«ããŒã¹ã¢ã¯ã»ã¹å¶åŸ¡ïŒãªã©ãæäŸãããã©ãããã©ãŒã ãAAPã¯Red Hatã«ããåçšè£œåãAWXã¯ãã®ã¢ããã¹ããªãŒã ã®ãªãŒãã³ãœãŒã¹ãããžã§ã¯ãã§ãã |
åºæ¬çãªå®è¡ãããŒã¯ä»¥äžã®ããã«ãªããŸãã
- ãŠãŒã¶ãŒãã³ã³ãããŒã«ããŒã㧠`ansible` ã³ãã³ãïŒã¢ãããã¯ã³ãã³ãïŒãŸã㯠`ansible-playbook` ã³ãã³ããå®è¡ããŸãã
- Ansibleã¯ã€ã³ãã³ããªãã¡ã€ã«ãèªã¿èŸŒã¿ã察象ãšãªããããŒãžãããŒããç¹å®ããŸãã
- Ansibleã¯SSHãWinRMã䜿ã£ãŠãããŒãžãããŒãã«æ¥ç¶ããŸãã
- Playbookã«èšè¿°ãããã¿ã¹ã¯ã«åŸããå¿ èŠãªã¢ãžã¥ãŒã«ããããŒãžãããŒãã«è»¢éããå®è¡ããŸãã
- å®è¡çµæãåéããã³ã³ãããŒã«ããŒãã«è¡šç€ºããŸãã
- ã¢ãžã¥ãŒã«ã¯å®è¡åŸã«ãããŒãžãããŒãããåé€ãããŸãã
ð» Ansibleã®ã€ã³ã¹ããŒã«
Ansibleã¯ã³ã³ãããŒã«ããŒãã«ã€ã³ã¹ããŒã«ããŸããæ§ã ãªOSã«å¯Ÿå¿ããŠããŸãããããã§ã¯äžè¬çãªLinuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã§ã®ã€ã³ã¹ããŒã«æ¹æ³ãããã€ã玹ä»ããŸããAnsibleã¯Pythonã§æžãããŠãããããPythonãå¿ èŠã§ãïŒéåžžãæè¿ã®Linuxãã£ã¹ããªãã¥ãŒã·ã§ã³ã«ã¯ããªã€ã³ã¹ããŒã«ãããŠããŸãïŒã
pip ã䜿çšããã€ã³ã¹ããŒã« (æšå¥šãããããšãå€ã)
pipã䜿ããšãOSã®ããã±ãŒãžç®¡çã·ã¹ãã ã«äŸåãããææ°çã«è¿ãAnsibleãã€ã³ã¹ããŒã«ã§ããŸããPythonã®ä»®æ³ç°å¢ (venv) ã䜿ããšãã·ã¹ãã å šäœãæ±ããã«ãããžã§ã¯ãããšã«Ansibleã®ããŒãžã§ã³ã管çã§ããããæšå¥šãããŸãã
# Python 3 ãš pip ãã€ã³ã¹ããŒã«ãããŠããããšã確èª
python3 --version
pip3 --version
# ä»®æ³ç°å¢ãäœæ (äŸ: myansible_env)
python3 -m venv myansible_env
# ä»®æ³ç°å¢ãæå¹å
source myansible_env/bin/activate
# Ansible ãã€ã³ã¹ããŒã« (ansible-core ãã€ã³ã¹ããŒã«ããã®ãäžè¬ç)
pip3 install ansible-core
# (ãªãã·ã§ã³) Ansible ã³ãã¥ããã£ããã±ãŒãžå
šäœãã€ã³ã¹ããŒã«ããå Žå
# pip3 install ansible
# ã€ã³ã¹ããŒã«ãããã確èª
ansible --version
# ä»®æ³ç°å¢ãæããå Žå
# deactivate
ã€ã³ã¹ããŒã«åŸã`ansible –version` ã³ãã³ããå®è¡ããŠãããŒãžã§ã³æ å ±ãèšå®ãã¡ã€ã«ã®å Žæã衚瀺ãããã°æåã§ã ðã
ð ïž Ansibleã䜿ã£ãŠã¿ããïŒåºæ¬çãªã³ãã³ãïŒ
Ansibleã®åºæ¬çãªäœ¿ãæ¹ãšããŠããŸãã€ã³ãã³ããªãã¡ã€ã«ãäœæããã¢ãããã¯ã³ãã³ããå®è¡ããŠã¿ãŸãããã
1. ã€ã³ãã³ããªãã¡ã€ã«ã®äœæ
ã€ã³ãã³ããªãã¡ã€ã«ã¯ãAnsibleãæäœãã察象ã®ãã¹ãïŒãããŒãžãããŒãïŒããªã¹ãã¢ãããããã¡ã€ã«ã§ããããã©ã«ãã§ã¯ `/etc/ansible/hosts` ãåç §ãããŸãããèªåã§ãã¡ã€ã«ãäœæããŠæå®ããããšãå¯èœã§ããINI圢åŒãŸãã¯YAML圢åŒã§èšè¿°ã§ããŸãã
ããã§ã¯ã`inventory.ini` ãšããååã§ç°¡åãªã€ã³ãã³ããªãã¡ã€ã«ãäœæããŠã¿ãŸãããã
[webservers]
192.168.33.10
web01.example.com ansible_user=myuser ansible_ssh_private_key_file=~/.ssh/mykey
[dbservers]
192.168.33.11
[all:vars]
ansible_python_interpreter=/usr/bin/python3
解説:
[webservers]
ã[dbservers]
ã¯ãã¹ãã°ã«ãŒããå®çŸ©ããŸãã- ã°ã«ãŒãã®äžã«ããã¹ãåãIPã¢ãã¬ã¹ãèšè¿°ããŸãã
- ãã¹ãåã®åŸã«ã¹ããŒã¹åºåãã§å€æ°ãæå®ã§ããŸãã
ansible_user
: SSHæ¥ç¶ã«äœ¿çšãããŠãŒã¶ãŒåansible_ssh_private_key_file
: SSHæ¥ç¶ã«äœ¿çšããç§å¯éµãã¡ã€ã«ã®ãã¹
[all:vars]
ã¯ãã€ã³ãã³ããªå ã®å šãŠã®ãã¹ãã«é©çšãããå ±éå€æ°ãå®çŸ©ããŸããããã§ã¯ãPython 3ã®ãã¹ãæå®ããŠããŸãã
2. ã¢ãããã¯ã³ãã³ãã®å®è¡
ã¢ãããã¯ã³ãã³ãã¯ãPlaybookãäœæããã«ãåäžã®ã¿ã¹ã¯ãã³ãã³ãã©ã€ã³ããçŽæ¥å®è¡ããæ¹æ³ã§ããç°¡åãªç¢ºèªäœæ¥ãäžæçãªæäœã«äŸ¿å©ã§ãã
ansible <ãã¹ããã¿ãŒã³> -i <ã€ã³ãã³ããªãã¡ã€ã«> -m <ã¢ãžã¥ãŒã«å> -a "<ã¢ãžã¥ãŒã«åŒæ°>"
ã®åœ¢åŒã§äœ¿çšããŸãã
çéç¢ºèª (ping ã¢ãžã¥ãŒã«)
ãããŒãžãããŒãã«æ¥ç¶ã§ããããåºæ¬çãªçé確èªãè¡ããŸãã
# webservers ã°ã«ãŒãã®å
šãã¹ãã« ping ãå®è¡
ansible webservers -i inventory.ini -m ping
# å
šãŠã®ãã¹ãã« ping ãå®è¡
ansible all -i inventory.ini -m ping
æåãããšãåãã¹ããã “pong” ãšããå¿çãè¿ã£ãŠããŸãã
192.168.33.10 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
ä»»æã®ã³ãã³ãå®è¡ (command / shell ã¢ãžã¥ãŒã«)
ãããŒãžãããŒãã§ä»»æã®ã·ã§ã«ã³ãã³ããå®è¡ããŸãã`command` ã¢ãžã¥ãŒã«ã¯ãã€ãããªãã€ã¬ã¯ããªã©ã®ã·ã§ã«æ©èœã¯äœ¿ããŸããããããå®å šã§ãã`shell` ã¢ãžã¥ãŒã«ã¯ã·ã§ã«çµç±ã§å®è¡ããããããããã®æ©èœãå©çšã§ããŸãã
# webservers ã°ã«ãŒãã®ãã¹ã㧠uptime ã³ãã³ããå®è¡
ansible webservers -i inventory.ini -m command -a "uptime"
# dbservers ã°ã«ãŒãã®ãã¹ã㧠df -h ã³ãã³ããå®è¡ (shell ã¢ãžã¥ãŒã«ã䜿çš)
ansible dbservers -i inventory.ini -m shell -a "df -h"
ããã±ãŒãžã®ã€ã³ã¹ããŒã« (apt / yum ã¢ãžã¥ãŒã«)
ãããŒãžãããŒãã«ããã±ãŒãžãã€ã³ã¹ããŒã«ããŸãã管çè
æš©éãå¿
èŠãªããã--become
(ãŸã㯠-b
) ãªãã·ã§ã³ã§æš©éææ Œ (sudo ãªã©) ãè¡ãã--ask-become-pass
(ãŸã㯠-K
) ã§ãã¹ã¯ãŒããå°ããããã«ããŸãã
# webservers ã°ã«ãŒã (Ubuntu/Debianæ³å®) ã« nginx ãã€ã³ã¹ããŒã«
ansible webservers -i inventory.ini -m apt -a "name=nginx state=present update_cache=yes" --become --ask-become-pass
# dbservers ã°ã«ãŒã (CentOS/RHELæ³å®) ã« mariadb-server ãã€ã³ã¹ããŒã«
ansible dbservers -i inventory.ini -m yum -a "name=mariadb-server state=present" --become --ask-become-pass
state=present
ã¯ããã±ãŒãžãååšããç¶æ
ïŒã€ã³ã¹ããŒã«æžã¿ïŒãä¿èšŒããŸããupdate_cache=yes
ã¯ããã±ãŒãžãªã¹ããæŽæ°ããŸãïŒaptã¢ãžã¥ãŒã«ïŒã
ã¢ãããã¯ã³ãã³ãã¯æ軜ã§ãããè€éãªæé ãç¹°ãè¿ãè¡ãäœæ¥ã¯ã次ã«çŽ¹ä»ããPlaybookã䜿ãã®ãäžè¬çã§ãã
ð Playbookå ¥éïŒèªååã®æé æžãäœæãã
Playbookã¯ãAnsibleã«ããèªååã®äžæ žã§ããè€æ°ã®ã¿ã¹ã¯ãé åºç«ãŠãŠèšè¿°ãããµãŒããŒæ§æãã¢ããªã±ãŒã·ã§ã³ãããã€ãªã©ã®äžé£ã®äœæ¥ãå®çŸ©ããŸããYAML圢åŒã§èšè¿°ããããããå¯èªæ§ãé«ãã管çããããã®ãç¹åŸŽã§ãã
Playbookã®åºæ¬çãªæ§é
Playbookã¯éåžžãäžã€ä»¥äžã®ãPlayãã§æ§æãããŸããåPlayã¯ãç¹å®ã®ãã¹ãã°ã«ãŒãã«å¯ŸããŠå®è¡ãããã¿ã¹ã¯ã®ãªã¹ããå®çŸ©ããŸãã
---
- name: Play 1 - WebãµãŒããŒã®èšå® # Playã®åå (ä»»æ)
hosts: webservers # 察象ãã¹ã/ã°ã«ãŒã (ã€ã³ãã³ããªåç
§)
become: true # ãã®Playå
ã®ã¿ã¹ã¯ã§æš©éææ Œ (sudo) ããã
vars: # ãã®Playã§äœ¿çšããå€æ° (ä»»æ)
package_name: nginx
config_file_src: files/nginx.conf
config_file_dest: /etc/nginx/nginx.conf
tasks: # å®è¡ããã¿ã¹ã¯ã®ãªã¹ã
- name: Install {{ package_name }} package # ã¿ã¹ã¯å (ä»»æ)
apt: # 䜿çšããã¢ãžã¥ãŒã«
name: "{{ package_name }}" # ã¢ãžã¥ãŒã«ãžã®åŒæ° (å€æ°ã䜿çš)
state: present
update_cache: yes
tags: install # ã¿ã° (ç¹å®ã®ã¿ã¹ã¯ã®ã¿å®è¡ããéã«äœ¿çš)
- name: Copy {{ package_name }} config file
copy:
src: "{{ config_file_src }}" # ã³ããŒå
(ã³ã³ãããŒã«ããŒãäžã®ãã¹)
dest: "{{ config_file_dest }}" # ã³ããŒå
(ãããŒãžãããŒãäžã®ãã¹)
notify: Restart Nginx # ãã®ã¿ã¹ã¯ãå€æŽãèµ·ãããããã³ãã©ãŒãåŒã³åºã
- name: Ensure {{ package_name }} service is running and enabled
service:
name: "{{ package_name }}"
state: started
enabled: yes
handlers: # notify ã§åŒã³åºãããåŠç (ã¿ã¹ã¯ãå€æŽãèµ·ãããå Žåã®ã¿å®è¡)
- name: Restart Nginx
service:
name: "{{ package_name }}"
state: restarted
- name: Play 2 - DBãµãŒããŒã®èšå® # å¥ã®Play
hosts: dbservers
become: true
tasks:
# ... DBãµãŒããŒçšã®ã¿ã¹ã¯ãèšè¿° ...
äž»èŠãªèŠçŽ :
---
: YAMLãã¡ã€ã«ã®éå§ã瀺ããŸãïŒä»»æã§ããæšå¥šïŒã-
: ãªã¹ãïŒé åïŒã®èŠçŽ ã瀺ããŸããPlaybookã¯Playã®ãªã¹ãã§ããname
: Playãã¿ã¹ã¯ã«äººéãããããããååãä»ããŸããå®è¡ãã°ã«è¡šç€ºãããŸããhosts
: Playã®å¯Ÿè±¡ãšãªããã¹ããŸãã¯ã°ã«ãŒããã€ã³ãã³ããªããæå®ããŸããall
ãæå®ãããšå šãŠã®ãã¹ãã察象ã«ãªããŸããbecome: true/false
:true
ã«ãããšãPlayå ã®ã¿ã¹ã¯ãå®è¡ããéã«æš©éææ ŒïŒéåžžã¯sudoïŒãè©Šã¿ãŸããvars
: Playå ã§äœ¿çšããå€æ°ãå®çŸ©ããŸããtasks
: å®è¡ããã¿ã¹ã¯ã®ãªã¹ããåã¿ã¹ã¯ã¯éåžžname
ãšäœ¿çšããã¢ãžã¥ãŒã«ããã®åŒæ°ã§æ§æãããŸããã¿ã¹ã¯ã¯èšè¿°ãããé åºã§å®è¡ãããŸããtags
: ã¿ã¹ã¯ã«ã¿ã°ãä»ããPlaybookå®è¡æã«ç¹å®ã®ã¿ã°ãä»ããã¿ã¹ã¯ã ããå®è¡ããããã¹ããããããã§ããŸããhandlers
: ç¹å®ã®ã¿ã¹ã¯ã«ãã£ãŠå€æŽãå ããããå ŽåïŒäŸ: èšå®ãã¡ã€ã«ãæŽæ°ãããå ŽåïŒã«ã®ã¿å®è¡ãããç¹å¥ãªã¿ã¹ã¯ãnotify
ã§ãã³ãã©ãŒåãæå®ããŠåŒã³åºããŸããéåžžããµãŒãã¹ã®åèµ·åãªã©ã«äœ¿ãããŸãããã³ãã©ãŒã¯ãPlayå ã®å šãŠã®ã¿ã¹ã¯ãå®äºããåŸã«äžåºŠã ãå®è¡ãããŸãã{{ variable_name }}
: å€æ°ãåç §ããæ§æ (Jinja2ãã³ãã¬ãŒã)ã
Playbookã®å®è¡æ¹æ³
äœæããPlaybook㯠`ansible-playbook` ã³ãã³ãã§å®è¡ããŸãã
# my_playbook.yml ã inventory.ini ã䜿ã£ãŠå®è¡
ansible-playbook -i inventory.ini my_playbook.yml
# æš©éææ Œãå¿
èŠãªå Žåããã¹ã¯ãŒããå°ãã
ansible-playbook -i inventory.ini my_playbook.yml --ask-become-pass
# ç¹å®ã®ã¿ã°ãä»ããã¿ã¹ã¯ã®ã¿å®è¡ (--tags ãŸã㯠-t)
ansible-playbook -i inventory.ini my_playbook.yml --tags "install"
# ç¹å®ã®ã¿ã°ãä»ããã¿ã¹ã¯ãã¹ããã (--skip-tags)
ansible-playbook -i inventory.ini my_playbook.yml --skip-tags "configure"
# æ§æãã§ã㯠(--syntax-check) - å®éã«å®è¡ããã«æ§æãšã©ãŒã確èª
ansible-playbook my_playbook.yml --syntax-check
# ãã©ã€ã©ã³ (--check ãŸã㯠-C) - å®éã«å€æŽãå ãããäœãå€æŽããããã確èª
ansible-playbook -i inventory.ini my_playbook.yml --check --ask-become-pass
# å®è¡å
容ã詳现衚瀺 (-v, -vv, -vvv, -vvvv)
ansible-playbook -i inventory.ini my_playbook.yml -vvv
`–check` ãªãã·ã§ã³ (ãã©ã€ã©ã³) ã¯ãæ¬çªç°å¢ã«å€æŽãé©çšããåã«ãæå³ããéãã«åäœãããã確èªããã®ã«éåžžã«åœ¹ç«ã¡ãŸãã
ð åªçæ§ (Idempotence) ã«ã€ããŠ
Ansibleãç解ããäžã§éåžžã«éèŠãªæŠå¿µããåªçæ§ãã§ããããã¯ããããæäœã1åå®è¡ããŠããè€æ°åå®è¡ããŠããçµæãåãã«ãªãããšããæ§è³ªãæããŸãã
äŸãã°ããã¡ã€ã«ãäœæããã¿ã¹ã¯ãèããŠã¿ãŸãããã
- name: Ensure directory exists
file:
path: /path/to/mydirectory
state: directory
mode: '0755'
ãã®ã¿ã¹ã¯ãåããŠå®è¡ãããšã`/path/to/mydirectory` ãã£ã¬ã¯ããªãäœæãããããŒããã·ã§ã³ã `0755` ã«èšå®ãããŸããAnsibleã¯ãå€æŽãã (changed)ããšå ±åããŸãã
ããããåãã¿ã¹ã¯ãå床å®è¡ããå Žåããã£ã¬ã¯ããªã¯æ¢ã«ååšããããŒããã·ã§ã³ã `0755` ã®ãŸãŸãªã®ã§ãAnsibleã¯äœã®å€æŽãå ããããå€æŽãªã (ok)ããšå ±åããŸãã
ãªãåªçæ§ãéèŠãªã®ãïŒ
- å®å šæ§: PlaybookãäœåºŠå®è¡ããŠãã·ã¹ãã ãå£ããå¿é ãå°ãªããå®å šã«ç¹°ãè¿ãé©çšã§ããŸãã
- å¹çæ§: å€æŽãå¿ èŠãªãå Žåã¯å®éã®æäœãã¹ããããããããå®è¡æéãççž®ã§ããŸãã
- ç¶æ ã®ä¿èšŒ: Playbookã¯ã·ã¹ãã ã®ããã¹ããç¶æ ããèšè¿°ãããã®ãšãªããå®è¡ããããšã§åžžã«ãã®ç¶æ ã«åæãããããšãã§ããŸãã
ãã ããå šãŠã®Ansibleã¢ãžã¥ãŒã«ãããã©ã«ãã§åªçæ§ãæã€ããã§ã¯ãããŸãããäŸãã°ã`shell` ã `command` ã¢ãžã¥ãŒã«ã§å®è¡ããã³ãã³ãã¯ããã®ã³ãã³ãèªäœãåªçã§ãªããã°ãäœåºŠå®è¡ããŠãåãçµæã«ãªããšã¯éããŸãããPlaybookãäœæããéã«ã¯ãã§ããã ãåªçæ§ãæã€ã¢ãžã¥ãŒã«ãå©çšããåªçæ§ãæèããŠèšèšããããšãéèŠã§ãã
ð å€æ°ãšãã³ãã¬ãŒã (Jinja2)
Playbookãããæè»ã§åå©çšå¯èœã«ããããã«ãå€æ°ãšãã³ãã¬ãŒãã掻çšããŸãããã
å€æ°ã®å®çŸ©å Žæ
Ansibleã§ã¯ãæ§ã ãªå Žæã§å€æ°ãå®çŸ©ã§ããŸããèªã¿èŸŒãŸããåªå é äœããããã泚æãå¿ èŠã§ãïŒäžè¬çã«ãããéå®çãªã¹ã³ãŒãã§å®çŸ©ãããå€æ°ãåªå ãããŸãïŒã
- ã€ã³ãã³ããªãã¡ã€ã«å : ãã¹ãããšããŸãã¯ã°ã«ãŒãããšã«å€æ°ãå®çŸ©ã§ããŸãã
- Playbookå (`vars` ã»ã¯ã·ã§ã³): Playã¬ãã«ã§å€æ°ãå®çŸ©ããŸãã
- ã€ã³ã¯ã«ãŒãããããã¡ã€ã« (`vars_files`): å€æ°å®çŸ©ãå¥ã®YAMLãã¡ã€ã«ã«èšè¿°ããPlaybookããèªã¿èŸŒã¿ãŸãã
- ããŒã«å (`defaults/main.yml`, `vars/main.yml`): ããŒã«å ã§ããã©ã«ãå€ãå€æ°ãå®çŸ©ããŸãã
- ã³ãã³ãã©ã€ã³åŒæ° (`-e` ãŸã㯠`–extra-vars`): Playbookå®è¡æã«å€æ°ãæž¡ããŸãã
- ç»é²ãããå€æ° (`register`): ã¿ã¹ã¯ã®å®è¡çµæãå€æ°ã«æ ŒçŽããŸãã
- ãã¡ã¯ã (`ansible_facts`): AnsibleããããŒãžãããŒãããèªååéããã·ã¹ãã æ å ±ïŒIPã¢ãã¬ã¹ãOSãã¡ã¢ãªå®¹éãªã©ïŒã
å€æ°å®çŸ©ã®äŸ
# inventory.ini
[webservers]
web01.example.com http_port=8080 app_version=1.1
web02.example.com http_port=8080 app_version=1.2
[webservers:vars]
nginx_user=www-data
---
# my_playbook.yml
- hosts: webservers
become: true
vars:
# Playbookå
ã§å®çŸ©ããå€æ°
log_dir: /var/log/my_app
deploy_user: ansible
vars_files:
# å€éšãã¡ã€ã«ããå€æ°ãèªã¿èŸŒã
- secrets.yml # ãã¹ã¯ãŒããªã©ã®æ©å¯æ
å ±
tasks:
- name: Display variables
debug:
msg: |
HTTP Port: {{ http_port }}
App Version: {{ app_version }}
Nginx User: {{ nginx_user }}
Log Directory: {{ log_dir }}
Deploy User: {{ deploy_user }}
OS Family: {{ ansible_facts['os_family'] }} # ãã¡ã¯ãå€æ°ã®äŸ
Default IPv4 Address: {{ ansible_facts['default_ipv4']['address'] }} # ãã¡ã¯ãå€æ°ã®äŸ
- name: Run a command and register result
command: "cat /path/to/some/file"
register: command_output # ã¿ã¹ã¯ã®çµæã command_output å€æ°ã«æ ŒçŽ
ignore_errors: yes # ãã¡ã€ã«ãååšããªããŠããšã©ãŒã«ããªã
- name: Display command output
debug:
var: command_output.stdout_lines # æšæºåºåãè¡ããšã®ãªã¹ãã§è¡šç€º
when: command_output.rc == 0 # ã³ãã³ããæåããå Žåã®ã¿è¡šç€º (æ¡ä»¶åå²)
ãã³ãã¬ãŒã (Jinja2)
Jinja2ã¯Pythonã§åºã䜿ãããŠãããã³ãã¬ãŒããšã³ãžã³ã§ãAnsibleã§ãèšå®ãã¡ã€ã«ã®çæãªã©ã«æŽ»çšãããŸããå€æ°ãã«ãŒããæ¡ä»¶åå²ãªã©ã䜿ã£ãŠãåçã«ãã¡ã€ã«ãçæã§ããŸãããã³ãã¬ãŒããã¡ã€ã«ã¯éåžž `.j2` ãšããæ¡åŒµåãä»ããŸãã
äŸãã°ãNginxã®èšå®ãã¡ã€ã«ããã³ãã¬ãŒãã§äœæããŠã¿ãŸãããã
# templates/nginx.conf.j2
user {{ nginx_user }}; # ã€ã³ãã³ããªã§å®çŸ©ããå€æ°
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
server {
listen {{ http_port }}; # ã€ã³ãã³ããªã§å®çŸ©ããå€æ°
server_name {{ inventory_hostname }}; # ãã¹ãå (Ansibleã®ç¹æ®å€æ°)
root /var/www/html/{{ app_version }}; # ã€ã³ãã³ããªã§å®çŸ©ããå€æ°
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
# ãã°ãã£ã¬ã¯ããªãå€æ°ã§æå®
access_log {{ log_dir }}/access.log; # Playbookã§å®çŸ©ããå€æ°
error_log {{ log_dir }}/error.log;
}
{% if enable_ssl %} # æ¡ä»¶åå² (å€æ°ãtrueã®å Žå)
server {
listen 443 ssl;
server_name {{ inventory_hostname }};
ssl_certificate /etc/ssl/certs/mycert.pem;
ssl_certificate_key /etc/ssl/private/mykey.key;
# ... SSLèšå® ...
}
{% endif %}
# è€æ°ã®ãµã€ãèšå®ãã«ãŒãã§çæããå Žå
{% for site in websites %}
server {
listen 80;
server_name {{ site.name }};
root /var/www/{{ site.name }};
# ... åãµã€ãã®èšå® ...
}
{% endfor %}
}
ãã®ãã³ãã¬ãŒããPlaybookãã `template` ã¢ãžã¥ãŒã«ã䜿ã£ãŠå±éããŸãã
- name: Deploy Nginx config from template
template:
src: templates/nginx.conf.j2 # ã³ã³ãããŒã«ããŒãäžã®ãã³ãã¬ãŒããã¡ã€ã«
dest: /etc/nginx/conf.d/my_app.conf # ãããŒãžãããŒãäžã®çæå
ãã¡ã€ã«
owner: root
group: root
mode: '0644'
notify: Restart Nginx
vars:
enable_ssl: false # ãã³ãã¬ãŒãå
ã®æ¡ä»¶åå²çšå€æ°
websites: # ãã³ãã¬ãŒãå
ã®ã«ãŒãçšå€æ°
- name: site1.example.com
- name: site2.example.com
`template` ã¢ãžã¥ãŒã«ã¯ãã³ã³ãããŒã«ããŒãäžã® `.j2` ãã¡ã€ã«ãèªã¿èŸŒã¿ãJinja2ãšã³ãžã³ã§å€æ°ãå±éããåŸããã®çµæããããŒãžãããŒãã®æå®ããããã¹ã«ãã¡ã€ã«ãšããŠé 眮ããŸããããã«ãããç°å¢ããšã«ç°ãªãèšå®ãã¡ã€ã«ãå¹ççã«ç®¡çã§ããŸãã
ð ããŒã«ãšAnsible GalaxyïŒPlaybookã®æ§é åãšåå©çš
Playbookã倧èŠæš¡ã«ãªã£ãããè€æ°ã®ãããžã§ã¯ãã§åããããªèšå®ãè¡ã£ããããå Žåãã³ãŒãã®åå©çšæ§ãšç®¡çæ§ãéèŠã«ãªããŸããããã§åœ¹ç«ã€ã®ããããŒã«ãã§ãã
ããŒã« (Role) ãšã¯ïŒ
ããŒã«ã¯ãç¹å®ã®åœ¹å²ïŒäŸ: WebãµãŒããŒãããŒã¿ããŒã¹ãµãŒããŒãç£èŠãšãŒãžã§ã³ãïŒã«å¿ èŠãªã¿ã¹ã¯ãå€æ°ããã¡ã€ã«ããã³ãã¬ãŒãããã³ãã©ãŒãªã©ãã決ãããããã£ã¬ã¯ããªæ§é ã«ãŸãšãããã®ã§ããããã«ãããPlaybookãéšååããåå©çšããããããŸãã
äžè¬çãªããŒã«ã®ãã£ã¬ã¯ããªæ§é ã¯ä»¥äžã®ããã«ãªããŸãã
my_role/
âââ defaults/ # ããã©ã«ãå€æ° (åªå
床äœ)
â âââ main.yml
âââ files/ # copyã¢ãžã¥ãŒã«ãªã©ã§äœ¿çšããéçãã¡ã€ã«
â âââ my_script.sh
âââ handlers/ # ãã³ãã©ãŒå®çŸ©
â âââ main.yml
âââ meta/ # ããŒã«ã®ã¡ã¿ããŒã¿ (äŸåé¢ä¿ãªã©)
â âââ main.yml
âââ tasks/ # ã¡ã€ã³ã®ã¿ã¹ã¯å®çŸ©
â âââ main.yml
âââ templates/ # templateã¢ãžã¥ãŒã«ã§äœ¿çšããJinja2ãã³ãã¬ãŒã
â âââ my_config.conf.j2
âââ vars/ # å€æ°å®çŸ© (åªå
床é«)
âââ main.yml
åãã£ã¬ã¯ããªå ã® `main.yml` (ãŸãã¯ä»ã®YAMLãã¡ã€ã«) ã«ãããããã®èŠçŽ ãèšè¿°ããŸãã
PlaybookããããŒã«ãå©çšããã«ã¯ã`roles` ã»ã¯ã·ã§ã³ã䜿çšããŸãã
---
- hosts: webservers
become: true
roles:
- common # å
±éèšå®ãè¡ãããŒã«
- webserver # WebãµãŒããŒèšå®ãè¡ãããŒã« (äŸ: my_role)
- role: monitoring # ããŒã«åãšå€æ°ãæå®ããå Žå
vars:
monitor_server: monitor.example.com
- hosts: dbservers
become: true
roles:
- common
- database
Ansibleã¯æå®ãããããŒã«åã®ãã£ã¬ã¯ããªãæ¢ãïŒããã©ã«ãã§ã¯Playbookãšåãé局㮠`roles` ãã£ã¬ã¯ããªãªã©ïŒããã®äžã® `tasks/main.yml` ãå®è¡ããŸããå€æ°ããã³ãã©ãŒãªã©ãèªåçã«èªã¿èŸŒãŸããŸãã
Ansible Galaxy
Ansible Galaxy ã¯ãã³ãã¥ããã£ã«ãã£ãŠäœæãããããŒã«ãå ±æã»æ€çŽ¢ããããã®å ¬åŒãããµã€ãã§ããNginxãApacheãMySQLãPostgreSQLãDockerãªã©ãäžè¬çãªãœãããŠã§ã¢ããµãŒãã¹ã®ã»ããã¢ãããè¡ãããã®ããŒã«ãå€æ°å ¬éãããŠããŸãã
`ansible-galaxy` ã³ãã³ãã䜿ã£ãŠãGalaxyããããŒã«ãã€ã³ã¹ããŒã«ããããèªäœããŒã«ã®é圢ãäœæãããã§ããŸãã
# geerlingguy.nginx ããŒã«ãæ€çŽ¢
ansible-galaxy search nginx
# geerlingguy.nginx ããŒã«ãã€ã³ã¹ããŒã« (ããã©ã«ã㯠~/.ansible/roles)
ansible-galaxy install geerlingguy.nginx
# ãããžã§ã¯ãå
ã® roles ãã£ã¬ã¯ããªã«ã€ã³ã¹ããŒã«
ansible-galaxy install geerlingguy.nginx -p ./roles
# requirements.yml ãã¡ã€ã«ã«èšè¿°ããããŒã«ãäžæ¬ã€ã³ã¹ããŒã«
# requirements.yml ã®äŸ:
# ---
# roles:
# - src: geerlingguy.nginx
# - src: geerlingguy.mysql
# collections:
# - name: community.general
ansible-galaxy install -r requirements.yml
# æ°ããããŒã«ã®é圢ãäœæ
ansible-galaxy init my_new_role
Ansible Galaxyã掻çšããããšã§ãèªåã§äžããPlaybookãæžãæéãçããå®çžŸã®ããèšå®ãåå©çšããŠãè¿ éãã€å¹ççã«èªååãé²ããããšãã§ããŸããð
ð ããã«å ãžïŒé«åºŠãªãããã¯ãšæ¬¡ã®ã¹ããã
Ansibleã®åºæ¬çãªäœ¿ãæ¹ããã¹ã¿ãŒããããããã«é«åºŠãªæ©èœãå¿çšçãªäœ¿ãæ¹ãæ¢æ±ããŠã¿ãŸãããã
- Ansible Automation Platform (AAP) / AWX: 倧èŠæš¡ãªç°å¢ãããŒã ã§ã®Ansibleå©çšãæ¯æŽããWebããŒã¹ã®ç®¡çããŒã«ãGUIã§ã®ãžã§ãå®è¡ãã¹ã±ãžã¥ãŒãªã³ã°ãRBACãç£æ»ãã°ãªã©ã®æ©èœãæäŸããŸãã
- ãããã¯ãŒã¯èªåå: Ansibleã¯ãµãŒããŒã ãã§ãªããCisco, Juniper, Aristaãªã©ã®ãããã¯ãŒã¯æ©åšã®èšå®èªååã«ã匷åã«å¯Ÿå¿ããŠããŸããå°çšã®ãããã¯ãŒã¯ã¢ãžã¥ãŒã«ãè±å¯ã«çšæãããŠããŸãã
- ã¯ã©ãŠãããããžã§ãã³ã°: AWS, Azure, GCPãªã©ã®äž»èŠãªã¯ã©ãŠããããã€ããŒã®ãªãœãŒã¹ïŒVMããããã¯ãŒã¯ãããŒã¿ããŒã¹ãªã©ïŒãAnsibleã§äœæã»ç®¡çã§ããŸããTerraformãªã©ã®IaCããŒã«ãšçµã¿åãããŠäœ¿ãããããšããããŸãã
- ã³ã³ãã管ç: DockerãKubernetesã®ç®¡çã«ãAnsibleãå©çšã§ããŸããã³ã³ããã®ãã«ãããããã€ããªãŒã±ã¹ãã¬ãŒã·ã§ã³ãèªååã§ããŸãã
- ã»ãã¥ãªãã£èªåå: ãã¡ã€ã¢ãŠã©ãŒã«èšå®ãäŸµå ¥æ€ç¥ã·ã¹ãã ã®ç®¡çãã»ãã¥ãªãã£ãããé©çšãã³ã³ãã©ã€ã¢ã³ã¹ãã§ãã¯ãªã©ãã»ãã¥ãªãã£é¢é£ã®ã¿ã¹ã¯èªååã«ã掻çšã§ããŸãã
- åçã€ã³ãã³ããª: ã¯ã©ãŠãç°å¢ãªã©ããã¹ããªã¹ããåçã«å€ããå Žåã«ãå€éšãœãŒã¹ïŒAWS EC2 API, VMWare, Cobblerãªã©ïŒããã€ã³ãã³ããªæ å ±ãèªåçã«ååŸããä»çµã¿ã§ãã
- ã«ã¹ã¿ã ã¢ãžã¥ãŒã«ã»ãã©ã°ã€ã³éçº: æšæºã®ã¢ãžã¥ãŒã«ããã©ã°ã€ã³ã§èŠä»¶ãæºãããªãå Žåã«ãPythonãªã©ã§ç¬èªã®æ¡åŒµæ©èœãäœæã§ããŸãã
Ansibleã¯éåžžã«å¥¥ãæ·±ããæ§ã ãªãŠãŒã¹ã±ãŒã¹ã«å¯Ÿå¿ã§ããæè»ãªããŒã«ã§ããå ¬åŒããã¥ã¡ã³ããã³ãã¥ããã£ã®ãªãœãŒã¹ã掻çšããå®éã®æ¥åã§å°ããã€é©çšããŠããããšã§ããã®åŒ·åãªèªååèœåãå®æã§ããã§ãããã
- Ansible å ¬åŒããã¥ã¡ã³ã (è±èª)
- Ansible User Guide (è±èª)
- Ansible Galaxy
- Ansibleé¢é£ã®æžç±ããªã³ã©ã€ã³ã³ãŒã¹
- åçš®æè¡ããã°ãã³ãã¥ãã㣠(äŸ: Qiita, Zenn, Stack Overflow)
ð ãŸãšã
ãã®èšäºã§ã¯ãæ§æ管çã»èªååããŒã«ã§ããAnsibleã®å ¥éãšããŠããã®ã¡ãªãããä»çµã¿ãåºæ¬çãªäœ¿ãæ¹ãPlaybookã®æžãæ¹ããããŠå¿çšçãªãããã¯ã«ã€ããŠè§£èª¬ããŸããã
Ansibleã¯ãã·ã³ãã«ãããšãŒãžã§ã³ãã¬ã¹ãåªçæ§ãšãã£ãç¹åŸŽãæã¡ããµãŒããŒèšå®ããã¯ã©ãŠãããããã¯ãŒã¯ãã»ãã¥ãªãã£ãŸã§ãå¹ åºãITã€ã³ãã©ã®èªååãå®çŸããŸããæäœæ¥ã«ããç ©éãªäœæ¥ãã解æŸãããããå¹ççã§ä¿¡é Œæ§ã®é«ãã€ã³ãã©éçšãç®æãããã«ãAnsibleã¯éåžžã«åŒ·åãªæŠåšãšãªããŸãã
ãŸãã¯ç°¡åãªã¢ãããã¯ã³ãã³ããPlaybookããè©ŠããŠã¿ãŠãå°ããã€Ansibleã®äžçã«æ £ããŠãããŸããããèªååã«ããã¡ãªããããã²äœéšããŠãã ããïŒ ðª
ã³ã¡ã³ã