æ°ããã®YAMAHA製ã«ã¼ã¿ã¯Ansibleã§è¨å®ã管çãããã¨ãã§ããã
æé ã«æ¸ãã¦ããéã
- SSHç¨ã®ã¦ã¼ã¶ãç¨æãã
- SSHæ©è½ãæå¹ã«ãã
- Ansibleã®ã³ã¼ããæ¸ãã¦é©ç¨ãã
ã®é åºã§é©ç¨ã§ããã
ç´ æ´ãªæ§æã§ããã°ãµã³ãã«ã¨åãå½¢ã§å®ç¾å¯è½ã ããã©ãè¤æ°ç°å¢ãè¤æ°æ ç¹ã®configãå ±éåãããã¨ãªãã¨é層åãã¦ç®¡çããããªããå®éãèªåã¯èªå® ã¨å®å®¶ã§RTX830ãéç¨ãã¦ãã¦ããå°ã£ãããªã®ã§ãå ·ä½çã«ã©ã®ãããªæ§æã«ããã®ããè¨ãã¦ãããã»ã¨ãã©Ansibleã®è©±ãªã®ã§Ansibleã«æ £ãã¦ãã人ã«ã¯ãã¾ãããªè©±é¡ã ã¨æã*1ã
ãã£ã¬ã¯ããªæ§æã¨inventories
ãµã³ãã«ã ã¨åãã¡ã¤ã«ããã©ããã«é ç½®ãã¦ãããã©ãç°å¢ãæ ç¹ãè¤æ°ããå ´åã¯ãããããè¤éãªæ§æãã¨ããããªãã¯ããèªåã¯Ansibleå ¬å¼ããã¥ã¡ã³ãã®ãã¹ããã©ã¯ãã£ã¹*2ã«åã£ã¦ãã£ã¬ã¯ããªæ§æãçµããã¨ã«ããã
$ tree . âââ inventories â  âââ test â  âââ group_vars â  â  âââ network_noop.yml â  â  âââ network_test.yml â  âââ hosts.yml â  âââ host_vars â  âââ hostname.yml.example âââ README.md âââ roles â  âââ router â  â  âââ tasks â  â  âââ general.yml â  â  âââ lan.yml â  â  âââ main.yml â  â  âââ ntp.yml â  â  âââ upstream.yml â  âââ save_configuration â  âââ tasks â  âââ main.yml âââ router.yml
inventories/
以ä¸ã«ç°å¢ãã¨ã®ãã£ã¬ã¯ããªãç¨æãã hosts.yml
ã«ãã¹ãã®æ
å ±ã¨æ ç¹ã®æ
å ±ãæ¸ãã¦ãããhosts.yml
ã®ä¸èº«ã¯ä»¥ä¸ã®ãããªé°å²æ°ã
--- # roles router: hosts: router_test: ansible_host: 192.168.0.1 ansible_network_os: yamaha_network.rtx.rtx router_noop: ansible_host: 192.168.16.1 ansible_network_os: yamaha_network.rtx.rtx # network groups network_test: hosts: router_test: network_noop: hosts: router_noop:
ãããããã¨ã§ãã©ã®ç°å¢ã®ã©ã®æ ç¹ã«å¯¾ãã¦æ§æãé©ç¨ããããé¸æã§ããããã¨ãã° test
ç°å¢ã® network_test
æ ç¹ã«å¯¾ãã¦é©ç¨ããã®ã§ããã°ä»¥ä¸ã®ã³ãã³ããçºè¡ããã
$ ansible-playbook -i ./inventories/test/hosts.yml router.yml --limit network_test --ask-vault-pass
ãªã router.yml
ã¯ãããã調åã
- hosts: router connection: network_cli roles: - router - save_configuration
VLANã®IDãIPã®ç¯å²ãDHCPã®ã¹ã³ã¼ãç¯å²ãªã©ã¯ group_vars
以ä¸ã«æ¸ãã¦ããã¨è¯ãã host_vars/HOSTNAME.yml
ã«ã¯ã«ã¼ã¿ã¸ã®æ¥ç¶æ
å ±ãæ¸ãã
--- ansible_user: SSH_USER ansible_ssh_pass: SSH_PASSWORD ansible_become: true ansible_become_password: ADMINISTRATOR_PASSWORD
æ¥ç¶æ å ±ã¯æå·åãã¦ä¿åãã
æ¥ç¶æ
å ±ãå¹³æã§ç½®ãã®ã¯ããªãæµæããããAnsibleã«ã¯å¤æ°ãã¡ã¤ã«ãæå·åããæ©è½ãããã®ã§ãããå©ç¨ãããhost_vars/HOSTNAME.yml
ã丸ãã¨æå·åããã«ã¯
$ ansible-vault encrypt host_vars/HOSTNAME.yml
ãå®è¡ããã°è¯ãã ansible-playbook
ã³ãã³ãã®å®è¡æã« --ask-vault-pass
ãªãã·ã§ã³ãä»ãããã¨ã§å¾©å·ãã¤ã¤é©ç¨ãããã¨ãã§ããã
ã«ã¼ã¿åæåæã®æé ã« ip lan1 address
㨠dhcp scope
ã®è¨å®ãå«ãã
ip interface address ip_address/mask
ã§interfaceã®IPã¢ãã¬ã¹ãæå®ãããã¨ãã§ãã*3ãip lan1 address 192.168.0.1/24
ã®ãããªè¦é ã
YAMAHAã«ã¼ã¿ã¯ã³ãã³ããå®è¡ããã¨é次æåãå¤åããã®ã§ãSSHã«IPv4ãå©ç¨ãã¦æ¥ç¶ãã¦ããå ´å ip lan1 address
ã§lan1ã®IPã¢ãã¬ã¹ãå¤æ´ããã¨ãã®å¾ã®è¨å®ãé©ç¨ã§ããªããªãã ããã°ããã¯ã©ããããããªãã®ã§ãSSHã¦ã¼ã¶ãæºåãããªã©ã®åæåæã®æé å
ã§lan1ã®IPã¢ãã¬ã¹è¨å®ã¨DHCPã®è¨å®ãè¡ãããã«ããã
Web UIããè¨å®ããã°åæã«å¤æ´ãããã¨ãã§ããããã³ã³ã½ã¼ã«ã±ã¼ãã«ã§æ¥ç¶ãã¦è¨å®ããã§ãè¯ããèªåã¯ã³ã³ã½ã¼ã«ã±ã¼ãã«ãç¨æãã¦æ¥ç¶ãã¦ããã
ç´ æ´ã«1å°ã ã管çãããªãconfigãã¡ã¤ã«ãæã£ã¦ããã¦é©ç¨ããã°è¯ãããã©ãæ ç¹ãè¤æ°ãã£ããä»ã®æ©æãAnsibleã§ç®¡çãã¦ããå ´åã¯ä¾¿å©ãããªã®ã§æ¤è¨ãã¦ãè¯ãããã
*1:èªåã¯æ®æ®µAnsibleã使ã£ã¦ãããmitamaeãTerraformãCDKã¨ããæããªã®ã§å ¬å¼ããã¥ã¡ã³ããèªã¿è¾¼ã¿ãªããæ¤è¨ãã
*2:https://docs.ansible.com/ansible/2.8/user_guide/playbooks_best_practices.html#alternative-directory-layout
*3:http://www.rtpro.yamaha.co.jp/RT/manual/rt-common/ip/ip_interface_address.html