Skip to content

Instantly share code, notes, and snippets.

@pescobar
Created June 21, 2019 14:12
Show Gist options
  • Save pescobar/7a21d0e065d6b8d204ba09000aa0a49e to your computer and use it in GitHub Desktop.
Save pescobar/7a21d0e065d6b8d204ba09000aa0a49e to your computer and use it in GitHub Desktop.
override ansible host on runtime
```
---
- name: Common tasks for dcc-devel servers
hosts: "{{ hostsvar | default('host1, host2, host3') }}"
gather_facts: True
remote_user: root
tasks:
- name: dummy task
command: echo hi
```
if you run `ansible-playbook playbook.yml` it will be executed in `host1, host2, host3` but you can override it by doing
`ansible-playbook -e hostsvar=newhost playbook.yml`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment