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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 使用配置片段構建配置文件 你怎能一口吃頭大象呢?有時你會遇到這種情況,想要從被不同類管理的各種片段構建單一的配置文件。 例如,你可能有兩到三個服務需要 rsync 模塊配置,因此你不能只發布單一的配置文件 rsyncd.conf。 盡管你可以使用 Augeas,但是一種更簡單的方法就是使用 exec 資源將若干配置片段串接成一個文件。 #### 操作步驟 1. 使用如下代碼創建 /etc/puppet/modules/admin/manifests/rsyncdconf.pp 文件: ``` class admin::rsyncdconf { file { "/etc/rsyncd.d": ensure =&gt; directory, } exec { "update-rsyncd.conf": command =&gt; "/bin/cat /etc/rsyncd.d/*.conf &gt; /etc/rsyncd.conf", refreshonly =&gt; true, } } ``` 2. 添加如下代碼到你的配置清單: ``` class myapp::rsync { include admin::rsyncdconf file { "/etc/rsyncd.d/myapp.conf": ensure =&gt; present, source =&gt; "puppet:///modules/myapp/myapp.rsync", require =&gt; File["/etc/rsyncd.d"], notify =&gt; Exec["update-rsyncd.conf"], } } include myapp::rsync ``` 3. 使用如下內容創建 /etc/puppet/modules/myapp/files/myapp.rsync 文件: ``` [myapp] uid = myappuser gid = myappuser path = /opt/myapp/shared/data comment = Data for myapp list = no read only = no auth users = myappuser ``` 4. 運行 Puppet: ``` # puppet agent --test info: Retrieving plugin info: Caching catalog for cookbook.bitfieldconsulting.com info: Applying configuration version '1303731804' notice: /Stage[main]/Admin::Rsyncdconf/File[/etc/rsyncd.d]/ensure: created notice: /Stage[main]/Myapp::Rsync/File[/etc/rsyncd.d/myapp.conf]/ ensure: defined content as '{md5}e1e57cf38bb88a7b4f2fd6eb1ea2823a' info: /Stage[main]/Myapp::Rsync/File[/etc/rsyncd.d/myapp.conf]: Scheduling refresh of Exec[update-rsyncd.conf] notice: /Stage[main]/Admin::Rsyncdconf/Exec[update-rsyncd.conf]: Triggered 'refresh' from 1 events notice: Finished catalog run in 1.01 seconds ``` #### 工作原理 admin::rsyncdconf 類為存放 rsync 的配置片段創建了如下目錄: ``` file { "/etc/rsyncd.d": ensure => directory, } ``` 當你創建一個配置片段(例如本例中的 myapp::rsync),你要做的所有工作就是 require 這個目錄(require =&gt; File["/etc/rsyncd.d"])并 notify 資源 exec 更新主配置文件 (notify =&gt; Exec["update-rsyncd.conf"],)。 只要 /etc/rsyncd.d 目錄中有一個配置片段被更新,exec 資源就會執行一次: ``` exec { "update-rsyncd.conf": command => "/bin/cat /etc/rsyncd.d/*.conf > /etc/rsyncd.conf", refreshonly => true, } ``` 這樣,/etc/rsyncd.d 目錄中的所有配置片段將會串接成一個 rsyncd.conf 文件。 這是非常有用的,原因在于你可以有許多不同的片段資源散布在各個不同的類或模塊中, 所有這些片段最終都將被合并成單一的 rsyncd.conf 文件,而你卻可以在一個地方實現配置代碼的合并。 #### 更多用法 當你有一個像 rsync 這樣的服務且在一個配置文件中需要包含不同的片段時,這會是一種很有用的模式。 實際上,這為你提供了類似于 Apache 的 conf.d 目錄或 PHP 的 php-ini.d 目錄的功能。 #### 參見本書 * 第 2 章的 [Using tags](#ch02sec13) 一節
                  <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>

                              哎呀哎呀视频在线观看