Nice & ionice Ansible processes on remote hosts

Hi all.

This question is about setting process priorities of Ansible processes on Linux remote hosts. For example, if Ansible wants to install a package, I want that package installation to have a lower priority. The Linux utility ‘nice’ is a common way to make a process run at lower priority.

I was wondering if there is a way to run my remote Ansible processes at a lower priority/higher niceness? We do processing of live video, so cannot afford to have something like Ansible running processes that might take up enough resources to hurt the performance of our video processors.

We recently switched away from Chef and it was easy to nice the chef-client process, which meant all it’s child processes were also niced.

I can think of ways to do this outside of Ansible (nice the sshd process, for example) but if there was a way to do it in Ansible, that would be much better.

After a little digging, the best I could come up with that’s cleaner than trying to nice sshd is to setup an ansible specific user and then restrict that use with cgroups

None of my digging around in docs provided any info on how to do this natively in ansible. But setting up an one-time ansible job (as part of deployment or even your standard image) to set things up that way so that all future jobs preform as expected might work.

Thanks for looking into it!

I think I’m going to make a specific user and give them a ~/.ssh/rc file that renices the process that runs it.

I’ll take a look at cgroups for that. I’ve only ever indirectly dealt with those as a side-affect of docker.