<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國際加速解決方案。 廣告
                ### 從 Shell 會話生成 Puppet 配置清單 > I object to being called a chess genius, because I consider myself to be an all around genius who just happens to play chess, which is rather different. > > — Bobby Fischer 并非所有人都是天才。如果你確切地知道安裝一個應用程序或服務都需要做些什么的話, 你馬上就可以創建 Puppet 的配置清單。盡管如此,你通常還是需要首先做些小小的試驗, 比如找到你要安裝的軟件包、需要編輯哪些配置文件等等。 你可以使用 script 命令記錄你的 Shell 會話,然后根據會話文件的記錄內容開發 Puppet 的配置清單,這是個不錯的方法。 但如果有一個工具能通過讀取你的會話文件生成 Puppet 配置清單的話是不是更精彩呢? 為了實現此功能,**cft** (讀音為 'sift')應運而生。 一旦你激活它,cft 監視你的 Shell 會話并記住你安裝的任何軟件包、任何服務的配置、 任何你創建或編輯的文件,等等。 當會話記錄結束,cft 會生成一個重現你剛剛所做的所有改變的完整的 Puppet 配置清單。 #### 準備工作 1. 當前完整的 cft 支持僅能用于 Red Hat/CentOS 發行版;針對 Debian/Ubuntu 發行版的完整的支持正在開發中,估計不久之后即可完成。 如果你正在使用 Red Hat/CentOS,只要安裝 cft 即可: ``` # yum install cft ``` 2. 對于 Debian/Ubuntu 系統,請參考如下安裝說明,網址為: [http://fmtyewtk.blogspot.com/2011/01/porting-cft-to-debian.html](http://fmtyewtk.blogspot.com/2011/01/porting-cft-to-debian.html) 。 #### 操作步驟 1. 在本例中我們將使用 cft 監視 NTP 安裝的軟件包并生成實現相同功能的配置清單。 ``` # cft begin ntp # apt-get install ntp Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: ntp-doc The following NEW packages will be installed: ntp 0 upgraded, 1 newly installed, 0 to remove and 385 not upgraded. Need to get 517kB of archives. After this operation, 1,323kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main ntp 1:4.2.4p8+dfsg-1ubuntu2 [517kB] Fetched 517kB in 5s (101kB/s) Selecting previously deselected package ntp. (Reading database ... 135278 files and directories currently installed.) Unpacking ntp (from .../ntp_1%3a4.2.4p8+dfsg-1ubuntu2_i386.deb) ... Processing triggers for man-db ... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Setting up ntp (1:4.2.4p8+dfsg-1ubuntu2) ... * Starting NTP server ntpd # vi /etc/ntp.conf # service ntp restart * Stopping NTP server ntpd [ OK ] * Starting NTP server ntpd # cft finish ntp # cft manifest ntp class ntp { package { 'ntp': ensure =&gt; '1:4.2.4p8+dfsg-1ubuntu2' } service { 'ntp': enable =&gt; 'true', ensure =&gt; 'running' } file { '/etc/ntp.conf': group =&gt; 'root', owner =&gt; 'root', mode =&gt; '0644', source =&gt; '/tmp/cft/ntp/after/etc/ntp.conf' } } ``` #### 工作原理 首先告訴 cft 開始記錄系統的改變,并將其會話存儲在 ntp 中?—?cft begin ntp 。 然后,當你安裝 ntp 軟件包時,cft 會記錄這個事實。 軟件包安裝了服務的啟動腳本,配置了在機器啟動時啟動服務,cft 同時也記錄了這些。 最后,cft 注意到你編輯了 /etc/ntp.conf 文件,并保存了一份修改后的拷貝以備后用。 當你運行 cft finish ntp 命令,這會停止記錄變化。 現在你可以使用 cft manifest ntp 命令生成與你的控制臺會話等效的 Puppet 配置清單。 正如你看到的,生成的配置清單包括了 package 聲明(由命令 apt-get install ntp 觸發): ``` package { 'ntp': ensure => '1:4.2.4p8+dfsg-1ubuntu2' } ``` 同時包括了再現包安裝腳本作用的 service 聲明,啟動服務并設置開機啟動: ``` service { 'ntp': enable => 'true', ensure => 'running' } ``` 這個聲明是由于你手動配置了如下命令所生成的: ``` # service ntp start # update-rc.d ntp defaults ``` 配置清單的最后一部分封裝了 ntp.conf 文件的改變。 cft 只知道你對這個文件做了改變,但不知道你具體做了哪些改變, 所以 cft 將修改后的整個文件做為一個拷貝,并使其可以通過 Puppet 分發這個文件: ``` file { '/etc/ntp.conf': group => 'root', owner => 'root', mode => '0644', source => '/tmp/cft/ntp/after/etc/ntp.conf' } ``` 當你將此配置清單放入 Puppet,還需要從原始路徑(/tmp/cft/ntp/after/etc/ntp.conf) 復制 ntp.conf 文件到你的模塊樹的適當位置,并根據這個位置修改 source 參數的值。 #### 更多用法 cft 是快速生成 Puppet 配置清單原型的一個強大工具。 你可以找一臺構建配置清單的主機,盡可能使用 cft 記錄你的安裝和配置過程, 并使用它對整個會話進行編碼生成 Puppet 的配置清單。 雖然這還需要一些額外的編輯工作,但是比你從頭開始編寫配置清單要快得多。
                  <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>

                              哎呀哎呀视频在线观看