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

89 views
Skip to first unread message

Joe Langdon

unread,
Jul 29, 2019, 4:29:22 PM7/29/19
to Ansible Project
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
---
# tasks file for /etc/ansible/roles/storage_timeout_aws
# Works with just root folder

- template:
    src: io_timeout
    dest: /sys/module/nvme_core/parameters/io_timeout




Thoughts 

-  Not sure it matters but this is to update NVME keep alive timeout. Sometimes Linux can't find EBS volume in AWS and the filesystem goes read only 
-  I am logging in as root 
-  I have also tried using "become: yes"
- I AM able to write the io_timeout file directly to the /root directory with same credentials 
- I do have the path correct

[root@elastic140 ~]# cat /sys/module/nvme_core/parameters/io_timeout
30


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 

Joe Langdon

unread,
Jul 29, 2019, 5:30:13 PM7/29/19
to Ansible Project
Figured it out. I needed to use the template option "unsafe_writes: yes"

Sebastian Meyer

unread,
Jul 29, 2019, 5:30:51 PM7/29/19
to ansible...@googlegroups.com
Hi Joe,

On 29.07.19 22:29, Joe Langdon wrote:
> 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

--
Sebastian Meyer
Linux Consultant & Trainer
Mail: me...@b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

Joe Langdon

unread,
Jul 29, 2019, 5:58:52 PM7/29/19
to Ansible Project
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 :-) 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. 


On Monday, July 29, 2019 at 4:29:22 PM UTC-4, Joe Langdon wrote:
Reply all
Reply to author
Forward
0 new messages