<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國際加速解決方案。 廣告
                ### 使用提交鉤子 如果我們在提交配置清單之前能夠發現其中的語法錯誤將會是個好消息。 檢查 Puppet 配置清單的語法可以使用 puppet parser validate 命令: ``` # puppet parser validate /etc/puppet/manifests/site.pp err: Could not parse for environment production: Syntax error at end of file at /etc/puppet/manifests/site.pp:3 ``` 這種語法檢查是特別有用的,因為配置清單中的任何一個錯誤將使運行 Puppet 的節點停止工作, 甚至不會應用配置清單中錯誤代碼的節點也會停止工作。 因此,導入(check in)一個有錯誤的配置清單,將導致 Puppet 應用這些更新到生產環境使其停止運行, 直到問題被發現,這可能會產生嚴重的后果。 避免錯誤發生的最好方法是在你的版本控制倉庫中使用 **pre-commit hook** 自動執行語法檢查。 #### 操作步驟 如果你使用的是 Git 版本控制系統,可以添加一個腳本 .git/hooks/pre-commit 用于為你提交的所有配置清單文件執行語法檢查。 下面的腳本示例來自 Puppet Labs wiki: [http://projects.puppetlabs.com/projects/puppet/wiki/](http://projects.puppetlabs.com/projects/puppet/wiki/) 。 ``` #!/bin/sh syntax_errors=0 error_msg=$(mktemp /tmp/error_msg.XXXXXX) if git rev-parse --quiet --verify HEAD > /dev/null then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # Get list of new/modified manifest and template files to check (in git index) for indexfile in `git diff-index --diff-filter=AM --name-only --cached \ $against | egrep '\.(pp|erb)'` do # Don't check empty files if [ `git cat-file -s :0:$indexfile` -gt 0 ] then case $indexfile in *.pp ) # Check puppet manifest syntax #git cat-file blob :0:$indexfile | puppet \ # --color=false --parseonly --ignoreimport > $error_msg # Updated for 2.7.x puppet parser validate $indexfile > $error_msg ;; *.erb ) # Check ERB template syntax # -P : ignore lines which start with "%" git cat-file blob :0:$indexfile | erb -P -x -T - |\ ruby -c 2> $error_msg > /dev/null ;; esac if [ "$?" -ne 0 ] then echo -n "$indexfile: " cat $error_msg syntax_errors=`expr $syntax_errors + 1` fi fi done rm -f $error_msg if [ "$syntax_errors" -ne 0 ] then echo "Error: $syntax_errors syntax errors found, aborting commit." exit 1 fi ``` #### 工作原理 這個提交鉤子腳本 .git/hooks/pre-commit 會防止你提交任何有語法錯誤的配置清單文件: ``` # git commit -m "spot the deliberate mistake" manifests/site.pp err: Could not parse for environment production: Syntax error at end of file; expected '}' at /etc/puppet/manifests/site.pp:3 manifests/site.pp: Error: 1 syntax errors found, aborting commit. ``` #### 更多用法 你可以在 Puppet Labs wiki: [http://projects.puppetlabs.com/projects/1/wiki/Puppet_Version_Control](http://projects.puppetlabs.com/projects/1/wiki/Puppet_Version_Control) 上找到有關這個腳本的更多詳細信息。 你也可以使用類似的 update 鉤子防止有語法錯誤的配置清單推送到 Puppetmaster: 查看同樣的 wiki 頁面也可以獲得使用 update 鉤子的詳細信息。 #### 參見本書 * 本章的 [使用版本控制](#ch01sec01) 一節
                  <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>

                              哎呀哎呀视频在线观看