| name | ansible-ops |
| description | Ansible operations patterns covering playbook execution, secret management with 1Password, task automation, and security best practices. Use when writing or running Ansible playbooks. |
Ansible Operations
Running Playbooks
Use a task runner (like mise, make, or just) to wrap playbook execution and handle environment setup:
mise run playbook ansible/playbooks/deploy-service-stack.yml
mise run playbook ansible/playbooks/deploy-monitoring-stack.yml --ask-become-pass
ansible-playbook -i ansible/inventory/hosts.ini ansible/playbooks/deploy-service.yml
Secret Management with 1Password
Service Account Pattern
Store the 1Password service account token in a .env file (gitignored) and load it automatically through your task runner:
OP_SERVICE_ACCOUNT_TOKEN=ops_xxxxx...
op whoami
Using Secrets in Playbooks
- name: Deploy service with secrets
environment:
API_KEY: "{{ lookup('env', 'OP_SERVICE_ACCOUNT_TOKEN') | community.general.onepassword_raw('API Key', vault='MyVault') }}"