Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)

316 views

Published on

因為當日實際只有 50 分鐘的分享時間,因此無法手把手的讓參與者操作每個步驟,但所有的操作步驟都已經公開於部落格文章中,可自行操作。此簡報為解說 workshop 101 每個環節之用,並提出一些在規劃 CI / CD pipeline 時需要注意的延伸思考。

Published in: Technology
  • Be the first to comment

Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)

  1. 1. Cheng Wei Chen @ Agile Tour Taipei 2017Photo by Daniel McCullough on Unsplash Ansible & GitLab CI / CD Workshop 101
  2. 2. Cheng Wei Chen 陳 正瑋 DevOps Engineer @ 得寬科技 http://chengweichen.com
  3. 3. 2013 100 % Laravel JetBrains ( )
  4. 4. PHP/Laravel http://www.laravel-dojo.com
  5. 5. 現場不進行詳細的操作步驟
  6. 6. 詳細步驟請參閱部落格文章 https://goo.gl/ZHKiyb
  7. 7. 在開始之前...
  8. 8. 你讀完了嗎?
  9. 9. 你讀完了嗎?
  10. 10. 沒讀完也很正常啦
  11. 11. 在開始動手之前, 你需要多想一想。
  12. 12. code build test release deploy operateplan Continuous Integration Continuous Delivery 目標 Continuous Deployment CIcommit dev stagingtest testprod deploy environment dev staging prod local
  13. 13. commit code build test release deploy operateplan Continuous Integration Continuous Delivery 今天的案例 Continuous Deployment CI staging testprod deploy environment staging prod
  14. 14. commit build stg-deploy test unit test prod-deploy 今天的案例 prod-remove
  15. 15. 該選用哪些工具?
  16. 16. 使用的工具 ‧Ansible ‧Docker CE ‧GitLab.com Your Computer Server Free Free Free
  17. 17. 環境說明 你的電腦 DEMO code GitLab .com Public Runner Cloud Web Server Your Runner container FreeFree
  18. 18. 環境說明 你的電腦 DEMO code GitLab .com Public Runner Cloud Web Server Your Runner container FreeFree FreeFree
  19. 19. GitLab CI 運作狀況 GitLab .com Public Runner Your Runner Docker container CI Jobs
  20. 20. 該從何處開始著手?
  21. 21. code build test release deploy operateplan Automation 從痛點、小處著手 Automation
  22. 22. Deploy 從痛點、小處著手 stagingdev test test production staging test production Project-1 Project-2 production Project-3 x10 x5 x3
  23. 23. build stg-deploy test unit test prod-deploy 今天的案例為例 prod-remove
  24. 24. .gitlab-ci.yml
  25. 25. build Stage: Build build-test build-release
  26. 26. Stage: Build build-test
  27. 27. Stage: Build build-release
  28. 28. Stage: Build build-release
  29. 29. Stage: Build Ansible: upload_artifacts.yml
  30. 30. build Stage: Build build-test build-release Artifacts (test) Artifacts (release) Artifacts Repository (release) Artifacts Repository (release)
  31. 31. Think : https://unsplash.com/photos/hANqC3_kTqU
  32. 32. ‧什麼是 Artifacts? ‧為何需要 Artifacts? ‧以及 Artifacts Repository? 延伸思考
  33. 33. 延伸思考 ‧為何要在 Build 時,同步進行 兩個 Jobs,一次就將測試與 Production 兩種環境的 Artifacts 給建立? ‧有沒有更好的做法?
  34. 34. 延伸思考 ‧在建立給 Production 使用的 Artifacts 時,還有哪些不必要 的檔案可以刪除,並不需要一 起放進 Artifacts Repository?
  35. 35. ‧將 Ansible Playbook 與程式碼一起 送進同一個 Project Repository? ‧自動化腳本應該如何存放?存放於 何處? ‧該如何讓 CI Runner 可以順利取得 自動化腳本呢? 延伸思考
  36. 36. build unit test Stage: unit-test build-test build-release phpunit
  37. 37. Stage: unit-test phpunit
  38. 38. Think : https://unsplash.com/photos/hANqC3_kTqU
  39. 39. ‧自動化測試? ‧What、When、How? ‧特別的測試組態該如何載入? 延伸思考
  40. 40. build unit test Stage: stg-deploy build-test build-release phpunit stg-deploy
  41. 41. Stage: stg-deploy stg-deploy
  42. 42. Ansible: auto-deploy.yml
  43. 43. Ansible: auto-deploy.yml
  44. 44. 變數傳遞 Project Ansible Playbook Your Runner Secret variable
  45. 45. Think : https://unsplash.com/photos/hANqC3_kTqU
  46. 46. 延伸思考 ‧Deploy 應該執行哪些動作?
  47. 47. ‧Deploy 的自動化腳本應該如何 設計? ‧Server 該如何與腳本配合? 延伸思考
  48. 48. ‧續上,你規劃的自動 Deploy 流程可以反覆的 Re-eploy 嗎? ‧當自動 Deploy 失敗時該如何 處理? 延伸思考
  49. 49. ‧Token、Key、inventory 或其 他 CI Job 需要的機敏資料應該 怎麼管理?並傳遞給 Runner? 延伸思考
  50. 50. ‧Zero downtime deploy? ‧DB、Files、Storages? 延伸思考
  51. 51. build unit test Stage: stg-test build-test build-release phpunit stg-deploy stg-test stg server stg server
  52. 52. Stage: stg-test test
  53. 53. ‧Staging 環境應該要與 Production 環境多相像? 延伸思考
  54. 54. 延伸思考 ‧在 Staging 環境中應該要執行 哪些自動化測試?
  55. 55. ‧除了測試程式碼,還有哪些東 西需要驗證? 延伸思考
  56. 56. ‧如何收集並回報測試的結果? ‧測試環境是否需要監控? 延伸思考
  57. 57. build unit test Stage: prod-deploy build-test build-release phpunit stg-deploy stg-test stg server stg server prod-deploy
  58. 58. Stage: test test prod-deploy
  59. 59. Think : https://unsplash.com/photos/hANqC3_kTqU
  60. 60. ‧Deploy 至 Staging 與 Production 的差異有哪些? 延伸思考
  61. 61. 延伸思考 ‧同一個 Deploy 自動化腳本如 何才能適用在不同的環境?
  62. 62. ‧再一次,Zero downtime deploy? ‧同樣 Files、Storages? ‧DB Migration? 延伸思考
  63. 63. ‧如何驗證 Deploy 確實成功? 延伸思考
  64. 64. ‧如何 Rollback? 延伸思考
  65. 65. ‧如何管理不同 Branch 不同 Pipeline? ‧哪些 Job 可以共用? 延伸思考
  66. 66. build unit test Stage: prod-deploy build-test build-release phpunit stg-deploy stg-test stg server stg server prod-deploy prod-remove
  67. 67. Summary
  68. 68. code build test release deploy operateplan Continuous Integration Continuous Delivery 目標 Continuous Deployment CIcommit dev stagingtest testprod deploy environment dev staging prod local
  69. 69. : https://unsplash.com/photos/Fixg8KipOg8 Trigger ScriptsInterface ServiceFlow 注意每個環節
  70. 70. 因為坑,比你想像的多 Oooops
  71. 71. 需要的資源(人力、工時), 也比你想像的多
  72. 72. 需要的評估關鍵, 也同樣比你想像的多
  73. 73. code build test release deploy operateplan Automation 從痛點、小處著手 Automation
  74. 74. • • • • • 思考並評估
  75. 75. 好書非讀不可
  76. 76. CD https://www.infoq.com/articles/Continuous-Delivery-Maturity-Model
  77. 77. 好書非讀不可 https://landing.google.com/sre/book.html
  78. 78. • Operator-triggered manual action • Operator-written, system-specific automation • Externally maintained generic automation • Internally maintained, system-specific automation • Autonomous systems that need no human intervention 自動化的演進 https://landing.google.com/sre/book.html
  79. 79. 反覆評估、持續改善 Photo by Sweet Ice Cream Photography on Unsplash 迭代
  80. 80. 工商服務
  81. 81. https://devopstw.club
  82. 82. 尋求志工、贊助 : https://pixabay.com/en/building-joy-planning-plans-1080592/ , https://pixabay.com/en/baby-hand-dad-200760/
  83. 83. 尋求講者及講題 : https://www.pexels.com/photo/man-person-suit-united-states-of-america-2281/
  84. 84. http://fb.sre.tw
  85. 85. Photo by Clark Tibbs on Unsplash Thank You

×