<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ### 繪制依賴關系圖 依賴關系會迅速變得復雜起來,并且很容易形成 **循環依賴**(**circular dependency**) (即 A 依賴 B,B 又依賴 A),這將導致 Puppet 發生錯誤并停止工作。 幸運的是, Puppet 的 --graph 選項可以很容易生成一個資源之間的依賴關系圖, 它可以幫助我們解決循環依賴的問題。 #### 準備工作 使用如下命令安裝查看圖片文件所需的 graphviz 軟件包: ``` # apt-get install graphviz ``` #### 操作步驟 1. 創建 /etc/puppet/modules/admin/manifests/ntp.pp 文件,添加包含如下循環依賴的代碼: ``` class admin::ntp { package { "ntp": ensure =&gt; installed, require =&gt; File["/etc/ntp.conf"], } service { "ntp": ensure =&gt; running, require =&gt; Package["ntp"], } file { "/etc/ntp.conf": source =&gt; "puppet:///modules/admin/ntp.conf", notify =&gt; Service["ntp"], require =&gt; Package["ntp"], } } ``` 2. 復制已存在的 ntp.conf 文件到 Puppet: ``` # cp /etc/ntp.conf /etc/puppet/modules/admin/files ``` 3. 在一個節點上包含這個類: ``` node cookbook { include admin::ntp } ``` 4. 運行 Puppet: ``` # puppet agent --test info: Retrieving plugin info: Caching catalog for cookbook.bitfieldconsulting.com err: Could not apply complete catalog: Found 1 dependency cycle: (File[/etc/ntp.conf] =&gt; Package[ntp] =&gt; File[/etc/ntp.conf]); try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz notice: Finished catalog run in 0.42 seconds ``` 5. 使用上面建議的 --graph 選項運行 Puppet: ``` # puppet agent --test --graph ``` 6. 檢查已經創建的圖片文件: ``` # ls /var/lib/puppet/state/graphs/ expanded_relationships.dot relationships.dot resources.dot ``` 7. 創建一個圖形化的關系依賴圖 ``` # dot -Tpng -o relationships.png \ /var/lib/puppet/state/graphs/relationships.dot ``` 8. 使用如下命令查看關系依賴圖: ``` # eog relationships.png ``` ![https://box.kancloud.cn/2016-05-12_5733eecec3c64.png](https://box.kancloud.cn/2016-05-12_5733eecec3c64.png) #### 工作原理 當你運行 puppet --graph (或者在 puppet.conf 文件中啟用 graph 選項), Puppet 會生成三個 **DOT** 格式(一種圖形語言)的文件。三個文件分別是: * resources.dot:顯示資源的類和層次結構,但沒有依賴關系 * relationships.dot:以箭頭顯示資源之間的依賴關系,如上圖所示 * expanded_relationships.dot:一個更詳細版本的關系圖 dot 工具(是 graphviz 軟件包的一部分) 可以將這些文件轉換為 PNG 格式進行查看。 在關系圖中,你的配置清單中的每個資源顯示為一個氣球, 用帶箭頭的線連接它們表示依賴關系。 從上面的例子中我們可以看到,在 File["/etc/ntp.conf"] 和 Package["ntp"] 之間存在循環依賴關系。 為了解決循環依賴問題,你要做的就是刪除一條依賴關系線,從而打破循環。 #### 更多用法 即使你不用去尋找錯誤(bug),資源和其關系圖也非常有用。 如果你為一個非常復雜的網絡設計類和資源,研究資源關系圖可以讓你看起來更簡單。 同樣,當依賴關系變得過于復雜,通過閱讀配置清單難于理解時,關系圖比文檔就顯得更為有用。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看