1. 程式人生 > >第一天,ansible 源碼學習

第一天,ansible 源碼學習

ansible 源碼

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

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

從圖片中可以知道,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源碼

第一天,ansible 源碼學習