Check it out on my Ansible YouTube channel
or click the link above.
Here’s the playbook, make_coffee.yml:
---
- name: Make Coffee
hosts: pi
gather_facts: no
tasks:
- name: Verify IOT Coffee Machine is Accessible
ansible.builtin.ping:
- name: Start Brew
become: true
ansible.builtin.command: python /root/relay_on
- name: Turn the Warmer OFF in 10 minutes
become: true
ansible.posix.at:
command: python /root/relay_off
count: 10
units: minutes
And here are the two short python scripts, relay_on and relay off:
### relay_on
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
GPIO.output(14, GPIO.HIGH)
### relay_off
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)
GPIO.output(14, GPIO.LOW)
And the circuit diagram:

Making coffee with Ansible only required 2 Ansible tasks and 8 lines of Python. The implementation was simple because Ansible was the workhorse that did the heavy lifting of communication across diverse hardware platforms.