9

It seems that all jobs are enqueued, and only one will run at a time. How can we run more than one?

Evan
  • 3,191
  • 4
  • 29
  • 25
  • This is a great question. It could really do with an accepted response, or some feedback so we can update our answers. – MillerGeek May 20 '16 at 01:54

5 Answers5

8

Tower is designed to parallelize jobs, but there are a couple of cases where it will not.

  1. If you have your inventory or SCM set up to "update on launch" with no cache or the cahche has expired, then any additional jobs will be stuck pending behind the inventory or SCM update. The inventory and SCM will not update until after the currently running job is done.
  2. If you are trying to run multiple jobs against the same host: Tower will not run multiple jobs against the same host at the same time in order to avoid race conditions. (localhost is a possible exception). If you need multiple jobs to run against the same host at the same time then you need to create two inventories and put that host in both inventories, running the two jobs against different inventories. In this situation, Tower does not know that you are running against the same host.
MillerGeek
  • 3,057
  • 20
  • 23
  • Did you find this info in the documentation? Could you post a link if you did? – laughingbovine May 16 '16 at 20:09
  • I'm not sure where or if this is documented. This was from personal experience. It has now been about 9 months since I posted this answer, and I'm not sure what, if anything, has changed, since I am not using Tower in my current position. – MillerGeek May 17 '16 at 18:53
  • I managed to find some documentation on parallelization in Ansible Tower: http://docs.ansible.com/ansible-tower/2.4.5/html/userguide/jobs.html#job-concurrency – laughingbovine May 19 '16 at 19:20
  • Mine is condition 1. Thanks! This BLOWS though because my jobs are running through callbacks so I need the inventory to update on launch. So If I have multiple jobs from multiple nodes doing callbacks this will slow things down to a crawl. – eco May 20 '16 at 01:48
  • I had The exact same problem @einarc. My solution was to stop doing callbacks and instead run the playbooks locally by passing a userdata script to my EC2 instances. Not an ideal solution, but it's something. – MillerGeek May 20 '16 at 21:32
  • @smiller, yeah. Either that or a seeded AMI. But that means you'd need ansible installed on every instance, and subsequently things like BOTO and so on. Like you said, non ideal because well, it defeats the purpose of Tower. – eco May 21 '16 at 01:18
  • @einarc I used Tower on the trial license and only used it for spinning up infrastructure (localhost) and that infrastructure bootstrapped itself I used Packer to create AMIs that had my playbooks already on the machine, and ran them with the right variables by templating the userdata scripts from Tower when I spun up the infrastructure. Ultimately, I think Tower is very overpriced considering it's limitations. My understanding though is that they are going to Open Source it in the next year or two now that RedHat owns them. – MillerGeek May 21 '16 at 01:23
4

Jobs which share the same Inventory or SCM source can not run at the same time.

Keith Adler
  • 20,880
  • 28
  • 119
  • 189
  • Hmm... Perhaps it is a license thing? Would you mind sharing which license type you have? On the 10-server evaluation license, this isn't possible. – Evan Jan 19 '15 at 20:56
  • I suspect it's a configuration thing. I don't know where. – tedder42 Jan 20 '15 at 22:10
  • The answer was that jobs which share the same Inventory or SCM source can not run at the same time. – Keith Adler Jan 20 '16 at 06:54
  • 1
    This is not entirely true. They can share the same inventory as long as the same hosts are not being targeted. (If inventory A has groups B and C, Job D can run against group B while job E runs against group C) The exception to this is if you try to update the inventory between running job D and Job E. The inventory update will have to wait, so job E can't run. – MillerGeek May 17 '16 at 18:55
3

Suppose you have a job comprised of three tasks:

task 1: "do x", task 2: "do y", task 3: "do z"

With ansible "do x" will run on all the servers, then "do y" will run on all the servers, then "do z" will run on all the servers.

Also, I said "all serves" but in fact it maxes out at the ansible "forks" value, which defaults to 5. In my 100 server enviroment I set this value to 20. more on this here: http://docs.ansible.com/intro_configuration.html#forks

Remember the strength of ansible is doing a job ( a collection of tasks) on many machines at the same time. If what you want is to run the same task many times on a single machine, then you want something like fork, or parallel.

In fact Ansible will try to run "do x" as many times as it can across many machines. You can adjust this behavior having the whole job run on a portion of machines before it gets started on more machines with the "serial" keyword (http://docs.ansible.com/playbooks_delegation.html#rolling-update-batch-size).

Not the subtle difference between forks, and serial.

  • forks is "per task"

  • serial is "per job" ( collection of tasks )

David Thornton

Edit:I re-read your question. This is about running more than one job at a time, not running more than on task in a job. So I think you are correct for ansible-awx but not for the command line. Via the web interface you can submit a job to the job queue, but you can't make ansible-awx run more than one task at a time. I think. However via command line, if you open more than one window you can run multiple ansible-playbooks at the same time. Do you have an ansible support account? Those guys are great IMHO, they have taken a lot of time to answer my questions ( like your question ).

David Thornton
  • 529
  • 4
  • 4
  • Yep, your edit is the real question: I would love parallelism in the awx/ansible tower server. – Evan Jan 16 '15 at 20:49
1

Simultaneous jobs can be executed from Tower. Job templates have "Enable Concurrent Jobs" option. See section "15.4. Job Concurrency" at http://docs.ansible.com/ansible-tower/latest/html/userguide/jobs.html.

0

If i have 3 different tasks on a single server running its called synchronous mode management, 3 tasks will be assigned to a single job ID , and each tasks executes one after the other were it consumes lots of time.

In Ansible version later than 2.5 we can get 3 job ID for 3 different tasks , and start executing at a same time were we can save a huge time.This type is called asynchronous mode.