Jon Brookes
2025-01-03
--
server:
hosts:
192.168.88.10:
ansible_python_interpreter: /usr/bin/python3
to my infra-scaling-carnival repo checked out I just added the above to its inventory
having copied my ssh key to it already
ssh-copy-id user@192.168.88.10
and also prior to that checked I can sudo -i
as the user user
which I could not as this bookworm debian did not even have sudo installed so I did that with
su -
apt update
apt install sudo
and checked my user was already in the sudo
group
now, I can ping it back with ansible
ansible -m ping all
192.168.88.10 | SUCCESS => {
"changed": false,
"ping": "pong"
}
after running a playbook to install docker
sdfsa
I can now ssh back into said host on 10 and see it running
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
this uses Jeff Geerlings module and a few bits more
--
name: Install Docker
hosts: server
become: true
vars_files:
vault.yml
tasks:
name: Update and upgrade apt packages
ansible.builtin.apt:
upgrade: yes
update_cache: yes
name: Install Docker
include_role:
name: geerlingguy.docker
name: Wait for Docker to be installed
command: docker --version
register: docker_check
retries: 5
delay: 10
until: docker_check.rc == 0
name: Add user 'user' to docker group
ansible.builtin.user:
name: user
groups: docker
append: yes
there is setup that I had to do further before running these few commands namely,
ansible vault needed configured and given a password file in order to use it in an automated way
Jeff’s role needed insttalled into the cureent enviroment using ansible-galaxy
ansible itself needed installed with a venv
( Python virtual environment ), that environment was activated with source venv/bin/activate
however in summary, all this prepareatory work has made this task and others, for which I can build an array of simple playbooks with Ansible simple and straight forward to achieve, without needing to Google the answer to ‘linux docker install’ ( again ), let alone punching yet another prompt to copilot ai, chat-gpt, gemini, anthropics claude or whatever
time better spent now doing other things, reduced cognitive load and better focus on the task at hand
above all, Ansible and tools like it give us repeatable, predictable outcomes that assure we have consistent infrastructure
if you have your ducks in a row and all your playbooks are idempotent, these can be run again and again even on a scheduled basis using Ansible tower or its open source like
Hey, it could even be run using cron
so long as you capture and log its outputs appropriately and check the results responsibly.
Daily quick wins like this also add to a state of feeling better, general well being and accomplishment and that we have achieved a bit of smart automation without boiling the ocean.
Happy days.