# Change request: community.general.ini\_file

**URL:** <https://forum.ansible.com/t/change-request-community-general-ini-file/3953>\
**Category:** Get Help\
**Created:** [February 19, 2024, 5:35pm UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953 "2024-02-19T17:35:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![idratherbediving](https://avatars.discourse-cdn.com/v4/letter/i/34f0e0/32.png) [@idratherbediving](https://forum.ansible.com/u/idratherbediving)\
**Post date:** [February 19, 2024, 5:35pm UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953/1 "2024-02-19T17:35:53Z")

</div>

I just signed up and I’m not sure if this is the right place to post this so here it goes:

The in the community.general.ini\_file module the default return for changed: false is fail if the file does not exist. To me, it would make more sense if it was marked as skipped. Thoughts?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 19, 2024, 7:04pm UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953/2 "2024-02-19T19:04:43Z")

</div>

Welcome to the forum!

I’m not sure I understand what you mean. Can you specify more precisely in which case the module fails when it shouldn’t?

---

<div class="post-metadata">

**Author:** ![idratherbediving](https://avatars.discourse-cdn.com/v4/letter/i/34f0e0/32.png) [@idratherbediving](https://forum.ansible.com/u/idratherbediving)\
**Post date:** [February 19, 2024, 9:02pm UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953/3 "2024-02-19T21:02:53Z")

</div>

If I do:

```auto
- name: Ini test 1

community.general.ini_file:

name: /some/test/inifile

create: true

section: main

option: purple

value: peopleeater

```

It will create the file /some/test/inifile

And put in it:

```auto
[main]

purple=peopleater

```

If I change this to:

```auto
- name: Ini test 1

community.general.ini_file:

name: /some/test/inifile

create: false

section: main

option: purple

value: peopleater

```

If /some/test/inifile does not exist. The play will fail and thus cause the whole playbook to fail. I’m suggesting that change: false behavior should be skipped vs fail. So that if the file exists, great modify it, otherwise move on to the next play and notify that the play was skipped. Yes, I understand I could run a pre-check play and see if /some/test/inifile exists, then run the “Ini test 1” play with a when statement. I’m just suggesting the idea, and I’m a relative noob to the Ansible world, so I was wondering what the appetite for a change like this might be.

Thanks for listening 😊

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 20, 2024, 6:18am UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953/4 "2024-02-20T06:18:09Z")

</div>

> If /some/test/inifile does not exist. The play will fail and thus cause the whole playbook to fail.

That’s the intended behavior for `create: false`. Changing it would break a LOT of existing playbooks and roles.

If you want to skip the task when the file does not exist, you need to use the [ansible.builtin.stat](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html) to first figure out whether the file exists, register its return value, and then add a `when:` condition based on that return value to the `community.general.ini_file` task. It will be skipped if the condition evaluates to `false`.

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [February 20, 2024, 5:31pm UTC](https://forum.ansible.com/t/change-request-community-general-ini-file/3953/5 "2024-02-20T17:31:51Z")

</div>

People expect modules to fail when they can’t do what they’re asked to and it would be a bad idea to change the module’s behaviour.

You can instead use `failed_when` to change what is considered an error for your specific task, since you’re okay with this change not being made.

```yaml
    - name: Add value to nonexistent file
      community.general.ini_file:
        path: /some/test/inifile
        create: false
        section: main
        option: purple
        value: peopleater
      register: result
      failed_when:
        - result is failed
        - result.msg != 'Destination /some/test/inifile does not exist!'

```
