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

user/group modules slow #7846

ryan-lane opened this issue Jun 19, 2014 · 5 comments


None yet
5 participants
Copy link

commented Jun 19, 2014

Issue Type:

Bug Report

Ansible Version:

ansible 1.6.3


Ubuntu 14.04


I have a playbook that adds 80 matching users and groups. Playbook runs that make no changes take nearly as long as runs that make all of the changes.

Steps To Reproduce:

Here's my tasks:

    - name: Ensure groups exist
      group: name={{ item.key }} gid={{ }}
      with_dict: users

    - name: Ensure users exist
      user: name={{ item.key }} uid={{ }} group={{ item.key }} groups=group1,group2,group3,group4,group5 comment="{{ item.value.full_name }}" shell=/bin/bash
      with_dict: users
Expected Results:

1-2 seconds for no-change runs. ~10 seconds for adding/removing all users and groups.

Actual Results:


real    0m33.069s
user    0m17.924s
sys     0m14.141s


real    0m31.818s
user    0m17.456s
sys     0m13.656s

No change:

real    0m29.248s
user    0m17.086s
sys     0m12.665s

This comment has been minimized.

Copy link

commented Jun 19, 2014

You're running your user creation in loops, so each of those items is a new connection out to the server. Are you running the ansible command from a system that supports ControlPersist connections via ssh (RHEL/CentOS 6+ or Ubuntu 12.04+) - it's unclear if the environment you specify above is the managed system or the ansible host.

Beyond that, your numbers seem highly arbitrary. Ansible must gather a lot of information about whether or not a change needs to be made, along with the overhead of the connection, so 30 seconds to add 80 users does not seem that far out of bounds.


This comment has been minimized.

Copy link

commented Jun 19, 2014

I'm using:

ansible-playbook -c local users.yml

My main complaint is that just checking 80 users/groups takes 30 seconds when running locally.


This comment has been minimized.

Copy link

commented Jun 20, 2014

So that's 0.5 seconds per user. I don't think we can do too much about that generically, but we'd welcome improvements. Feel free to start a discussion about how to do this per user on ansible-devel.

@mpdehaan mpdehaan closed this Jun 20, 2014


This comment has been minimized.

Copy link

commented Feb 1, 2015

Does seem terribly slow :( - has anything been done to address this?


This comment has been minimized.

Copy link

commented Feb 13, 2015

For what it's worth, please see below the result of running a 'user' task with 10k items.

In Fedora 21, the "accounts-daemon" services uses 100% CPU for a very long time (even after the playbook is finished). Looks like it's documented here but I'm not sure it's related (I'll try to reproduce on another system without systemd to check):

- name: create many users
    name: "{{ item }}"
    comment: "{{ item }}"
    state: present
    - user0
    - user1
    - ...

This was captured with Python's cProfile and plotted with gprof2dot.


@ansible ansible locked and limited conversation to collaborators Apr 25, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.