# Enabling core dump creation on remote host fails from ansible

**URL:** <https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188>\
**Category:** Get Help\
**Tags:** ubuntu\
**Created:** [January 7, 2024, 1:58pm UTC](https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188 "2024-01-07T13:58:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilia987](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ilia987/32/1852_2.png) [@ilia987](https://forum.ansible.com/u/ilia987)\
**Post date:** [January 7, 2024, 1:58pm UTC](https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188/1 "2024-01-07T13:58:22Z")

</div>

I have set the

**/etc/security/limits.conf** is set set with:

```auto
* soft core unlimited
* hard core unlimited

```

to give all users permission to set coredump size.

when i an trying to run ansible code :

```auto
    - name: Launch my code
      shell:
        python3 script.py
      become: yes
      become_user: AAA

```

content of the script.py:

```auto
import resource
resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(
    resource.RLIMIT_CORE,
        (resource.RLIM_INFINITY, resource.RLIM_INFINITY)
    )

```

**it failes**

but when i connect to the remote host using ssh and connect then running:

```auto
sudo su
python3 script.py

```

the code works.

the difference that i found is that ansible connect to the remote host using:

```auto
sudo -i -u AAA /bin/bash

```

any idea how i can change the way ansible connects and uses the environment ?

both host and target are ubuntu 22.04

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 7, 2024, 2:45pm UTC](https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188/2 "2024-01-07T14:45:46Z")

</div>

Is user `AAA` a member of the `sudo` group? To test if you can connect as user `AAA` and become `root`:

```bash
ssh AAA@server_name
sudo -i
whoami
exit
exit

```

If they are it should be fine to connect as user `AAA` and have the task run as `root`, for example:

```yaml
- name: Run script.py as root
  ansible.builtin.command: python3 script.py
  become: true
  become_user: root

```

---

<div class="post-metadata">

**Author:** ![ilia987](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ilia987/32/1852_2.png) [@ilia987](https://forum.ansible.com/u/ilia987)\
**Post date:** [January 7, 2024, 9:59pm UTC](https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188/3 "2024-01-07T21:59:38Z")

</div>

root is an option but not ideal.  
i am looking for cleaner solution

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [January 7, 2024, 10:21pm UTC](https://forum.ansible.com/t/enabling-core-dump-creation-on-remote-host-fails-from-ansible/3188/4 "2024-01-07T22:21:07Z")

</div>

Can you connect to the server using Ansible as the `AAA` user?

Does the script run as the `AAA` user or does it have to be run by `root`?
