Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch mode for delegate_to and local_action (take 2) #2434

Closed
cheribral opened this issue Mar 17, 2013 · 4 comments · Fixed by #19911
Closed

Batch mode for delegate_to and local_action (take 2) #2434

cheribral opened this issue Mar 17, 2013 · 4 comments · Fixed by #19911

Comments

@cheribral
Copy link

I'll try this again. I had suggested a feature in #2389 which was closed
before I think anyone even understood what the suggestion was. I tried to
clarify what I meant, but it seems like comments to a closed issue go to
/dev/null.

We have roughly 1200 servers which are currently configured with cfengine.
Cfengine is good for determining what to do based on dynamic data, but I have
wanted to find something that can handle group complexity better without
becoming unwieldy or be a resource hog. Obviously, I'm toying around
with ansible, and trying to get it to wrap around a lot of existing stuff.

I have several times wished that delegate_to had an option to do batch
processing instead of firing off for each host in the loop and killing the
delegate server. A batch job is supposedly possible by working around the problem as
described here:
http://jpmens.net/2012/11/03/an-action-plugin-for-ansible-to-handle-ssh-host-keys/

That solution seems less than obvious. As a newbie working through this, the
most intuitive thing I could see would be a "batch=yes" option or something
similar, which would cause delegate_to to run once, and just send the entire
list of hosts ansible is going to loop over.

Anyway, just a suggestion! :)

@mpdehaan
Copy link
Contributor

I think I understand now.

Right now, the functionality you seek needs to exist in the module itself. I think what you are asking for is exactly how yum and apt work.

This can be added to basically any module, but then we also have to teach the module how to work with lists (like apt and yum are told they are special). It would be nice if the module itself could declare this versus the hard code, which is reasonable.

What load balancer are you using? (Or just the shell command?)

We could teach 'shell' to do "with_items" using the ";" as a seperator, perhaps.

@cheribral
Copy link
Author

I think you might be understanding it, just backwards. Switch around which
direction the list is going, and you'll have it. The module isn't accepting a
list, the command being run is getting one, maybe with a special variable.

Perhaps I can make it clear with a ridiculous example. Pretend that I work
just like ansible, and I have to help orchestrate a birthday party.

---
- name: Birthday party
  guests: Joe Jimmy John Susy our_kids kids_from_school
  tasks:
    - name: make somthing to eat
      shell: /home/prepare.sh --food cupcakes --food pizza --for ${guest_name}
      delegate_to: wife
      register: food
  
    - name: feed the kids
      action: feed ${food}
  
    - name: distribute pins for pin-the-tail-on-the-donkey
      action: give_pin

Here would be a good example of a chance for a special variable and a
"run_once" or "batch" option. I could call my wife and say, "Hi Honey, here is
who is coming to the party. It's just going to be Joe. Go ahead and get the
food ready". After she has ordered a small pizza, cooked one cupcake and cleaned
the kitchen, I call her, and tell her about another guest. I do the same
thing for every guest. She would most likely come at me with a kitchen knife when I
got home. If I could do something like the following, I think the party would
be a lot less stressful for everyone:

---
- name: Birthday party
  guests: Joe Jimmy John Susy our_kids kids_from_school
  tasks:
    - name: prepare somthing to eat
      shell: /home/prepare.sh --food cupcakes --food pizza --for ${everyone_who_is_coming}
      delegate_to: wife
      register: food
      run_once: yes

She could use the "everyone_who_is_coming" special variable, and only do the task once.
Hopefully that gives the idea.

@mpdehaan
Copy link
Contributor

mpdehaan commented Apr 5, 2013

This feels like complex_args to me and making a module take a list and knowing what to do with it, but I am closing this because we don't support cupcakes :)

@mpdehaan mpdehaan closed this as completed Apr 5, 2013
@inverminx
Copy link

cheribral, I will be glad to hear if you found a solution for this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants