The destination directory (/sys/module/nvme_core/parameters) is not writable by the current user

Hello,

I am using an Ansible Role to copy a template file. It is not allowing me saying… “The destination directory (/sys/module/nvme_core/parameters) is not writable by the current user”

Here is the execution of the play

[root@ip-172-29-100-198 roles]# ansible-playbook -u root --ask-pass storage_timeout.yml
SSH password:

PLAY [172.29.100.194] *********************************************************************************************************************************************************************************

TASK [storage_timeout_aws : template] *****************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 2] No such file or directory: ‘/sys/module/nvme_core/parameters/.ansible_tmpxo2cR0io_timeout’
fatal: [172.29.100.194]: FAILED! => {“changed”: false, “checksum”: “e431bd404db55f2205c3ae4074e3f6de2fb2eb71”, “msg”: “The destination directory (/sys/module/nvme_core/parameters) is not writable by the current user. Error was: [Errno 2] No such file or directory: ‘/sys/module/nvme_core/parameters/.ansible_tmpxo2cR0io_timeout’”}

Here is the template. Very simple

[root@ip-172-29-100-198 roles]# cat storage_timeout_aws/templates/io_timeout
255

  • The current value is 30

Here is the Task

[root@ip-172-29-100-198 roles]# cat storage_timeout_aws/tasks/main.yml

Figured it out. I needed to use the template option “unsafe_writes: yes”

Hi Joe,

I am using an Ansible Role to copy a template file. It is not allowing me
saying...... "The destination directory (/sys/module/nvme_core/parameters)
is not writable by the current user"

I am not sure how to proceed at this point. I have close to 100 servers
with this issue and it is causing some intermittent outages (apparently
this is a known issue with AWS NVME) Thanks for your thoughts in advance

so the problem is, /sys is a virtual file system. You (afaik) can't
remove files from it.

What Ansible does is creating a temporary file with the desired content
and moving it to the destination. And moving implies first removing the
original file. The following won't work either:

echo 40 > /tmp/io_timeout
mv /tmp/io_timeout /sys/module/nvme_core/parameters/io_timeout

The correct solution would be setting the nvme.io_timeout kernel
parameter in /etc/default/grub, regenerating grub config and rebooting.

The easy solution would be something like:

    - name: Get nvme.io_timeout value
      command: /bin/cat /sys/module/nvme_core/parameters/io_timeout
      register: nvme_current_timeout
      changed_when: false

    - name: Set nvme.io_timeout value
      shell: "echo {{ nvme_target_timeout }} >
/sys/module/nvme_core/parameters/io_timeout"
      when: nvme_current_timeout.stdout|int != nvme_target_timeout|int

Regards,
Sebastian

Thanks for that feedback. I am in the process of making a module for grub as well. The problem is that I won’t be allowed to reboot that many servers without wailing and nashing of teeth :slight_smile: I am going to add the temporary solution (io_timeout) and then do the grub entry and allow the reboots to happen organically over time.