<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 使用 Augeas 自動修改配置文件 當然,有關標準的事物是如此之多。有時每個應用程序的配置格式都略有不同, 書寫正則表達式來解析和修改所有這些配置文件是一項很煩人的工作。 幸好 Augeas 在這方面可以幫助我們。Augeas 是一個旨在簡化使用不同配置文件格式工作的工具, 它將不同格式的配置文件統一呈現為一個簡單的包含所有配置項的樹狀結構。 Puppet 的 Augeas 支持允許你創建 augeas 資源,它可以智能地自動地為所需的配置做相應的改變。 #### 準備工作 在使用 Augeas 之前需要先安裝它。如下的 Puppet 代碼將添加 Augeas 到你的配置。 1. 使用如下內容創建 /etc/puppet/modules/admin/manifests/augeas.pp 文件: ``` class admin::augeas { package { [ "augeas-lenses", "augeas-tools", "libaugeas0", "libaugeas-ruby1.8" ]: ensure =&gt; "present" } } ``` 2. 在一個節點上包含此類: ``` node cookbook { include admin::augeas } ``` 3. 運行 Puppet: ``` # puppet agent --test info: Retrieving plugin info: Caching catalog for cookbook.bitfieldconsulting.com info: Applying configuration version '1303657095' notice: /Stage[main]/Admin::Augeas/Package[augeas-tools]/ensure: ensure changed 'purged' to 'present' notice: Finished catalog run in 21.96 seconds ``` #### 操作步驟 1. 使用如下內容創建 /etc/puppet/modules/admin/manifests/ipforward.pp 文件: ``` class admin::ipforward { augeas { "enable-ip-forwarding": context =&gt; "/files/etc/sysctl.conf", changes =&gt; [ "set net.ipv4.ip_forward 1", ], } } ``` 2. 在一個節點上包含此類: ``` node cookbook { include admin::augeas include admin::ipforward } ``` 3. 運行 Puppet: ``` # puppet agent --test info: Retrieving plugin info: Caching catalog for cookbook.bitfieldconsulting.com info: Applying configuration version '1303729376' notice: /Stage[main]/Admin::Ipforward/Augeas[enable-ipforwarding]/ returns: executed successfully notice: Finished catalog run in 3.53 seconds ``` 4. 使用如下命令檢查配置是否生效: ``` # sysctl -p |grep forward net.ipv4.ip_forward = 1 ``` #### 工作原理 下面將描述前面的代碼是如何工作的: 1. 我們聲明了一個名為 enable-ip-forwarding 的 augeas 資源: ``` augeas { "enable-ip-forwarding": ``` 2. 我們指定要實施改變的文件 /etc/sysctl.conf: ``` context =&gt; "/files/etc/sysctl.conf", ``` 3. 將我們需要改變的設置作為一個數組(本例中只有一個數組元素)傳遞給 changes 參數: ``` changes =&gt; [ "set net.ipv4.ip_forward 1", ], ``` 通常使用 Augeas 改變設置需用如下的格式: ``` set &lt;parameter&gt; &lt;value&gt; ``` Augeas 使用一套名為 **lenses** 的轉換文件,使其能夠為給定的配置文件以適當的格式改寫設置。 在本例中,此設置將轉換為 /etc/sysctl.conf 文件中的如下一行: ``` net.ipv4.ip_forward=1 ``` #### 更多用法 之所以使用 /etc/sysctl.conf 文件做例子,是因為它包含了各種各樣的內核設置, 你可能想要在不同的 Puppet 類中因各種不同的目的而改變這些設置。 在前面的例子中,我們為一個路由器的類啟用了 IP 轉發, 然而你也可以為一個負載均衡的類調整 net.core.somaxconn 的值。 這意味著簡單地對 /etc/sysctl.conf 文件“Puppet化”("Puppetizing") 并分發它不能勝任所有的情況,因為你要修改的設置根據不同的服務需求可能會有不同, 從而引發版本沖突。Augeas 則是這種情況的正確解決方案,因為你可以在不同的位置定義 augeas 資源去修改相同的配置文件,這樣就不會引起沖突。 Augeas 是個強大的工具,使用 lenses 可以轉換絕大多數標準的 Linux 配置文件, 而且如果需要管理自己的專有格式的配置文件,你也可以書寫自己的專有配置格式。 更多關于使用 Puppet 和 Augeas 的信息,請訪問 Puppet Labs 的 wiki 頁面: [http://projects.puppetlabs.com/projects/1/wiki/Puppet_Augeas](http://projects.puppetlabs.com/projects/1/wiki/Puppet_Augeas) 。
                  <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>

                              哎呀哎呀视频在线观看