2

I am using Ubuntu-16.04 image with docker to test my cookbook in local. While doing kitchen converge, I am getting the following error. I figured out systemctl is not working properly. Can someone please help me to fix this problem OR any other way to achieve the same thing?

 [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

This is my .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
Jai Prak
  • 2,855
  • 4
  • 29
  • 37
  • systemctl only works if you're running systemd, and using systemd in a docker container is not a particularly good idea -- the Docker Way is to directly invoke the single service that container is supposed to run, rather than having an init system in each container. – Charles Duffy Nov 30 '17 at 16:05

3 Answers3

3

Normally docker doesn't support systemd services in container, but you can use a special ubuntu systemd image with some additional host configuration. Note that this image is not recommended to be run in production.

Firstly, you need to setup your host to be able to run this image:

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

Then, you'll be able to run containers with systemd (adding necessary mounts and flags):

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
Bohdan Blyzniuk
  • 575
  • 6
  • 14
  • Test Kitchen is an integration test suite, not a production system :) – coderanger Dec 01 '17 at 05:11
  • I tried with ``ubuntu-systemd`` image but its not working. Giving the same error as I shown above. This image is for **systemd** but in my case it's **systemctl**. Is it the problem? – Jai Prak Dec 01 '17 at 08:08
  • **systemd** is an init system and system manager while **systemctl** is a command line tool to manage systemd services. I've added some editions which can help you to achieve your goal. – Bohdan Blyzniuk Dec 01 '17 at 09:13
  • Actually, systemctl uses d-bus to talk to the systemd daemon which in turn manages the services. The systemctl tool itself is pretty dumb. – Guido U. Draheim Dec 03 '17 at 22:38
2

kitchen-docker is not really set up to work with systemd. I would recommend using kitchen-dokken instead, which is fairly easy to set up this way.

coderanger
  • 52,400
  • 4
  • 52
  • 75
0

YES, there is another way to achieve the same thing! You can try to replace the standard systemd systemctl with the https://github.com/gdraheim/docker-systemctl-replacement ... while it works in surprising number of environments, it has not been tested so far with kitchen. Please provide some feedback if you're giving it a try.

Guido U. Draheim
  • 3,038
  • 1
  • 20
  • 19