IAC-Ansible supports multiple filtering methods to target specific servers.
make deploy LIMIT=0046-20.cloud.bauer-group.commake deploy LIMIT="*.bauer-group.com" # All bauer-group hosts
make deploy LIMIT="0046-*" # All hosts starting with 0046
make deploy LIMIT="*.cloud.*" # All cloud hostsmake deploy LIMIT="192.168.1.*" # Subnet
make deploy LIMIT="10.0.0.1" # Exact IPmake deploy LIMIT=auto_update # All auto-update hosts
make deploy LIMIT=ubuntu # All Ubuntu hosts
make deploy LIMIT=webservers # All web servers# AND (intersection) - hosts in BOTH groups
make deploy LIMIT="auto_update:&ubuntu"
# NOT (exclusion) - auto_update hosts EXCEPT webservers
make deploy LIMIT="auto_update:!webservers"
# Multiple hosts (comma-separated)
make deploy LIMIT="host1.example.com,host2.example.com"Hosts can have labels defined in their inventory entry:
# inventory/production/hosts.yml
0046-20.cloud.bauer-group.com:
labels:
- cloud
- production
- bauer-groupFilter by label:
make deploy LABEL=cloud
make deploy LABEL=productionIf hosts define services in their host_vars:
# inventory/production/host_vars/myhost.yml
services:
- nginx
- docker
- postgresqlFilter by service:
make deploy SERVICE=nginx
make deploy SERVICE=dockerRun only specific parts of the playbook:
make deploy TAGS=common # Only common tasks
make deploy TAGS=update # Only update tasks
make deploy TAGS=ansible-pull # Only pull setup
make deploy TAGS="common,update" # Multiple tagsAvailable in playbooks and templates:
# Filter hosts by label
{{ groups['all'] | filter_by_label('production', hostvars) }}
# Check hostname pattern
when: inventory_hostname | matches_pattern('*.bauer-group.com')
# Check hostname regex
when: inventory_hostname | matches_regex('^web-\d+\.example\.com$')
# Filter by platform
{{ groups['all'] | filter_by_platform('ubuntu_2404', hostvars) }}
# Check for service
when: services | default([]) | has_service('nginx')# Ubuntu hosts with auto-update, only update tasks
make update LIMIT="auto_update:&ubuntu" TAGS=update
# All bauer-group hosts, labeled as cloud
make deploy LIMIT="*.bauer-group.com" LABEL=cloud
# Specific host, dry-run
make check LIMIT=0046-20.cloud.bauer-group.com