Archive for the ‘Linux’ Category

Offset cron jobs with Ansible


Warning: count(): Parameter must be an array or an object that implements Countable in /home/fbsqlcom/public_html/youdidwhatwithtsql.com/wp-content/plugins/wp-codebox/main.php on line 31

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… ?View Code YAML- name: Ensure cron exists cron: name: Test Job minute: "{{ play_hosts.index(inventory_hostname) […]

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. ?View Code BASH#!/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 […]

Creating a Vagrant, Virtualbox & Ansible environment in the Windows Linux Subsystem

I’ve just been given a new Windows corporate laptop, with a huge amount of RAM (64GB), a large number of cores, and I wanted to start using this as my main development virtualisation platform. I do a lot of stuff with Vagrant, Ansible and VirtualBox and Windows hasn’t always been a welcome home for this […]

Automate ssh-copy-id with numbered hosts

Here’s a script I use to automate ssh-copy-id when I need to add a series of hosts using a incremental node number. For example… prod-db-server001 prod-db-server002 prod-db-server003 and so on. The script uses expect to perform its work. To adjust this for your own purposes you simply need to change the SSH_USER variable, the number […]

Using avahi / mDNS in a Vagrant project

I’m working on a project, with Vagrant and Ansible, to deploy a MongoDB Cluster. I needed name resolution to function between the VirtualBox VMs I was creating and didn’t want to hardcode anything in the hosts file. The solution I decided on uses avahi which essentially works like Apple Bonjour. As this solution has broader […]