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

Ansible-Playbook-CleanUp-WinUpd-TempFiles

 Ansible-Playbook-CleanUp-WinUpd-TempFiles

Windows Update の中間ファイル(ゴミ)を Ansible Playbook で一発で掃除することができるので事例を紹介します

Hisashi SOGA
PRO

September 01, 2017
Tweet

More Decks by Hisashi SOGA

Other Decks in Programming

Transcript

  1. Windows Update ͷதؒϑΝΠϧ(ΰϛ)Λ Ansible Playbook ͰҰൃͰ૟আ͢Δ 2017/09/01 @sogaoh 1 Presentation

    Slide at https://ansible-users.connpass.com/event/62508/
  2. AGENDA • ࣗݾ঺հ • લఏ • ઃఆ • ࣮ߦ •

    ஫ҙ఺ • ͓ΘΓʹ 2
  3. ࣗݾ঺հ • ીզɹԝ / Hisashi SOGA – Twitter : @sogaohɹ,

    GitHub : sogaoh • Marketing Applications, Inc. / MApps – WebΞϯέʔτ࡞੒ɾ഑৴αʔϏε forSurvey – ए೥૚ճऩ਺ࠃ಺No.1ͷ MApps Panel • DevOpsਪਐࣨ (ফ๷ୂ ) – Πϯϑϥ ʛ˛˕˛˛˗˛ʵʛ ΞϓϦ – ϑϩϯτ ʛʵʵʵ˛˗˕˛ʛ αʔό ɹ 3 ◆࠷ॳ ˛कඋൣғ ˕ΠϚίί
  4. લఏ • ※࣮૷ͨ͠ͷ͕̍೥͘Β͍લͰ͢ • Ansible (Server) ଆ (Playbook࣮ߦ؀ڥ) – CentOS

    7.2, ansible 2.1.0.0, Python 2.7 • Windows (Agent) ଆ – Powershell 3 Ҏ্ (5 ΛೖΕͨ) – Win 2008 R2 ʹ͸Πϯετʔϧ͕ඞཁɹɹɹɹɹ (2.0͕σϑΥϧτ) 4
  5. ઃఆ (1) • Windows (Agent) ଆ • ઃఆεΫϦϓτμ΢ϯϩʔυ • ઃఆεΫϦϓτ࣮ߦ

    • AllowUnencrypted="true"Λઃఆ 5 PS> Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ ConfigureRemotingForAnsible.ps1 -OutFile ConfigureRemotingForAnsible.ps1 PS> powershell -ExecutionPolicy RemoteSigned ./ConfigureRemotingForAnsible.ps1 PS C:\tmp> winrm set winrm/config/service '@{AllowUnencrypted="true"}'
  6. ઃఆ (2) • Ansible (Server)ଆ • pywinrm ͷΠϯετʔϧ • Winଆͷࣗݾূ໌ॻݕূΛεΩοϓ͢ΔઃఆΛೖΕΔ

    • /opt/ansible_win/ansible.cfg • ຤ඌʹ௥هɹɹɹɹɹɹɹɹɹɹɹͦͷଞௐ੔ 6 $ sudo mkdir -p /opt/ansible/callback_plugins $ sudo vim /opt/ansible/callback_plugins/fix-ssl.py [defaults] bin_ansible_callbacks=True callback_plugins = ./callback_plugins ansible_winrm_server_cert_validation=ignore $ sudo pip install pywinrm inventory = /opt/ansible_win/hosts host_key_checking = False
  7. ࣮ߦ • ૄ௨֬ೝ • ࣮ߦ 7 ansible win-host-01 -m win_ping

    env ANSIBLE_CONFIG=/opt/ansible_win/ansible.cfg ansible- playbook ./cleanup-win-update-tmp-files.yml -l win-host-01 env ANSIBLE_CONFIG=/opt/ansible_win/ansible.cfg ansible- playbook ./cleanup-win-installer-tmp-files.yml -l win-host-01 refs: https://github.com/sogaoh/AnsiblePractice/tree/master/operation/windows
  8. ஫ҙ఺ • ΢Οϧεରࡦιϑτ͕ೖ͍ͬͯΔ৔߹ • ϙʔτ5985, 5986 ͷղ์͕ඞཁ • ΞϯΠϯετʔϧ͕Ͱ͖ͳ͘ͳΔ •

    ʮ੾Γ໭͢ʯՄೳੑ͕͋Δ؀ڥͰ͸࣮ߦ ʹ஫ҙɾݕূ͕ඞཁ 8
  9. ͓ΘΓʹ • Windows ʹର͢ΔఆܕԽ͞Ε͍ͯΔΦϖϨʔ γϣϯ΋ɺ͖ͬͱࣗಈԽɾ؆ૉԽͰ͖Δ • ଞʹ΋ɺAnsible ͰҎԼͷΑ͏ͳ͜ͱΛ؆ૉԽ͠ ͓ͯΓɺ୭Ͱ΋Ͱ͖Δମ੍Λ੔͍͑ͯ·͢ •

    BIND ͷόʔδϣϯΞοϓ • STNS ΫϥΠΞϯτͷηοτΞοϓ • ͜ΜͳνʔϜʹjoin͍ͨ͠ͱࢥͬͨํ͸↓΁ͥͻɹ 9 https://jp.stanby.com/ats/marketing-applications/jobs