Slide 1

Slide 1 text

Ansible Meetup in Tokyo 2014.09 LT ʮAnsibleͱςετʯ @volanja

Slide 2

Slide 2 text

Introduction • Twitter / Github / Qiita : volanja • Ansibleྺ:1೥ (≒Github/Qiitaྺ) • QiitaʮAnsilbeͰ࡞ΔGitlab+RedmineʯͳͲɻ • Ansible Advent Calendar 2013
 ࡢ೥ɺ΍ͬͯΈ·ͨ͠ɻ࠷ॳͱ࠷ޙͷਓͰ͢ɻ

Slide 3

Slide 3 text

Thank you All Author!!

Slide 4

Slide 4 text

Ansible΍ͬͯ·͔͢ʁ

Slide 5

Slide 5 text

ςετ͸Ͳ͏ͯ͠·͔͢ʁ

Slide 6

Slide 6 text

Severspec http://serverspec.org/

Slide 7

Slide 7 text

ansible_spec https://rubygems.org/gems/ansible_spec

Slide 8

Slide 8 text

ansible_spec • Ruby੡ίϚϯυϥΠϯπʔϧͰ͢ɻ
 AnsibleͱServerspecΛ૊Έ߹Θͤͯ࢖͏ͨΊͷɺ
 Rakefileͱspec_helper.rbΛ࡞੒͠·͢ɻ • Serverspec͸ɺAnsibleͷInventoryFile͔Βର৅ϗετΛɺ playbook͔Βର৅ϩʔϧΛɺಡΈࠐΜͰςετΛ࣮ߦ͠·͢ɻ $ gem install ansible_spec
 $ ansiblespec_init
 create spec
 create spec/spec_helper.rb
 create Rakefile
 create .ansiblespec

Slide 9

Slide 9 text

ᵓᴷᴷ hostsɹɹ(Inventoryfile)
 ᵓᴷᴷ site.yml (playbook)
 ᵓᴷᴷ roles
 ᴹ ᵋᴷᴷ nginx
 ᴹ ᵋᴷᴷ spec
 ᴹ ᵋᴷᴷ nginx_spec.rb
 ᴹ ᵋᴷᴷ tasks
 ᴹ ᵋᴷᴷ main.yml
 ᵓᴷᴷ Rakefile
 ᵓᴷᴷ spec
 ᵋᴷᴷ spec_helper.rb
 ᵋᴷᴷ .ansiblespecɹɹɹ(playbook, inventoryfileΛઃఆ͢ΔϑΝΠϧ) AnsibleͱServerspec Ansible Serverspec σΟϨΫτϦߏ੒(like BestPractise) by https://github.com/volanja/ansible-sample-tdd

Slide 10

Slide 10 text

࣮ߦ $ ansible-playbook site.yml -i hosts ! 
PLAY [Ansible-Sample-TDD] ***************************************************** GATHERING FACTS *************************************************************** ok: [192.168.0.103] (লུ) PLAY RECAP ******************************************************************** 192.168.0.103 : ok=10 changed=9 unreachable=0 failed=0 $ rake serverspec:Ansible-Sample-TDD
 
 Run serverspec for Ansible-Sample-TDD to 192.168.0.103
 /Users/Adr/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec 
 roles/nginx/spec/nginx_spec.rb
 ...........
 Finished in 0.79885 seconds
 11 examples, 0 failures

Slide 11

Slide 11 text

$ ansible-playbook site.yml -i hosts ! 
PLAY [Ansible-Sample-TDD] ***************************************************** GATHERING FACTS *************************************************************** ok: [192.168.0.103] (লུ) PLAY RECAP ******************************************************************** 192.168.0.103 : ok=10 changed=9 unreachable=0 failed=0 $ rake serverspec:Ansible-Sample-TDD
 
 Run serverspec for Ansible-Sample-TDD to 192.168.0.103
 /Users/Adr/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec 
 roles/nginx/spec/nginx_spec.rb
 ...........
 Finished in 0.79885 seconds
 11 examples, 0 failures site.yml is playbook
 - name: Ansible-Sample-TDD ࣮ߦ

Slide 12

Slide 12 text

$ ansible-playbook site.yml -i hosts ! 
PLAY [Ansible-Sample-TDD] ***************************************************** GATHERING FACTS *************************************************************** ok: [192.168.0.103] (লུ) PLAY RECAP ******************************************************************** 192.168.0.103 : ok=10 changed=9 unreachable=0 failed=0 $ rake serverspec:Ansible-Sample-TDD
 
 Run serverspec for Ansible-Sample-TDD to 192.168.0.103
 /Users/Adr/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec 
 roles/nginx/spec/nginx_spec.rb
 ...........
 Finished in 0.79885 seconds
 11 examples, 0 failures hosts is InventoryFile
 [Server] 192.168.0.103 ࣮ߦ

Slide 13

Slide 13 text

• Gemͷৄࡉ͸ҎԼͷϖʔδΛޚཡ͍ͩ͘͞ɻ
 Github volanja/ansible_spec
 https://github.com/volanja/ansible_spec • NginxͱMariaDBΛΠϯετʔϧ͢Δαϯϓϧ͕͋Γ·͢ɻ
 Githubɹvolanja/ansible-sample-tdd
 https://github.com/volanja/ansible-sample-tdd

Slide 14

Slide 14 text

ͱ͜ΖͰɺ Ansibleͱผͷςετπʔϧ͸ඞཁͰ͠ΐ͏͔ʁ

Slide 15

Slide 15 text

Testing Strategies • Ansible » Docs » Testing Strategies
 http://docs.ansible.com/test_strategies.html • Conclusion
 “Ansible believes you should not need another framework to validate basic things of your infrastructure is true.” • modules for Test
 assert, register, when, fail

Slide 16

Slide 16 text

Έͳ͞Μ͸Ͳ͏͍ͯ͠·͔͢ʁ

Slide 17

Slide 17 text

Welcome to
 Ansible Advent Calendar 2014 at Qiita or ATND

Slide 18

Slide 18 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ

Slide 19

Slide 19 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ དྷ݄ʹServerspec v2͕ग़ΔͷͰɺ ͝঺հͨ͠Gem͸ಈ͔ͳ͘ͳΔ͔΋͠Ε·ͤΜorz….