2

Is it possible to specify the process priority for an Ansible task?

The use case is setting a low priority for an expensive and long-running backup task. In a bash script I'd use nice for this. I did not find anything by searching using keywords "process priority" and "nice" combined with "Ansible".

Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79

1 Answers1

1

async tasks allow you to run tasks in background. This helps in avoiding long-running tasks from blocking remaining tasks. The approach works as long as the remaining tasks are independent of the task marked async, this can reduce wait time.

For example, waiting for huge file to complete download and the next task is c completely independent command which can take some time. Since async task will run in the background by the time it is completed the rest of the independent commands are done.

Link on documentation below https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html

CRDias
  • 114
  • 3
  • While this is interesting, it does not answer my question about process priority. I'm not concerned with runtime of my playbook, I'm concerned with how my playbook affects running services (like a webserver). – Jeroen De Dauw May 29 '20 at 10:27
  • I don't think you can do something as granular as defining CPU time and priority as in case of nice that will override ansible optimization for task executions. Is there any particular task you want to tweak this for?. A little optimization is possible by tweaking ansible.cfg file or using a custom plugin. – CRDias May 29 '20 at 15:48