Kitchen and Kitchen-docker - docker

I am trying to use kitchen-docker driver on a GNU/Linux machine. I have installed the kitchen-docker gem using chef gem install command.
This is an extract of my .kitchen.yml file:
---
driver:
name: docker
provisioner:
name: chef_zero
verifier:
name: inspec
platforms:
- name: centos-7.2
driver_config:
image: centos:7.2
platform: centos
suites:
- name: zaz
run_list:
- recipe[foo::bar]
...
...
I have Docker installed on it's latest version using Docker repositories for Centos. The service is running and Docker is in my path. However when I try to run a simple kitchen list using that .kitchen.yml I get this error:
[FakeyMcFakeFace#workstation foo]$ kitchen list
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: You must first install the Docker CLI tool http://www.docker.io/gettingstarted/
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
Why is docker not being recognized by Kitchen? If I run the diagnose -all option I just see it is failing on the dependencies check:
backtrace:
- "/home/FakeyMcFakeFace/.chefdk/gem/ruby/2.3.0/gems/kitchen-docker-2.6.0/lib/kitchen/driver/docker.rb:93:in
`rescue in verify_dependencies'"
What am I missing here?

To copy down from the comments, kitchen-docker requires passwordless sudo (if using sudo) right now, the error message is misleading

Related

test-kitchen command not found

I'm trying to test chef recipe locally using test kitchen docker, I installed chef workstation, chef, and test kitchen but kitchen still complaints "Kitchen not found"
-bash: kitchen: command not found
Here's what I installed on my redhat7 linux machine ;
Chef Workstation version: 22.1.778
Chef Habitat version: 1.6.420
Test Kitchen version: 3.2.2
Cookstyle version: 7.31.1
Chef Infra Client version: 17.9.26
Chef InSpec version: 4.52.9
Chef CLI version: 5.5.6
kitchen.yml
---
driver:
name: docker
provisioner:
name: dummy
verifier:
name: inspec
tranport:
name: docker
platforms:
- name: centos-7
docker_config:
image: centos:7
platform: centos
suites:
- name: default
verifier:
inspec_tests:
- test/integration/default
Error:
kitchen list
-bash: kitchen: command not found
Execute kitchen --version and see the output. It should output you the version of the Test Kitchen if correctly installed
Eg:
kitchen --version
Test Kitchen version 3.x.x

Molecule : Testing roles : Failed to get Dbus Connection Operation not permitted

I facing an issue on my Molecule Test. I have begin to study this tool 2 days ago for information.
on a Ubuntu VM running with Vagrant,I have create a role and initialze Molecule's folder and create a testinfra test file ( with the docker provider ).
The error is when my task's role are running, at the step of checking service running, it failed.
fatal: [instance]: FAILED! => {"changed": false, "msg": "Could not find the requested service httpd: "}
I was design to simply install 2 packages including httpd on a Centos Image.
When im loggin directly to the Molecule VM ( so through docker ), when i simply type systemctl the error message is
Failed to get D-Bus connection: Operation not permitted
As adviced Geerlingguy, i have specify volume mapped on cgroup folder
platforms:
- name: instance
#image: docker.io/pycontribs/centos:7
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
The error is not related to Testinfra but only the docker built image.
Could someone help me to understand why this error message ?
Is that because im on a VirtualBox ran by Vagrant ?
Thanks all for reading :-)
I have added that on my mocule.yml file config according molecule documentation ( https://molecule.readthedocs.io/en/latest/examples.html#docker ) :
platforms:
- name: instance
#image: docker.io/pycontribs/centos:7
image: geerlingguy/docker-centos7-ansible:latest
capabilities:
- SYS_ADMIN
command: /sbin/init
systemctl working fine now

Hyperledger fabric first network error executing ./byfn.sh: line 175: docker-compose: command not found

I have the following prerequisites node v10.16.3, go v1.8.1 linux/amd64, Docker Podman v1.0.5, Docker-compose 1.24.1. All are included in path. When I execute "sudo ./byfn.sh up" I'm able to generate the crypto certificates without issues- However error "docker-compose: command not found
" comes in Line 175 when docker-compose is executed in NetworkUp. Tried uninstalling Docker and reinstalling and couldnt find anything relevant in stackflow as well - can someone pl bail me out ?
error
./byfn.sh: line 175: docker-compose: command not found
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Additional info
host:
BuildahVersion: 1.6-dev
Conmon:
package: podman-1.0.5-1.gitf604175.module+el8.0.0+4017+bbba319f.x86_64
path: /usr/libexec/podman/conmon
version: 'conmon version 1.14.0-dev, commit: 6ee5ad0285ca12e6c8d0b663d7a8db5323812ef6-dirty'
Distribution:
distribution: '"rhel"'
version: "8.0"
kernel: 4.18.0-80.4.2.el8_0.x86_64
os: linux

How to get image from a docker repo for test kitchen

I need to test my application with Docker Image httpd and when i add it to the current .kitchen.yaml file it fails with the error:
root#ip-172-31-1-22:~/test1# kitchen test
-----> Starting Kitchen (v1.23.2)
-----> Cleaning up any prior instances of <default-httpd>
-----> Destroying <default-httpd>...
Finished destroying <default-httpd> (0m0.00s).
-----> Testing <default-httpd>
-----> Creating <default-httpd>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>> Create failed on instance <default-httpd>. Please see .kitchen/logs/default-httpd.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
root#ip-172-31-1-22:~/test1#
My Kitchen.yaml file
driver:
name: docker
use_sudo: false
#image: httpd
provisioner:
hosts: aws
name: ansible_playbook
#roles_path: roles
require_ansible_repo: true
ansible_verbose: true
ansible_version: latest
require_chef_for_busser: false
playbook: default.yml
verifier:
name: inspec
platforms:
#- name: ubuntu
- name: httpd
driver_config:
run_command: /bin/systemd
privileged: true
provision_command:
- systemctl enable sshd.service
suites:
- name: default
verifier:
inspec_tests:
- path: /root/kitchen/test/integration/default/test.rb
Use Case:
1> Deoloy a Httpd base container
2> Use Ansible Play book to move a index.html file
3> Use ansible tos tart and stop the services
4> Run an inspec to check if the tests are successful
What is the right procedure to deploy an httpd using kitchen.yaml and to test the use case.
1> Is this the correct Approch??
2> Should i simply write a Ansible playbook to install httpd and then move my html files.
3> If the Answer to Q2 is yes, then doesn't it defeat the purpose of having an httpd Container already
since you are using ansible, then use docker modules to deploy httpd

importerror:no module name docker.client

I've gotten a question when usde ansible to configurate a docker container.
Here is my ansible playbook:
---
-name: localhost
hosts: localhost
vars:
- ansible_python_interpreter: python
tasks:
- name: busybox test
docker:
image: busybox
name: test
but when I run the file with :
ansible-playbook ad.yml
I got following error:
from docker.client import APIError as DockerAPIError
ImportError: No module named docker.client
no docker.client? I have installed docker-py, but still got this question , how can I fix this ?? h....e....l....p....
I think the problem is caused by the way how I install the ansible. After I reinstall the ansible through python-pip, this problem has been solved successfully.
zypper install python-pip
pip install ansible
use this to solve the problem on suse.

Resources