Posts tagged ansible

Quick Tip: Ansible target hosts with wildcard

This is a short quick tip about Ansible. TL;DR: it’s possible to use a wildcard in the target hosts specifier. This became useful to me when I dynamically created the inventory based on Ansible facts.

Read more ...


Quick Tip: Ansible commands as non-root user with environment variables

This is a short quick tip. When executing Ansible playbooks, you might need to execute a task as another user than the one you established the connection with. This post shows an example how to do it and deal with the environment variables.

Read more ...


Ansible Playbook Refactoring into Roles

In a previous post (Monitoring with Prometheus), we created one playbook which contained all the logic. This post will show how to do a refactoring of a playbook into smaller, reusable Ansible Roles. This allows us to hide complexity and to provide defined interfaces. It also increases the ability to work in parallel on different parts of your Infrastructure as Code (IaC) project. I won’t explore how you publish your roles to Ansible Galaxy but merely show a basic recipe how you move Playbook logic step by step into project specific roles.

Read more ...