multiple async actions (background tasks) question

64 views
Skip to first unread message

Dmitry Makovey

unread,
Jun 23, 2014, 3:39:07 PM6/23/14
to ansible...@googlegroups.com
Hi, I'm trying to reconfigure a running OS to use bridge vs the actual interface. My playbook so far:

- name: copy bridge config
  template: src=if-br.j2 dest=/etc/sysconfig/network-scripts/if-{{ bridge_name }} backup=yes

- name: copy interface config
  template: src=if-nic.j2 dest=/etc/sysconfig/network-scripts/if-{{ nic_name }} backup=yes

# we will lose connectivity right after this
- name: add OVS port
  openvswitch_port: bridge={{ bridge_name }} port={{ nic_name }} state=present
  async: 60
  poll: 30

# we should recover connectivity right after this
- name: restart network 
  service: name=network state=restarted 
  async: 60
  poll: 30


As you can see last two actions should be run async (due to loss of connectivity) however they also need to be executed sequentially. I like the way those tasks are defined using Ansible (with some add-on built logic for checking whether bridge exists etc. that I don't have to implement) and would prefer it not to be a shell script instead. Are there any good options for doing it within ansible without resorting to "outsorcing" for that last chunk to a shell script?


Michael DeHaan

unread,
Jun 24, 2014, 9:19:53 AM6/24/14
to ansible...@googlegroups.com
If you are polling on an async job, they will still be executed sequentially.

I do not see where you are calling a shell script in your example, so I can't tell what you mean by the last part of your question.  Can you elaborate or show that part?


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/03df72bb-ebd0-467f-8871-3f2a02edf714%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitry Makovey

unread,
Jun 25, 2014, 11:28:50 AM6/25/14
to ansible...@googlegroups.com
Sorry for being unclear - I meant that I can implement above functionality either via ansible (albeit I have no clue on how to make certain things run in the background as per my question) or write a script that does all of that and have a single ansible statement like this:

- shell: reconfigure_nic.sh {{ nic_name }} {{bridge_name}}

I'm leaving out details of that script implementation because I both don't have it and do not have inclination to implement it with all bells and whistles to match ansible functionality, but something along the lines of:

ovs-vsctl --may-exist add-port {{ bridge_name }} {{nic_name}}
service network restart 

and run it in the background... 
Reply all
Reply to author
Forward
0 new messages