Archive for the ‘devops’ Category

How to tell if you’re in a docker container

Sometimes you need to know if you’re inside a docker container from the shell. Here’s how you can do that.. First spin up a container.. docker run -ti –rm ubuntu You can perform a cat on the cgroups section of your process in /proc. N.B. self means the calling process… cat /proc/self/cgroup In a docker […]

Linux Server checks with Goss

I’ve been playing a little with goss recently. Goss is similar to TestInfra in that it allows you to write tests to validate your infrastructure. Goss uses yaml to specify the expected state rather than python code unittests like Testinfra. It also has a couple of other interesting features making it stand out from the […]

“could not open session” error in docker container

I received the following error, attempting to cat a log file, inside a docker contain when troubleshooting another issue… TASK [setup_cassandra : shell] ************************************************* changed: [testhost] => {“changed”: true, “cmd”: “cat /var/log/cassandra/*”, “delta”: “0:00:00.004140”, “end”: “2019-03-16 18:48:28.684133”, “rc”: 0, “start”: “2019-03-16 18:48:28.679993”, “stderr”: “”, “stderr_lines”: [], “stdout”: “could not open session”, “stdout_lines”: [“could not open […]

Vagrant: Create a series of VMs from a hostname array

I couldn’t find any examples of creating VMs from a array of strings online so sat down to work something out myself. Here’s how you do it… Vagrant.configure(“2”) do |config| [ “web1”, “db1”, “web2”, “db2”, “backup1”, “backup2”, “admin1” ].each do |host| config.vm.define “#{host}” do |nrpe| = “bento/centos-7.5” nrpe.vm.provider :virtualbox do |vb| vb.customize [ “modifyvm”, […]