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

Ansibleとテスト

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for volanja volanja
September 22, 2014

 Ansibleとテスト

Ansible Meetup in Tokyo 2014.09

Avatar for volanja

volanja

September 22, 2014
Tweet

Other Decks in Technology

Transcript

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

    Ansibleྺ:1೥ (≒Github/Qiitaྺ) • QiitaʮAnsilbeͰ࡞ΔGitlab+RedmineʯͳͲɻ • Ansible Advent Calendar 2013
 ࡢ೥ɺ΍ͬͯΈ·ͨ͠ɻ࠷ॳͱ࠷ޙͷਓͰ͢ɻ
  2. ᵓᴷᴷ 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
  3. ࣮ߦ $ 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
  4. $ 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 ࣮ߦ
  5. $ 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 ࣮ߦ
  6. 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