You could use delegation to run some of the tasks on another machine (in this case localhost).
But to be honest I wouldn't, personally I'd split this into 2 plays. On 12 March 2017 at 04:33, Zhu Wayne <[email protected]> wrote: > Is it possible to pack the following into a single role? My understanding > that a role ONLY can be run on a defined set of hosts. > > - name: Provision a vagrant machine > hosts: localhost > vars: > > box: trusty64 > tasks: > > - name: create a Vagrantfile > command: vagrant init {{ box }} creates=Vagrantfile > > - name: Bring up a vagrant server > command: vagrant up > > - name: add the Vagrant hosts to the inventory > add_host: > > > name=vagrant > ansible_ssh_host=127.0.0.1 > ansible_ssh_port=2222 > ansible_ssh_user=vagrant > > ansible_ssh_private_key_file=/Users/lorinhochstein/.vagrant.d/ > insecure_private_key > > > - name: Do something to the vagrant machine > hosts: vagrant > sudo: yes > tasks: > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/e65e7792-1911-4bd7-a773-2c13e08d20dd%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK5eLPQfQMZWt5WGBpWZNntP4M375wXanExpVVUjmv%3Dhgetozw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
