ruebenramirez / blog

My blog
http://blog.ruebenramirez.com/
7 stars 0 forks source link

ansible-playbook matching hosts #357

Open ruebenramirez opened 7 years ago

ruebenramirez commented 7 years ago

apply a trailing , to your -i host

# Host and IP address
ansible all -i example.com,
ansible all -i 93.184.216.119,
# Requires 'hosts: all' in your playbook
ansible-playbook -i example.com, playbook.yml

source: http://stackoverflow.com/a/18255256

ruebenramirez commented 7 years ago

use --extra-vars

playbook:

---
- hosts: '{{ target }}'
...

usage:

ansible-playbook playbook.yml --extra-vars "target=host1"

source: http://stackoverflow.com/a/18195217