Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)

1,761 views

Published on

Ansible Night in Nagoya 2019.02 での発表資料です。
https://ansible-users.connpass.com/event/116946/


Published in: Technology
  • Be the first to comment

Ansibleではじめるサーバー・ネットワークの自動化(2019/02版)

  1. 1. @akira6592 /1 . 2 / 0 2019.02
  2. 2. l 7 li e . l 2 A n b 2 2 .
  3. 3. 3 0 6 5 2 25 1 https://tekunabe.hatenablog.jp https://www.slideshare.net/akira6592/ 8 9 AD https://gihyo.jp/magazine/SD/archive/2018/201812
  4. 4. 4 https://www.sugakiya.co.jp/products/sokuseki/soku_f_0095.html
  5. 5. 5 l l 8 . l 2 : : l l A
  6. 6. 6 Ansible
  7. 7. Ansible 7 l Playbook l l l l Chef puppet
  8. 8. Ansible 1. • 2. • • 3. • 4. Ansible 8 l Ansible YAML
  9. 9. insr 9 l . srd in / c bjq l c begu https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html w : - q u : /- a b P . / c bo . / / : : /- : . mh a b f R tl c b o a b Wa_c :/ py
  10. 10. 10 Ansible
  11. 11. 4 3(11. 2 ( ) 11 4 11. 2 ) ( 123 123 123 P
  12. 12. l IP l 12 6 12 02. 2 1 1 0 AWS Zabbix
  13. 13. l Ansible l Playbook 13 •Linux •Windows •AWS •Azure •GCP •Dcoker •OpenStack DB •PostgreSQL •MySQL •MS SQL Server •Zabbix •Sensu •nagios •Mail •Slack •syslog NW •Cisco IOS •Juniper Junos •Arista EOS
  14. 14. 14 http://docs.ansible.com/ansible/modules_by_category.html yum yum user win_firewall_rule Windows Firewall ec2 AWS ec2 azure_rm_virtualmachine Azure VM ios_config Cisco IOS junos_config Juniper Junos
  15. 15. l YAML P l Playbook ad-hoc 15 : / 2 2 / - 2 2 2 2 2 -2 - - 2 -2 . ::: -2
  16. 16. ansible.cfg l Ansible l SSH l 16
  17. 17. 17 1 Web
  18. 18. 18 1 UP
  19. 19. 19 : : 6 60 2 6 . 7 60 2 66/ 0 7 1 02 66/ 7 676 1 web 172.16.0.10 web 1
  20. 20. Playbook 20 --- - hosts: web become: yes tasks: - name: httpd package yum: name: httpd state: present - name: deploy index.html template: src: index.html.j2 dest: /var/www/html/index.html - name: httpd service service: name: httpd state: started enabled: yes vars: v_name: world web sudo yum httpd template index.html.j2 /var/www/html/index.html service httpd v_name world 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1
  21. 21. 21 <html> <head> <title>Test Page</title> </head> <body> <h1>Hello, {{ v_name }} !</h1> </body> </html> Playbook Ansible Jinja2 1
  22. 22. Playbook 22 . - 21 6 7 =: 40 7 = AE . F 7 $ 40 7 G G = E = 7 $ 40 7 =GCF AE = C E = 7 $ 40 7 G = LA = E = 7 $ 21 6 3 2 $ F * E = * KE = :C=* AC= * -i Playbook web httpd changed Index.html changed httpd changed 1
  23. 23. 23 Hello, {{ v_name }} ! v_name: world 1
  24. 24. 24 1 https://youtu.be/7jIv_h6xQcM → Playbook →
  25. 25. 25 2
  26. 26. 26 @/ @/ 6/ / 1 = 6/ 2 : =/ / 0 6/ 2 =/ = / 9 9 6/ /=@9 9 9 6/ / .7 6/ 2 : : juons 172.16.0.1 juons OS 2
  27. 27. Playbook 27 --- - hosts: junos gather_facts: no connection: netconf tasks: - name: ntp config test junos_config: lines: - set system ntp server 10.0.1.123 - name: config backup junos_command: commands: - show configuration register: result - name: save config to file copy: content: "{{ result.stdout[0] }}" dest: "show_config_{{ inventory_hostname }}.txt" juons SSH NETCONF junos_config NTP 10.0.1.123 junos_config show copy result 0 show_config_172.16.0.1.txt show result 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2
  28. 28. Playbook 28 . - - A .*3 C 2*1 C : =6 : $ 2*1 C 76 C $ 2*1 6 : C C A: =6 : $ .*3 0 * $ C =6 : $ E:6 =67A: 6 A: -i Playbook junos changed show configuration 2
  29. 29. 29 XTail eh U il eh df _ 1 0 A B@L ; B >D B C; > > >D > > # # # NW ; A : B@: # # # # 6; A; @> . -" " -. . 874 > B # "5 # / >D A " ;D> / ";L A> B ; B > > " ; ##### / A" ; A" ; 22223 ##### / C @B L > ;@ ; LB / #### > > # # # / B > ; > @>" $ $ ##### Ansible 2 https://postd.cc/8-tips-for-great-code-reviews/
  30. 30. 30 2 → Playbook → https://youtu.be/tE63YsOrX9Q
  31. 31. 31 Ansible 2.8
  32. 32. Ansible 2.8 (2019/05/02 c TO l e I I A L MN f l 0310 8 4 f 2 9 4 TO LY Y L . f l / A 32 lAnsible 2.8 New module list https://awsbloglink.wordpress.com/2018/09/05/ansible-2-8-new-module-list/ ldevel branch chengelogs https://github.com/ansible/ansible/tree/devel/changelogs/fragments
  33. 33. 33
  34. 34. 34 l Ansible l l Linux Windows NW l Playbook
  35. 35. 35 l l l https://docs.ansible.com/ l Getting Started l https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html l l http://docs.ansible.com/ansible/modules_by_category.html l l Ansible 101 by irixjp | Katacoda l https://www.katacoda.com/irixjp/scenarios/ansible-101 l l Ansible 2 l https://book.impress.co.jp/books/1117101100 l Ansible l https://www.shoeisha.co.jp/book/detail/9784798149943
  36. 36. 36 // . . . -. .. l Ansible Night l LT l Ansible l l l Slack (ansiblejp) l http://bit.ly/slack-ansiblejp 3,000

×