How to set ulimit -n 10240 for the current session in ansible

Hi

Before installing my product using command module, I need to set ulimit -n 10240. I tried running

  • name: Install product
    command: “{{ item }}”
    with_items:

  • “ulimit -n 10240”

  • “setup -r responsefile”

When I run this way, I get

“module_name”: “command”}, “item”: “ulimit -n 10240”, “msg”: “[Errno 2] No such file or directory”, “rc”: 2}

How can I get it working ?

That will not do what you think it does,even if you set the ulimit it will ONLY affect the task that is setting the ulimit …

Ansible creates new sessions/shells for every task (and in this case, item iteration), so that settign will be lost by the time you call setup.

What you want to do is use the shell module :

shell: umlimit -n 10240; setup -r responsefile