Manage a node with chef server tutorial bootstrap step error


#1

Hello all! I have recently begun learning how to use Chef, and I have to say that so far I am enjoying what it can do. However, I ran into an error with one of the tutorials on Learn Chef Rally and haven’t been able to find any potential solution while googling the problem or searching on here. The tutorial in question is the second module under the “Infrastructure Automation” track, and I am trying to complete it by using a RHEL/CentOS node, but I ran into an error trying to get one of the cookbooks to work.
The Problem
I created a CentOS-based docker container to use as the SSH node for the tutorial example. I can SSH into it, and so far as I can tell all the appropriate ports are open. However, when I run the cookbook from the example without any modifications, I get the following output with this command:

knife bootstrap IP_ADDRESS --ssh-user USER --ssh-password 'PASSWORD' --node-name node1-centos --run-list 'recipe[learn_chef_httpd]'

IP_ADDRESS Recipe: learn_chef_httpd::default
IP_ADDRESS * yum_package[httpd] action install
IP_ADDRESS - install version 0:2.4.6-80.el7.centos.x86_64 of package httpd
IP_ADDRESS * service[httpd] action enable
IP_ADDRESS * service[httpd]: Service is not known to chkconfig.
IP_ADDRESS ================================================================================
IP_ADDRESS Error executing action enable on resource ‘service[httpd]’
IP_ADDRESS ================================================================================
IP_ADDRESS
IP_ADDRESS Chef::Exceptions::Service
IP_ADDRESS -------------------------
IP_ADDRESS service[httpd]: Service is not known to chkconfig.
IP_ADDRESS
IP_ADDRESS Resource Declaration:
IP_ADDRESS ---------------------
IP_ADDRESS # In /var/chef/cache/cookbooks/learn_chef_httpd/recipes/default.rb
IP_ADDRESS
IP_ADDRESS 8: service ‘httpd’ do
IP_ADDRESS 9: action [:enable, :start]
IP_ADDRESS 10: end
IP_ADDRESS 11:
IP_ADDRESS
IP_ADDRESS Compiled Resource:
IP_ADDRESS ------------------
IP_ADDRESS # Declared in /var/chef/cache/cookbooks/learn_chef_httpd/recipes/default.rb:8:in `from_file’
IP_ADDRESS
IP_ADDRESS service(“httpd”) do
IP_ADDRESS action [:enable, :start]
IP_ADDRESS default_guard_interpreter :default
IP_ADDRESS service_name “httpd”
IP_ADDRESS enabled nil
IP_ADDRESS running nil
IP_ADDRESS masked nil
IP_ADDRESS pattern “httpd”
IP_ADDRESS declared_type :service
IP_ADDRESS cookbook_name “learn_chef_httpd”
IP_ADDRESS recipe_name “default”
IP_ADDRESS end
IP_ADDRESS
IP_ADDRESS System Info:
IP_ADDRESS ------------
IP_ADDRESS chef_version=14.2.0
IP_ADDRESS platform=centos
IP_ADDRESS platform_version=7.5.1804
IP_ADDRESS ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
IP_ADDRESS program_name=/bin/chef-client
IP_ADDRESS executable=/opt/chef/bin/chef-client
IP_ADDRESS
IP_ADDRESS
IP_ADDRESS Running handlers:
IP_ADDRESS [2018-06-29T19:58:11+00:00] ERROR: Running exception handlers
IP_ADDRESS Running handlers complete
IP_ADDRESS [2018-06-29T19:58:11+00:00] ERROR: Exception handlers complete
IP_ADDRESS Chef Client failed. 1 resources updated in 50 seconds
IP_ADDRESS [2018-06-29T19:58:11+00:00] WARN: Using deprecated positional arguments for sign(), please update to keyword arguments (from /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/chef-14.2.0/lib/chef/http/authenticator.rb:114)
IP_ADDRESS [2018-06-29T19:58:12+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
IP_ADDRESS [2018-06-29T19:58:12+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
IP_ADDRESS [2018-06-29T19:58:12+00:00] FATAL: Chef::Exceptions::Service: service[httpd] (learn_chef_httpd::default line 8) had an error: Chef::Exceptions::Service: service[httpd]: Service is not known to chkconfig.

My system details
In order to help with reproducing the error, my host system is Ubuntu 18, I made the container using docker-compose using the following Dockerfile:

FROM centos:7
RUN yum update && yum install -y net-tools openssh-server
RUN mkdir /var/run/sshd
RUN echo 'root:password' | chpasswd
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
RUN /usr/bin/ssh-keygen -A
EXPOSE 22
EXPOSE 80
EXPOSE 443
ADD . app/
WORKDIR app
CMD ["sh", "startup.sh"]

The following docker-compose.yml:

version: '3'
services:
  eg_sshd:
    build:
      context: .
      dockerfile: Dockerfile

And the following shell script to get the IP address of the node:

ifconfig
/usr/sbin/sshd -D

I also used “chmod +x” on the script before adding it to docker if that helps at all.
Thanks in advance everyone!


#2

UPDATE: As a point of comparison, I tried the same instructions, but with an AWS EC2 RHEL instance instead of the CentOS docker container I tried to make as the node. I can continue with the tutorial normally, but I would like to try fixing this at some point since a lot of our company’s work involves Docker and I’d love to present Chef as a possible infrastructure automation tool suite that can fix issues with Docker containers.