Archive for the ‘Linux’ Category

Wait for processes to end with Ansible

I’ve been doing a lot in stuff in ansible recently where I needed to fire up, kill and relaunch a bunch of processes. I wanted to find a quick and reliable way of managing this… This is possible using a combination of the pids and wait_for modules… First get the pids of your process… – […]

Broken sudo?

If you somehow add a dodgy sudo rule you might end up breaking it completely… sudo su – >>> /etc/sudoers.d/new_sudo_rule: syntax error near line 1

Linux: Reclaim disk space used by “deleted” files

I had a misbehaving application consuming a large amount of space in /tmp. The files were visible in the /tmp volume itself but lsof allowed me to identify them. lsof -a +L1 -c s3fs /tmp COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME s3fs 59614 root 28u REG 253,3 584056832 0 22 /tmp/tmpfMIMLU4 […]

Offset cron jobs with Ansible

Sometimes I want to run the same cronjob on a few hosts but I might want to offset them slightly if I’m accessing any shared resources. Here’s an easy way to do that, for a small number of hosts, using Ansible… – name: Ensure cron exists cron: name: Test Job minute: “{{ play_hosts.index(inventory_hostname) }}-59/5” job: […]

ssh-copy-id automation with a list of hosts

Here’s another version of my ssh-copy-id script this time using a text file containing a list of hosts. The hosts file should contain a single host per line. #!/bin/bash export SSH_USER=”user” read -s PASSWORD export PASSWORD while read HOST; do export HOST; expect -c ‘ set SSH_USER $env(SSH_USER) set HOST $env(HOST) set PASSWORD $env(PASSWORD) spawn […]