【问题标题】:Error executing action `install` on resource 'apt_package[ntp]'在资源“apt_package [ntp]”上执行操作“安装”时出错
【发布时间】:2018-02-26 16:11:29
【问题描述】:

我正在尝试使用 Chef 在 vagrant 实例上安装包 'ntp'。

这是我的厨师食谱:

package 'ntp' do
        action :install
end

我也试过用这个作为我的食谱:

package 'ntp'

这些脚本有什么问题?还有什么是这样的最佳实践?

对不起,这真的很简单,我没有得到。我已经尝试用谷歌搜索它很多以找出如何但我找不到任何东西。我也尝试过查看厨师文档,但无法弄清楚。

这是我不断收到的错误输出:

-----> Starting Kitchen (v1.19.2)
-----> Converging <default-ubuntu-1604>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 6.3.1...
       Removing non-cookbook files before transfer
       Preparing validation.pem
       Preparing client.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-ubuntu-1604>
       Starting Chef Client, version 13.7.16
       resolving cookbooks for run list: ["git_cookbook::default"]
       Synchronizing Cookbooks:
         - git_cookbook (0.1.0)
       Installing Cookbook Gems:
       Compiling Cookbooks...
       Converging 1 resources
       Recipe: git_cookbook::default
         * apt_package[ntp] action install

           ================================================================================
           Error executing action `install` on resource 'apt_package[ntp]'
           ================================================================================

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '100'
           ---- Begin output of ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] ----
           STDOUT: Reading package lists...
           Building dependency tree...
           Reading state information...
           The following additional packages will be installed:
             libopts25
           Suggested packages:
             ntp-doc
           The following NEW packages will be installed:
             libopts25 ntp
           0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
           Need to get 518 kB/576 kB of archives.
           After this operation, 1792 kB of additional disk space will be used.
           Err:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ntp amd64 1:4.2.8p4+dfsg-3ubuntu5.7
             404  Not Found [IP: 91.189.88.162 80]
           STDERR: E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/ntp/ntp_4.2.8p4+dfsg-3ubuntu5.7_amd64.deb  404  Not Found [IP: 91.189.88.162 80]

           E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
           ---- End output of ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] ----
           Ran ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] returned 100

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/git_cookbook/recipes/default.rb

             1: package 'ntp' do
             2:         action :install
             3: end

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/git_cookbook/recipes/default.rb:1:in `from_file'

           apt_package("ntp") do
             package_name "ntp"
             action [:install]
             default_guard_interpreter :default
             declared_type :package
             cookbook_name "git_cookbook"
             recipe_name "default"
           end

           System Info:
           ------------
           chef_version=13.7.16
           platform=ubuntu
           platform_version=16.04
           ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
           program_name=chef-client worker: ppid=5272;start=06:22:55;
           executable=/opt/chef/bin/chef-client


       Running handlers:
       [2018-02-26T06:23:02+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2018-02-26T06:23:02+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 07 seconds
       [2018-02-26T06:23:02+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2018-02-26T06:23:02+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2018-02-26T06:23:02+00:00] ERROR: apt_package[ntp] (git_cookbook::default line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'
       ---- Begin output of ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] ----
       STDOUT: Reading package lists...
       Building dependency tree...
       Reading state information...
       The following additional packages will be installed:
         libopts25
       Suggested packages:
         ntp-doc
       The following NEW packages will be installed:
         libopts25 ntp
       0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
       Need to get 518 kB/576 kB of archives.
       After this operation, 1792 kB of additional disk space will be used.
       Err:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ntp amd64 1:4.2.8p4+dfsg-3ubuntu5.7
         404  Not Found [IP: 91.189.88.162 80]
       STDERR: E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/n/ntp/ntp_4.2.8p4+dfsg-3ubuntu5.7_amd64.deb  404  Not Found [IP: 91.189.88.162 80]

       E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
       ---- End output of ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] ----
       Ran ["apt-get", "-q", "-y", "install", "ntp=1:4.2.8p4+dfsg-3ubuntu5.7"] returned 100
       [2018-02-26T06:23:03+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-ubuntu-1604>.  Please see .kitchen/logs/default-ubuntu-1604.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

【问题讨论】:

    标签: vagrant chef-infra virtualbox ntp


    【解决方案1】:

    您的实例有一段时间没有更新包索引/或者只是有过时的包索引。根据我的经验,将include_recipe "apt" 放在你的厨师运行的第一个食谱的顶部是一个很好的做法,它将在任何其他资源之前运行apt-get update(你可以自己做,但它有一些警告。使用提供的配方更简单)。

    Apt cookbook在超市有售。

    【讨论】:

    • 我是否需要在我的 ntp cookboot 中使用 apt 食谱,还是应该添加 include_recipe "ntp" 工作?
    • 如果你想使用 apt cookbook,你必须将它添加到你的食谱的 metadata.rb 中,并且你必须将它们一起分发(例如使用 Berkshelf)。抱歉,我没有得到第二部分,包括ntp,你想在哪里添加include_recipe "ntp"
    • 对不起,我的意思是包含“apt”部分。我把它添加到我的食谱中,但我什么也没做,我只能假设这是因为这是我所做的唯一改变,而我实际上并没有添加食谱
    • 默认 apt recipe 应该为您运行 apt-get update。
    猜你喜欢
    • 2019-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多