Ansibe: Finding Public IP Addresses With Filter Plugin

Consider a large inventory file full of hosts, some of them only have private IP addresses, but some of them have public IPs as well. The goal is to identify which hosts have a public IP and print it in a debug message. The process involves running a playbook with a custom filter plugin to examine every host. If a public IP exists on a host, the print a debug message to identify the host....

May 11, 2023 · 2 min

Ansibe: Create Sub Inventory

Consider a large inventory file full of hosts. The goal is to create a smaller list, a ‘sub-inventory’, containing only hosts with a specific service - Docker, in this case. The process involves running a playbook to examine every host. If Docker exists on a host, this host gets added to the smaller list. What’s the significance of this action? During the initial creation of the large inventory, hosts with Docker weren’t categorized separately....

April 6, 2023 · 2 min

Ansible: Combining one variable from multiple sources

Case study: Imagine that firewalld needs to be configured on multiple servers with Ansible. Different servers might have different ports and services are allowed through the firewall. But at the same time some settings are same across all servers, for example the default zone. This article will attempt to provide the best way to configure host_vars and group_vars for firewalld configuration. Since the main focus of this article is on variables, only localhost will be used in examples below....

April 5, 2023 · 3 min