2

我正在使用带有docker的Ubuntu-16.04映像在本地测试我的食谱。在执行时,我收到以下错误。我发现工作不正常。有人可以帮我解决这个问题任何其他方式来实现同样的事情吗?kitchen convergesystemctl

 [2017-11-30T15:22:30+00:00] INFO: Running queued delayed notifications before re-raising exception

 Running handlers:
   [2017-11-30T15:22:30+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2017-11-30T15:22:30+00:00] ERROR: Exception handlers complete
   Chef Client failed. 9 resources updated in 06 seconds
   [2017-11-30T15:22:30+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2017-11-30T15:22:30+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2017-11-30T15:22:30+00:00] ERROR: envoy_auth_apps_setup[default-service] (envoy_auth_apps::_default line 1) had an error: Chef::Exceptions::MultipleFailures: Multiple failures occurred:
   * Mixlib::ShellOut::ShellCommandFailed occurred in chef run: execute[systemctl daemon-reload] (/tmp/kitchen/cache/cookbooks/envoy_auth_apps/resources/setup.rb line 133) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
   ---- Begin output of systemctl daemon-reload ----
   STDOUT:
   STDERR: Failed to connect to bus: No such file or directory
   ---- End output of systemctl daemon-reload ----
   Ran systemctl daemon-reload returned 1
   * Mixlib::ShellOut::ShellCommandFailed occurred in delayed notification: service[envoy] (/tmp/kitchen/cache/cookbooks/envoy_auth_apps/resources/setup.rb line 194) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
   ---- Begin output of /bin/systemctl --system restart envoy ----
   STDOUT:
   STDERR: Failed to connect to bus: No such file or directory
   ---- End output of /bin/systemctl --system restart envoy ----
   Ran /bin/systemctl --system restart envoy returned 1

   [2017-11-30T15:22:30+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>.  Please see .kitchen/logs/default-ubuntu.log for more details
 >>>>>> ----------------------
 >>>>>> Please see .kitchen/logs/kitchen.log for more details
 >>>>>> Also try running `kitchen diagnose --all` for configuration

这是我的.kitchen.yml

---

driver:
  name: docker
  binary: /usr/local/bin/docker
  use_sudo: false
  network:
    - ["public_network", "bridge: 'en0: Wi-Fi (AirPort)'"]

provisioner:
  name: chef_zero
  require_chef_omnibus: "12.21.14"
  environments_path: test/integration/environments
  nodes_path: test/integration/nodes
  data_bags_path: test/integration/data_bags
  client_rb:
    environment: development

verifier:
  name: inspec

platforms:
  - name: ubuntu
    driver_config:
      image: ubuntu:xenial
      platform: ubuntu
#     provision_command:
#       - apt-get -y install dbus

suites:
  - name: default
    run_list:
#   - recipe[base_app]
        - recipe[envoy_auth_apps::_default]
    verifier:
      inspec_tests:
        - test/integration/default
attributes:
  nameserver:
    domain_name: 'kitchen.xyz.io'
  envoy_auth_apps:
    consul_client_enabled: false
4

3 回答 3

3

通常 docker 不支持systemd容器中的服务,但您可以使用特殊的ubuntu systemd映像和一些额外的主机配置。请注意,不建议在生产中运行此映像。

首先,您需要设置您的主机以便能够运行此映像:

docker run --rm --privileged -v /:/host solita/ubuntu-systemd setup

然后,您将能够使用systemd(添加必要的挂载和标志)运行容器:

docker run -d --name systemd --security-opt seccomp=unconfined \
 --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
 -t solita/ubuntu-systemd
于 2017-11-30T16:09:24.937 回答
2

kitchen-docker并没有真正设置为与 systemd 一起使用。我建议kitchen-dokken改用,这样设置起来相当容易。

于 2017-11-30T16:23:35.260 回答
0

是的,还有另一种方法可以实现相同的目标!您可以尝试用https://github.com/gdraheim/docker-systemctl-replacement替换标准的 systemd systemctl ...虽然它可以在数量惊人的环境中工作,但到目前为止还没有在厨房中进行过测试。如果您尝试一下,请提供一些反馈。

于 2017-12-03T22:35:52.367 回答