Cool, thanks... I found that example far from intuitive, and it wasn't clear to me when I looked at it that it facilitated firing off many different tasks at different points, but after loading it up and messing with it for a while I think i have an ugly but functional version of what I was looking for, so I should be able to sugar that up somehow into something like what I want :)
On Friday, September 8, 2017 at 10:30:22 PM UTC+8, jhawkesworth wrote: > > I think async_status will do what you want already. I've not had cause to > use it myself but there's an example about halfway down this page > > http://docs.ansible.com/ansible/latest/playbooks_async.html > > > ---# Requires ansible 1.8+- name: 'YUM - fire and forget task' > yum: name=docker-io state=installed > async: 1000 > poll: 0 > register: yum_sleeper > - name: 'YUM - check on fire and forget task' > async_status: jid={{ yum_sleeper.ansible_job_id }} > register: job_result > until: job_result.finished > retries: 30 > > > Hope this helps, > > Jon > On Friday, September 8, 2017 at 2:51:00 PM UTC+1, ne...@neilsouza.com > wrote: >> >> It seems like it would be really useful to have "await" functionality to >> go with the async task stuff - instead of poll or "fire-and-forget", the >> ability to start async tasks that are going to take a while and receive >> handles to them which can then be used later in the play to wait for them >> to succeed or fail to continue. >> >> If this is already possible, I'd appreciate some pointers on how to do >> it. I didn't spend a ton of time with the async docs, but I didn't see >> anything that seemed to indicate this functionality to me. Did quick >> searches here, online and on the project mailing list and didn't see >> anything either. >> >> I was thinking of something like... >> >> >> # We're working normally (sequentially)... >> >> >> - name: Init/update all Git submodules >> command: git submodule update --init >> >> >> # OK, now we're ready to kick off some tasks that are independent of each >> other >> # and can take quite a while to complete: >> >> >> - name: Start independent asynchronous background tasks... >> async: >> # I structured these as a dict to emphasis that they're not running >> in >> # order, like a list might suggest. The keys (user-defined - >> whatever >> # you want) could then be used to access results on the handle. >> tasks: >> git_lfs_pull: >> name: Pull Git LFS files >> command: git lfs pull >> >> bundle_install: >> name: Install gems with Bundler >> bundler: >> state: present >> # A handle you receive back that can be used to wait for the tasks. >> register: async_handle >> >> >> # Now we can keep working in sequence... >> >> >> - name: Install some Python packages with Pip >> with_items: >> - pathlib2 >> - docker-compose >> pip: >> name: "{{ item }}" >> >> >> # ...whatever else as usual... >> >> >> # OK, now we're at the point where we need the async tasks to be done >> >> >> - name: Wait for async tasks to be done. >> await: >> handle: "{{ async_handle }}" >> >> >> # Once here, we know the async stuff is done and successful (or failed >> with the >> # usual message, etc.) >> >> >> - name: Kick off a build... >> command: docker-compose build . >> >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.