Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ansibleとテスト

B016de1381be90fd38ffbcdb10a41586?s=47 volanja
September 22, 2014

 Ansibleとテスト

Ansible Meetup in Tokyo 2014.09

B016de1381be90fd38ffbcdb10a41586?s=128

volanja

September 22, 2014
Tweet

Other Decks in Technology

Transcript

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

  2. Introduction • Twitter / Github / Qiita : volanja •

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

  4. Ansible΍ͬͯ·͔͢ʁ

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

  6. Severspec http://serverspec.org/

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

  8. 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
  9. ᵓᴷᴷ 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
  10. ࣮ߦ $ 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
  11. $ 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 ࣮ߦ
  12. $ 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 ࣮ߦ
  13. • 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

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

  15. 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
  16. Έͳ͞Μ͸Ͳ͏͍ͯ͠·͔͢ʁ

  17. Welcome to
 Ansible Advent Calendar 2014 at Qiita or ATND

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

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