Hi,
I have a role that does everything to standup a server on aws - create a network and provision a VM. But sometimes I only want to run only the part that deploys a new server.
Currently I simple include these sub-tasks in a playbook, which I don’t really like:
tasks:
should be called as a role, but only parts of it …
- include: aws/tasks/provision-net.yml
- include: aws/tasks/provision-vm.yml
thanks
Peter
Could you use
ansible-playbook --start-at-task
Hi Peter,
I’ve found that when you start wanting to invoke sections of a role independently, that’s usually the time that you should break that role up into multiple separate roles. This makes reuse and separate execution much easier. You can have a structure that looks like this, too:
roles/aws/net/tasks/main.yml
roles/aws/vm/tasks/main.yml
…for nice nested organization of roles.
You can then call the roles individually, and if you need to, use role dependencies to enforce one to run before another.
Hope this helps,
-Tim
Hi Tim,
that is what I actually did,
so thanks
Peter