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

Ansible 2.0 at Ansible Meetup in Tokyo 2015.09

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →
shirou
September 14, 2015

Ansible 2.0 at Ansible Meetup in Tokyo 2015.09

shirou

September 14, 2015

Transcript

23 slides
  1. ͓લͩΕΑ • एࢁ ࢙࿠@r_rudi / πΩϊϫגࣜձࣾ CTO • WebΞϓϦ։ൃ͔Βӡ༻·Ͱ •

    ීஈ͸golangͰWebΞϓϦॻ͍ͯ·͢ • ஶॻʮೖ໳Ansibleʯ • Amazonʹͯൢചத(ిࢠॻ੶)
  2. Ansible 2.0ͱ͸ • ࠷৽͸1.9.3 (1.9.4͕rc2) • 1ܥͱฏߦͯ͠2ܥ͕௕͍ؒ։ൃ͞Ε͍ͯͨ • গͳ͘ͱ΋ࠓ೥2݄Ҏ߱ •

    ಺෦ߏ଄Λ΄΅Ұ͔Βॻ͖௚ͨ͠ • ίʔυ໊: ”Over the Hills and Far Away” (Led Zeppelin)
  3. block • taskΛ͞Βʹ෼ׂͰ͖·͢ tasks: - block: - yum: name={{ item

    }} state=installed with_items: - httpd - memcached - template: src=templates/src.j2 dest=/etc/foo.conf - service: name=bar state=started enabled=True when: ansible_distribution == 'CentOS'
  4. blockʹΑΔྫ֎ॲཧ tasks: - block: - debug: msg='࣮ߦ͞Ε·͢' - fail: msg=“fail!!!”

    - debug: msg=‘Τϥʔ͕ى͖ΔͨΊɺ͜͜͸࣮ߦ͞Ε·ͤΜ' rescue: - debug: msg=‘Τϥʔ͕͓͖·ͨ͠' - fail: msg=“rescue಺Ͱfail!!” - debug: msg='͜͜΋࣮ߦ͞Ε·ͤΜ' always: - debug: msg="ඞ࣮ͣߦ͞Ε·͢"
  5. block಺Ͱઃఆͷ্ॻ͖ - hosts:
 remote_user: someuser
 tasks: - block: - shell:

    whoami
 - shell: touch /etc/hosts
 become_user: root
  6. taskϨϕϧͰͷม਺ • taskϨϕϧͰఆٛɾ্ॻ͖͕Մೳʹ vars: aa: "AA" tasks: - debug: msg="{{

    aa }}" - debug: msg="{{ aa }}" vars: aa: “BB" - debug: msg="{{ aa }}” -> AA -> BB -> AA
  7. Ϟδϡʔϧ/pluginͷ௥Ճ • 140Ҏ্ͷ৽نϞδϡʔϧͷ௥Ճ • openstackɺdockerɺzabbixɺvmware… • inventory, connection plugin΋௥Ճ •

    serf, consul, dockerͳͲ • callback plugin͕ಉࠝɻansible.cfgʹॻ͚ͩ͘Ͱ༗ޮ Խ(callback_whitelist)
  8. ྫ: profile_tasks plugin [defaults] callback_whitelist = profile_tasks TASK [debug msg={{

    aa }}] ****************************************************** Monday 14 September 2015 16:00:20 +0900 (0:00:00.074) 0:00:00.162 ****** ok: [localhost] => { "changed": false, "msg": "AA" } Monday 14 September 2015 16:00:20 +0900 (0:00:00.078) 0:00:00.241 ****** =============================================================================== TASK: debug msg={{ aa }} ------------------------------------------------ 0.08s TASK: debug msg={{ aa }} ------------------------------------------------ 0.08s TASK: debug msg={{ aa }} ------------------------------------------------ 0.07s

More Decks by shirou

Other Decks in Technology