Closed jarnohenneman closed 6 years ago
Interesting as it should be using systemd on Ubuntu 16.04
and sensu 1.4.2
and I know this worked previously at my last company as that is what they used. I don't recall doing anything special to make this happen.
Can you try replicating this with older versions of chef?
I also see you are using dokken
can you please include a gist of what your config looks like? I recall needing to specify pid_one_command: /bin/systemd
in your .kitchen.yml
I conferred with a colleague of mine at the last place and we did have to do some magic to make systemd work with sensu in a container. Here is the platform section he gave me:
platforms:
- name: ubuntu-1604
named_run_list: debian
driver:
image: ubuntu:16.04
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd
intermediate_instructions: # make systemd work as process 1
# install addtional packages that can't be installed by cookbook
- ENV container docker
- RUN rm -rf /var/lib/apt/lists/*
- RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done)
- RUN rm -f /lib/systemd/system/multi-user.target.wants/*
- RUN rm -f /etc/systemd/system/*.wants/*
- RUN rm -f /lib/systemd/system/local-fs.target.wants/*
- RUN rm -f /lib/systemd/system/sockets.target.wants/*udev*
- RUN rm -f /lib/systemd/system/sockets.target.wants/*initctl*
- RUN rm -f /lib/systemd/system/basic.target.wants/*
- RUN rm -f /lib/systemd/system/anaconda.target.wants/*
- RUN apt-get -y update
- RUN apt-get install -y apt-transport-https build-essential zlib1g-dev python-pip sudo net-tools
- RUN pip install PyYAML && pip install awscli
Thank you @majormoses , will give it a test to see if its working!
Unfortunately no smoke light yet,,, this is the kitchen Im trying with:
---
driver:
name: dokken
chef_version: latest
privileged: true # because Docker and SystemD/Upstart
customize:
memory: '512'
transport:
name: dokken
provisioner:
name: dokken
verifier:
name: inspec
platforms:
- name: ubuntu-16.04
driver:
# image: ubuntu:16.04
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd
intermediate_instructions: # make systemd work as process 1
# install addtional packages that can't be installed by cookbook
- ENV container docker
- RUN rm -rf /var/lib/apt/lists/*
- RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done)
- RUN rm -f /lib/systemd/system/multi-user.target.wants/*
- RUN rm -f /etc/systemd/system/*.wants/*
- RUN rm -f /lib/systemd/system/local-fs.target.wants/*
- RUN rm -f /lib/systemd/system/sockets.target.wants/*udev*
- RUN rm -f /lib/systemd/system/sockets.target.wants/*initctl*
- RUN rm -f /lib/systemd/system/basic.target.wants/*
- RUN rm -f /lib/systemd/system/anaconda.target.wants/*
- RUN apt-get -y update
- RUN apt-get install -y apt-transport-https build-essential zlib1g-dev python-pip sudo net-tools
- RUN pip install PyYAML && pip install awscli
run_list:
- recipe[apt]
attributes:
apt:
compile_time_update: true
suites:
- name: default
run_list:
- recipe[monitor::master]
Can you try replicating this with older versions of chef?
It used to work with chef-lxc and chef12, but would like to throw lxc out of the window and go for a container like setup.
@jarnohenneman I see you are using the monitor
cookbook which is quite old and not been updated. If you are using all the default attributes (not properly overriding them) the version of sensu defined does not include a systemd
unit file which I believe started shipping in 0.27
. I know that when I was there we were also on chef
12 and I am not sure if they have upgraded to chef 13 yet. I can try asking if they have done that yet. That being said at my current org we are using chef
13 our setup but are still sadly on Ubuntu 14.04 so I cant really confirm what other changes would be necessary.
We are not using the supermarket monitor cookbook. As mentioned we are deploying sensu in version 1.4 not 0.27. It works for us with Chef 12 on VMs / Cloud instances, be it as a test with kitchen or in production, and as mentioned in our usual quick testing environment of kitchen-lxc. Sensu is also entirely installed by the sensu cookbook (meaning the one this discussion is in). The purpose of our cookbook, is to setup the basic checks of every system and the sensu gems/plugins, handlers, etc. necessary to do so, as well as the transport and therefore the target of sensu-clients to which to report to. What we certainly do not modify is the fact that there is a service, or that it is started, enabled, etc. and how that works one different distributions or operating systems.
It used to work with chef-lxc and chef12, but would like to throw lxc out of the window and go for a container like setup.
Can we try changing one thing at a time to see if its more of a dokken/docker issue and use chef 12?
@autarchprinceps makes sense, I would have no way of knowing that its an internal cookbook based on the code block I was given. I will try to see if I can put together a minimal reproduction case when I have some time. It might be a bit as I have very limited personal time for the next week or so due to some family events.
To help me reproduce does this happen only on the server component or does it fail on client as well?
I was not able to reproduce this with a minimal setup, perhaps with more information as to what you are doing in your custom cookbook I will be able to further assist.
Minimal setup: https://github.com/sensu/sensu-chef/compare/feature/local-dokken-testing?expand=1
Output: https://gist.github.com/majormoses/ef35735eaf05b38bda9aba9fd7f96b2a
Thank you @majormoses , think I have it running let me do some more testing and get back to you
For me its working now with the following setup;
---
driver:
name: dokken
chef_version: latest
privileged: true # because Docker and SystemD/Upstart
platforms:
- name: ubuntu-16.04
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
My problem was that I ended up commenting to much recipes, or saying it differently sensu::default is required to run sensu::server_service - sensu::api_service - sensu::client_service, not sure why but above worked for me. Thank you so much @majormoses !
Its working perfectly @majormoses ! Thank you for your help I'm closing the issue.
No such file or directory - /sbin/status - Unable to start or restart the Sensu service on Ubuntu 16.04
Expected Behavior
The correct Ubuntu provider should be selected and service installed.
Current Behavior
Currently it will fail on the installation of Sensu::default or other Sensu recipes.
Possible Solution
-
Steps to Reproduce (for bugs)
Your Environment