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

LT: Python and Ansible CI

Satoru SATOH
November 08, 2018

LT: Python and Ansible CI

LT: Python and Ansible CI @ Red Hat Tech Night 2018 @ Tokyo: https://ossbyredhat.connpass.com/event/106062/

Satoru SATOH

November 08, 2018
Tweet

Other Decks in Programming

Transcript

  1. Python & Ansible CI Python & Ansible CI レッドハット( 株)

    コンサルティングサービス事業部 シニアコンサルタント 佐藤 暁 <[email protected]> 2018-11-08 Rev. 1.0 1 . 1
  2. 自己紹介 自己紹介 佐藤 暁 ( さとる) <[email protected]> RHKK 18 年目

    (2000/06/01 入社、最古参) RHL 開発や組込み系サポート等、コンサルタント( 現職) 担当分野: RHEL, Lifecycle Management 系 (RHEL, RHEL HA, RHUI, Satellite, Ansible 他) 関った製品ほとんどで patch ( 修正コード) を書くはめに OSS 開発者: ( 本業ではありません) RHEL 本体: kernel network, libvirt dnsmasq backend 現実 装作者, 雑多な hacks (ansible, openscap ref. guide, ...) i18n/l10n: GNOME/KDE の i18n/l10n 元コミッタ (python などちょっとできる) https://github.com/ssato/ 1 . 3
  3. Python CI Python CI 大昔: CI ? テストがもしあるとしても手動だったり 基本書くだけ; doctest

    書くことがもしかするとあるかも位 昔 Unit & Integration Tests (TDD, XP, etc.) Python 3 migration 検討 (2to3); しかしテストは大変 Coding Guide: 人が見て気をつけてコード書く PEP: Google: ( これか ?) https://www.python.org/dev/peps/pep-0008/ https://github.com/google/styleguide/blob/gh- pages/pyguide.md 2 . 2
  4. Python CI Python CI 最近 ( 主観) Python 3 migration

    必須 or 最初からテスト含めて (tox, six) Unit & Integration Tests + Coverage Unit & Integration Tests 以外も充実: Lint/Static Analysis 系: pylint, pyflakes, mypy, McCabe Code Style Checker: pycodestyle ( 旧 pep8), yapf 色々 Health check 系: Landscape, Scrutinizer Doc: github, etc. + 連携 web services: {Travis,Circle}-CI 等 https://readthedocs.org/ 2 . 3
  5. Python CI: 実例 Python CI: 実例 python-anyconfig: CI としてやっていること: Travis-CI

    利用; flake8, pylint, pycodestyle Coverage: Health Check: Doc: https://github.com/ssato/python-anyconfig https://coveralls.io/github/ssato/python-anyconfig https://landscape.io/github/ssato/python-anyconfig/459 https://scrutinizer-ci.com/g/ssato/python-anyconfig/ https://python-anyconfig.readthedocs.io/en/latest/? badge=latest 2 . 4
  6. Python CI: まとめ Python CI: まとめ Unit & Integration Tests:

    自動化当たり前 Unit & Integration Tests 以外: Lint 系: もはや必須では Static Analysis 系: こちらもできれば Code Style Checker: 必須 色々 Health check 系: 複雑度確認や Bug を発生しやすい箇所 をみつけてくれるので非常におすすめ Doc: Library では必須ではないかと コードに文書断片から生成 ( 別途書いたりはしない) 2 . 5
  7. Ansible CI Ansible CI 大昔 ~ 昔: CI ? 『Ansible

    はコード書かずに簡単 YAML で書けるよ! 』-> 現実 には、簡単でも一種の『コード』で、テストは必要 etc. テストがもしあるとしても手動か、自動化されているとしても ansible-playbook --syntax-check してる位 (Coding) Style Guide 的なものはあるが人間が読んで理解して気 つけて書く想定: etc. http://https://docs.ansible.com/ansible/latest/user_guide/p ybooks_best_practices.html https://github.com/whitecloud/ansible-styleguide 3 . 2
  8. Ansible CI Ansible CI 最近 ( 主観) Unit & Integration

    Tests: Molecule (testinfra) Unit & Integration Tests 以外も充実: Lint/Static Analysis 系: yamllint, ansible-lint Code Style Checker: 同上 色々 Health check 系: これはまだないかも Doc: 内緒 github, etc. + 連携 web services: 連携は galaxy 位? 3 . 3
  9. Ansible CI: 実例 Ansible CI: 実例 ssato.openssl-cert: CI としてやっていること: Travis-CI

    利用; yamllint, ansible-lint molecule 対応は作業中 https://github.com/ssato/ansible-role-openssl-cert https://galaxy.ansible.com/ssato/ansible_role_openssl_cert 3 . 4
  10. Ansible CI: まとめ Ansible CI: まとめ Unit & Integration Tests:

    自動化は当たり前 molecule (testinfra) でどこまで実装するかはケースバイケース Unit & Integration Tests 以外: Lint/Static Analysis/Code Style Checker 系: 発展途上だが必須 かと ( 特に ansible-lint): 色々 Health check 系: 必要性はともかく今はないかも Doc: ... 参考: インフラCI 実践ガイド https://github.com/ansible/ansible- lint/blob/master/README.md#rules https://amazon.jp/dp/4798155128/ 3 . 5