Skip to content

Instantly share code, notes, and snippets.

@lordmuffin
Last active July 21, 2017 16:54
Show Gist options
  • Save lordmuffin/c73804336593f872700ebbe07c843d08 to your computer and use it in GitHub Desktop.
Save lordmuffin/c73804336593f872700ebbe07c843d08 to your computer and use it in GitHub Desktop.
Example of nested playbooks and different ip?
- name: this is a play at the top level of a file
hosts: pre-ip
remote_user: root
tasks:
- name: say hi
tags: foo
shell: echo "hi..."
- name: this is a play at the top level of a file
hosts: post-ip
remote_user: root
tasks:
- name: say hi
tags: foo
shell: echo "hi..."
[pre-ip]
hostname1 ansible_host=192.0.2.50
[post-ip]
hostname2 ansible_host=192.0.2.51
- name: this is a play at the top level of a file
hosts: pre-ip
remote_user: root
tasks:
- name: say hi
tags: foo
shell: echo "hi..."
# and this is how we include another playbook, be careful and
# don't recurse infinitely or anything. Note you can't use
# any variables in the include path here.
- include: hostname1.yml
- include: hostname2.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment