Anisible works great for applying a configuration to a server. It has a declarative state, and changes only what needs to modified to align the system with the desired configuration.
For my small lab, I don’t want to have to remember to run my ansible playbooks. Because I won’t remember, and the servers will fall behind on patches, and configuration will drift. So I need an orchestrator to automate running the baseline playbooks. I tried Ansible Tower / AWX, but it’s too much for my needs. I’d rather save the CPU and RAM for my workloads, not my infrastructure.
Ansible-pull is the perfect amount of automation for a small environment. It runs locally on each server via cron, ensuring the baseline is consistent and up-to-date.
On a new server, I have a single line that kicks off the playbook, either manually or via cloud-init.
1
wget -O - http://gitlab.home.nicksabine.com/nsabine/ansible-baseline/-/raw/main/install.sh | su -
That install.sh installs ansible and runs the baseline playbook:
There’s a few more things in there, but you get the point. The initial install script runs the playbook the first time, which creates a cron job for itself to run every hour.
With this setup, I have a simple baseline to keep the servers in sync, and an extensible framework to standardize any configuration.
Conditionals
You can write conditions to selectively apply configuration to some of your servers. For example, I can differentiate on ansible facts to select servers by hostname, operating system, etc.
Here I use hostname to decide if I want to start the log sender vs log receiver: