<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之旅 廣告
                ### 配置 APT 軟件倉庫 運行自己的軟件倉庫有幾個優點。你可以在自己的倉庫中發布自己的軟件包。 你可以在自己的軟件倉庫中放置上游軟件包或第三方軟件包,從而控制你使用的軟件版本。 你可以將自己的軟件倉庫放置在其他服務器附近,從而避免網速緩慢或鏡像站點無法訪問的問題。 即使你不需要創建自己的軟件包,也可能想要下載特定版本軟件包所需的關鍵依賴包, 并將這些依賴包存儲在自己的倉庫中,從而防止因上游發生變故而產生的任何意外 (例如,你的發行版本已到達生命周期的終結或者上游倉庫已經被關閉)。 這也使得通過 Puppet 自動更新軟件包便得更容易。你可能偶爾需要更新一個軟件包 (例如,當有一個安全更新可用時),只要在 package 資源中指定 ensure =&gt; latest 就可以方便地實現包更新。但是如果你不能控制倉庫,就可能遭遇意想不到的升級風險, 使你的系統受到某種破壞。 使用自己的軟件倉庫是件兩全其美的事情:你可以放心地使用 Puppet 從自己的軟件倉庫自動更新軟件包,當有新版本的軟件可用時,只需要將其納入自己的軟件倉庫; 你可以首先測試上游的軟件版本,確保其可用的情況下再納入用于生產環境的軟件倉庫。 #### 準備工作 你需要第 9 章 [管理 Apache 服務](#ch07sec01) 一節中講述的 apache 模塊, 如果還沒有此模塊請先創建它。 在本例中,我將我的倉庫命名為 packages.bitfieldconsulting.com。 你可能想要使用一個不同的倉庫名,這需要替換本例中的所有的倉庫名 packages.bitfieldconsulting.com 為你想要的倉庫名。 #### 操作步驟 1. 創建一個新的 repo 模塊: ``` # mkdir /etc/puppet/modules/repo # mkdir /etc/puppet/modules/repo/manifests # mkdir /etc/puppet/modules/repo/files ``` 2. 使用如下內容創建 /etc/puppet/modules/repo/manifests/bitfield-server.pp 文件: ``` class repo::bitfield-server { include apache package { "reprepro": ensure =&gt; installed } file { [ "/var/apt", "/var/apt/conf" ]: ensure =&gt; directory, } file { "/var/apt/conf/distributions": source =&gt; "puppet:///modules/repo/distributions", require =&gt; File["/var/apt/conf"], } file { "/etc/apache2/sites-available/apt-repo": source =&gt; "puppet:///modules/repo/apt-repo.conf", require =&gt; Package["apache2-mpm-worker"], } file { "/etc/apache2/sites-enabled/apt-repo": ensure =&gt; symlink, target =&gt; "/etc/apache2/sites-available/apt-repo", require =&gt; File["/etc/apache2/sites-available/apt-repo"], notify =&gt; Service["apache2"], } } ``` 3. 使用如下內容創建 /etc/puppet/modules/repo/files/distributions 文件: ``` Origin: Bitfield Consulting Label: bitfield Suite: stable Codename: lucid Architectures: amd64 i386 Components: main non-free contrib Description: Custom and cached packages for Bitfield Consulting ``` 4. 使用如下內容創建 /etc/puppet/modules/repo/files/apt-repo.conf 文件: ``` &lt;VirtualHost *:80&gt; DocumentRoot /var/apt ServerName packages.bitfieldconsulting.com ErrorLog /var/log/apache2/packages.bitfieldconsulting.com.error.log LogLevel warn CustomLog /var/log/apache2/packages.bitfieldconsulting.com.access.log combined ServerSignature On # Allow directory listings so that people can browse the # repository from their browser too &lt;Directory "/var/apt"&gt; Options Indexes FollowSymLinks MultiViews DirectoryIndex index.html AllowOverride Options Order allow,deny allow from all &lt;/Directory&gt; # Hide the conf/ directory for all repositories &lt;Directory "/var/apt/conf"&gt; Order allow,deny Deny from all Satisfy all &lt;/Directory&gt; # Hide the db/ directory for all repositories &lt;Directory "/var/apt/db"&gt; Order allow,deny Deny from all Satisfy all &lt;/Directory&gt; &lt;/VirtualHost&gt; ``` 5. 在一個節點的配置清單中添加如下代碼: ``` include repo::bitfield-server ``` 6. 運行 Puppet: ``` # puppet agent --test info: Retrieving plugin info: Caching catalog for cookbook.bitfieldconsulting.com info: Applying configuration version '1304775601' notice: /Stage[main]/Repo::Bitfield-server/File[/var/apt]/ensure: created notice: /Stage[main]/Repo::Bitfield-server/File[/var/apt/conf]/ ensure: created notice: /Stage[main]/Repo::Bitfield-server/File[/var/apt/conf/ distributions]/ensure: defined content as '{md5}65dc791b876f53318a 35fcc42c770283' notice: /Stage[main]/Repo::Bitfield-server/Package[reprepro]/ ensure: created notice: /Stage[main]/Repo::Bitfield-server/File[/etc/apache2/ sites-enabled/apt-repo]/ensure: created notice: /Stage[main]/Repo::Bitfield-server/File[/etc/apache2/ sites-available/apt-repo]/ensure: defined content as '{md5}2da4686 957e5acf49220047fe6f6e6e1' info: /Stage[main]/Repo::Bitfield-server/File[/etc/apache2/sitesenabled/ apt-repo]: Scheduling refresh of Service[apache2] notice: /Stage[main]/Apache/Service[apache2]: Triggered 'refresh' from 1 events notice: Finished catalog run in 16.32 seconds ``` #### 工作原理 其實,你無需創建一個 APT 倉庫。因為可以通過 HTTP 下載軟件包,所以你只需要一個 Apache 虛擬主機。 你可以將實際的軟件包隨意放置在任何地方,只要有一個 conf/distributions 文件并在其中給出 APT 倉庫的相關信息。 1. bitfield-server 類的第一部分確保 Apache 已經被設置: ``` class repo::bitfield-server { include apache ``` 2. reprepro 是用于管理倉庫本身的非常有用的工具(例如,添加一個新的軟件包): ``` package { "reprepro": ensure =&gt; installed } ``` 3. 我們創建一個倉庫的根目錄 /var/apt,以及該目錄下的 conf/distributions 文件: ``` file { [ "/var/apt", "/var/apt/conf" ]: ensure =&gt; directory, } file { "/var/apt/conf/distributions": source =&gt; "puppet:///modules/repo/distributions", require =&gt; File["/var/apt/conf"], } ``` 4. 這個類的其余部分部署了一個 Apache 虛擬主機的配置文件,用于響應 packages.bitfieldconsulting.com 的請求: ``` file { "/etc/apache2/sites-available/apt-repo": source =&gt; "puppet:///modules/repo/apt-repo.conf", require =&gt; Package["apache2-mpm-worker"], } file { "/etc/apache2/sites-enabled/apt-repo": ensure =&gt; symlink, target =&gt; "/etc/apache2/sites-available/apt-repo", require =&gt; File["/etc/apache2/sites-available/apt-repo"], notify =&gt; Service["apache2"], } ``` #### 更多用法 當然,一個可用的倉庫里不能沒有軟件包。下面將介紹如何添加軟件包, 以及如何配置主機并從你的倉庫下載軟件包。 ##### 向倉庫添加軟件包 要添加一個軟件包到你的倉庫,首先下載它然后使用 reprepro 將其添加到倉庫: ``` # cd /tmp # wget http://archive.ubuntu.com/ubuntu/pool/main/n/ntp/\ ntp_4.2.4p8+dfsg-1ubuntu2.1_i386.deb # cd /var/apt # reprepro includedeb lucid /tmp/ntp_4.2.4p8+dfsg-1ubuntu2.1_i386.deb Exporting indices... ``` ##### 配置節點使用倉庫 1. 使用如下內容創建 /etc/puppet/modules/repo/manifests/bitfield.pp 文件 (請根據你自己的倉庫服務器的 IP 地址替換如下的 IP 地址): ``` class repo::bitfield { host { "packages.bitfieldconsulting.com": ip =&gt; "10.0.2.15", ensure =&gt; present, target =&gt; "/etc/hosts", } file { "/etc/apt/sources.list.d/bitfield.list": content =&gt; "deb http://packages.bitfieldconsulting.com/lucid main\n", require =&gt; Host["packages.bitfieldconsulting.com"], notify =&gt; Exec["bitfield-update"], } exec { "bitfield-update": command =&gt; "/usr/bin/apt-get update", require =&gt; File["/etc/apt/sources.list.d/bitfield.list"], refreshonly =&gt; true, } } ``` 如果你有 DNS 服務器或者你可以控制你的 DNS 區域,可以省略 host 資源的設置。 2. 應用這個類到一個節點: ``` node cookbook { include repo::bitfield } ``` 3. 測試你倉庫中的 ntp 軟件包是否可用: ``` # apt-cache madison ntp ntp | 1:4.2.4p8+dfsg-1ubuntu2.1 | http://us.archive.ubuntu. com/ubuntu/ lucid-updates/main Packages ntp | 1:4.2.4p8+dfsg-1ubuntu2.1 | http://packages. bitfieldconsulting.com/ lucid/main Packages ntp | 1:4.2.4p8+dfsg-1ubuntu2 | http://us.archive.ubuntu. com/ubuntu/ lucid/main Packages ntp | 1:4.2.4p8+dfsg-1ubuntu2 | http://us.archive.ubuntu. com/ubuntu/ lucid/main Sources ntp | 1:4.2.4p8+dfsg-1ubuntu2.1 | http://us.archive.ubuntu. com/ubuntu/ lucid-updates/main Sources ``` ##### 對軟件包簽名 對于生產環境,你應該對軟件倉庫設置 GPG 密鑰并且對軟件包進行簽名,關于如何設置密鑰和簽名的信息, 請參考 Sander Marechal 撰寫的關于 “設置和管理 APT 倉庫” 的文章: [http://www.jejik.com/articles/2006/09/setting_up_and_managing_an_apt_repository_with_reprepro/](http://www.jejik.com/articles/2006/09/setting_up_and_managing_an_apt_repository_with_reprepro/) 。
                  <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>

                              哎呀哎呀视频在线观看