# Doas is not working in my playbook... error msg Dest /etc/ not writable

**URL:** <https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704>\
**Category:** Get Help\
**Tags:** playbook\
**Created:** [October 13, 2023, 3:53pm UTC](https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704 "2023-10-13T15:53:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![quist](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/quist/32/1169_2.png) [@quist](https://forum.ansible.com/u/quist)\
**Post date:** [October 13, 2023, 3:53pm UTC](https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704/1 "2023-10-13T15:53:53Z")

</div>

I am trying to write some configuration files to an OpenBSD node.  
I have created a remote user: ansible  
I have allowed said user to perform as root in /etc/doas.conf  
I have tested logging in as well as using doas to become root interactively  
The playbook is as follows:

```auto
- name: For newer OpenBSD hosts
  hosts: obsd_doas
  gather_facts: true
  become: yes
  become_method: community.general.doas
  become_user: root
 - name: Write the snmp client configuration file
    template:
      src: "{{ ansible_facts['distribution'] }}_snmpd.j2"
      dest: /etc/snmpd.conf
      owner: root
      group: wheel
      mode: '0600'
    notify:
    - restart snmpd

```

Using the following command:

```auto
$ ansible-playbook -v --limit dns5-new -K snmp.yml

```

The error message is:

```auto
TASK [Gathering Facts] ********************************************************************************************************************************************************************************
ok: [dns5-new]

TASK [Write the snmp client configuration file] *******************************************************************************************************************************************************
fatal: [dns5-new]: FAILED! => {"changed": false, "checksum": "a71ac6e888a48b1caf483e077bd985c6fdbd02e9", "msg": "Destination /etc not writable"}

PLAY RECAP ********************************************************************************************************************************************************************************************
dns5-new : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

```

Tag: playbook, doas

---

<div class="post-metadata">

**Author:** ![ptn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ptn/32/481_2.png) [@ptn](https://forum.ansible.com/u/ptn)\
**Post date:** [October 14, 2023, 10:34am UTC](https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704/2 "2023-10-14T10:34:06Z")

</div>

Hi,

A few questions / observations:

- Are your sure you are connecting as ‘ansible’ user on remote node using Ansibe ? Could you run: `ansible -i <yourInventoryFile> dns5-new -m setup -a 'filter=ansible_user_id'` ?
- I understand opening up a root shell using doas interactively works, while being logged in as ‘ansible’ user on your remote node, but have you tried also manually creating a file on /etc/ using doas (preferably not from a root shell) ? It should work in theory, though you might have some filesystem attributes on that might prevent your user writing on it, like an ext4 immutable equivalent
- Have you tried templating out your file elsewhere, both on another root-restricted path and one that is not, like /tmp ? What gives ?
- Could your run your playbook in verbose / debug mode, using either `-vvv` (should be enough) params or `ANSIBLE_DEBUG=1` envvar, then post the output ?
- Which version of Ansible are you using ? (`ansible --version`)
- It surely is a bad or reconstituted paste but your playbook present syntax issues (no `tasks:` block indicator, and task name not correctly indented). Output doesn’t reflect that, so nvm

---

<div class="post-metadata">

**Author:** ![quist](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/quist/32/1169_2.png) [@quist](https://forum.ansible.com/u/quist)\
**Post date:** [October 14, 2023, 2:55pm UTC](https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704/3 "2023-10-14T14:55:50Z")

</div>

I was able to find the error. It was that I had the following in my hosts file:

ansible\_become\_user: ansible

where as it should have been:

ansible\_become\_user: root

which is probably the default

Thanks for your assistance!

---

<div class="post-metadata">

**Author:** ![wa\_schaly](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wa_schaly/32/1079_2.png) [@wa\_schaly](https://forum.ansible.com/u/wa_schaly)\
**Post date:** [October 15, 2023, 11:59am UTC](https://forum.ansible.com/t/doas-is-not-working-in-my-playbook-error-msg-dest-etc-not-writable/1704/4 "2023-10-15T11:59:33Z")

</div>

As an extra debugging flag … have you tried instead of -v the -vv or -vvv ?
