Answers: <p>After research it turned out that it will be necessary to set a larger file size limit via Ansible module  <a href="https://docs.ansible.com/ansible/latest/collections/community/general/pam_limits_module.html" rel="nofollow noreferrer"><code>pam_limits</code></a>. The file size limit should larger than UID * 292 bytes.</p>
  <pre><code>- name: Add or modify soft fsize limits for root domain (for /var/log/lastlog)
    pam_limits:
      domain: root
      limit_type: soft
      limit_item: fsize
      value: '360493823880' # uid * 292
    when: ansible_domain == &quot;example.com&quot;
    tags: install,user,system
  </code></pre>
  <p><strong>Credits to</strong></p>
  <ul>
  <li><a href="https://unix.stackexchange.com/a/530157/266568">Is there a reason why <code>/var/log/lastlog</code> is a huge sparse file?</a></li>
  <li><a href="https://access.redhat.com/solutions/3123941" rel="nofollow noreferrer">Red Hat Solution 3123941</a></li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2024-08-07T07:46:58.783Z
Answers: It is best to include explanations from other websites in your answer to avoid broken links in the future (and not everyone have an account on RedHat too...).
Answers: 4wk_
Answers: CC BY-SA 4.0
Answers: 2024-08-07T07:51:45.307Z
Answers: @4wk_, thanks for following up. "_And why `uid * 292`?_" that's explained in the already linked answer [Is there a reason why ...](https://unix.stackexchange.com/a/530157/266568)
Answers: U880D
Answers: CC BY-SA 4.0
Answers: 2024-08-07T13:25:54.387Z
Answers: yeah I've re-read that's why I edited seconds after ;) Thanks.
Answers: 4wk_
Answers: CC BY-SA 4.0
Answers: 2021-09-22T16:35:32.093Z
Answers: 2021-09-22T16:35:32.093Z
Answers: U880D
Body: <p>Ansible <a href="https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html" rel="nofollow noreferrer"><code>user_module</code></a> exit with <code>rc: -25</code> if trying to create user with UID provided from Active Directory (AD) domain controller (DC).</p>
  <p><strong>main.yml</strong></p>
  <pre><code>- name: Configure local user for example.com
    user:
      name: example
      password: &quot;{{ lookup('file', '/tmp/example_at_host.example.com') }}&quot;
      system: yes         # Defaults to no
      createhome: yes     # Defaults to yes
      uid: '1234567890'   # Default user id of example
      group: '1234500513' # Default group &quot;example users&quot;
      groups: wheel       # Empty by default, here, provide root rights via sudoers wheel
      shell: /bin/bash    # Defaults to /bin/bash
      state: present
    when: ansible_domain == &quot;example.com&quot;
    tags: install,user
  </code></pre>
  <p><strong>stdout</strong></p>
  <pre><code>TASK [Configure local user for example.com] *****************************************************************************
  fatal: [host.example.com]: FAILED! =&gt; changed=false
    msg: ''
    name: example
    rc: -25
  </code></pre>
  <p>Even if trying to create the user manually on CLI</p>
  <pre><code>useradd --system --create-home --uid 1234567890 --gid 1234500513 --groups wheel --shell /bin/bash --comment &quot;Example User&quot; example
  </code></pre>
  <p>it fails.</p>
  <pre><code>File size limit exceeded (core dumped)
  </code></pre>
  <p>How to resolve this and get user created with same ID as in AD?</p>
  
Tags: <ansible><linux>
Title: Ansible user_module exit with "rc: -25" if UID is large
UserDisplayName: U880D
ThreadText: # Ansible user_module exit with "rc: -25" if UID is large
  
  (Asked by: username_0 on 2021-09-22)
  
  Ansible [`user_module`](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/user_module.html) exit with `rc: -25` if trying to create user with UID provided from Active Directory (AD) domain controller (DC).
  
  **main.yml**
  
  ```
  - name: Configure local user for example.com
    user:
      name: example
      password: "{{ lookup('file', '/tmp/example_at_host.example.com') }}"
      system: yes         # Defaults to no
      createhome: yes     # Defaults to yes
      uid: '1234567890'   # Default user id of example
      group: '1234500513' # Default group "example users"
      groups: wheel       # Empty by default, here, provide root rights via sudoers wheel
      shell: /bin/bash    # Defaults to /bin/bash
      state: present
    when: ansible_domain == "example.com"
    tags: install,user
  
  ```
  
  **stdout**
  
  ```
  TASK [Configure local user for example.com] *****************************************************************************
  fatal: [host.example.com]: FAILED! => changed=false
    msg: ''
    name: example
    rc: -25
  
  ```
  
  Even if trying to create the user manually on CLI
  
  ```
  useradd --system --create-home --uid 1234567890 --gid 1234500513 --groups wheel --shell /bin/bash --comment "Example User" example
  
  ```
  
  it fails.
  
  ```
  File size limit exceeded (core dumped)
  
  ```
  
  How to resolve this and get user created with same ID as in AD?
  
  **Tags:** ansible, linux
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-09-22. Score: 0 | Accepted answer
  
  After research it turned out that it will be necessary to set a larger file size limit via Ansible module [`pam_limits`](https://docs.ansible.com/ansible/latest/collections/community/general/pam_limits_module.html). The file size limit should larger than UID \* 292 bytes.
  
  ```
  - name: Add or modify soft fsize limits for root domain (for /var/log/lastlog)
    pam_limits:
      domain: root
      limit_type: soft
      limit_item: fsize
      value: '360493823880' # uid * 292
    when: ansible_domain == "example.com"
    tags: install,user,system
  
  ```
  
  **Credits to**
  
  * [Is there a reason why `/var/log/lastlog` is a huge sparse file?](https://unix.stackexchange.com/a/530157/266568)
  * [Red Hat Solution 3123941](https://access.redhat.com/solutions/3123941)
  
  > **Comments:**
  > **username_1**: It is best to include explanations from other websites in your answer to avoid broken links in the future (and not everyone have an account on RedHat too...).  
  > **username_0**: @username_1, thanks for following up. "_And why `uid * 292`?_" that's explained in the already linked answer [Is there a reason why ...](https://unix.stackexchange.com/a/530157/266568)  
  > **username_1**: yeah I've re-read that's why I edited seconds after ;) Thanks.  
  
  ---
  
  