天天看點

第一天,ansible 源碼學習

ansible 用過一段時間,都是停留在用的階段,好奇它内部是如何執行,是以準備從源碼分析。

分析一個程式,先了解它的執行流程會對學習很有幫助(ps:圖檔是使用網絡的)。

第一天,ansible 源碼學習

從圖檔中可以知道,ansible 執行的步驟就6步,其中前面第二、第三是确定ansible 要操作的對象。第四步是确定要調用那一個子產品,第五步是執行。從ansible文檔可以知道,第五步是把子產品拷到要執行的機器上,然後通過ssh執行。(原文:Ansible works by connecting to your nodes and pushing out small programs, called “Ansible Modules” to them. These programs are written to be resource models of the desired state of the system. Ansible then executes these modules (over SSH by default), and removes them when finished.)是以ansible 的子產品可以是多種程式設計語言編寫,隻要執行結束輸出的結果傳回是符合ansible規範的json字元串就能夠解析。

下一步,将按照ansible執行流程來學習ansible源碼

轉載于:https://blog.51cto.com/3106950/2091889