Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel_blacklist - Error while setting attributes: /tmp/xyz: Operation not supported #7362

Closed
1 task done
bartlomiejkida opened this issue Oct 7, 2023 · 4 comments · Fixed by #7382
Closed
1 task done
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) traceback

Comments

@bartlomiejkida
Copy link

Summary

I wanted to blacklist some kernel modules using the ready-made kernel_blacklist in Ansible.

My sample code:

- name: Remove potentially affected (and unused) modules
  community.general.kernel_blacklist:
    name: "{{ line_item }}"
    state: present
    blacklist_file: "/etc/modprobe.d/{{ line_item }}-blacklist.conf"
  with_items:
    - cifs
    - cls_rsvp
  loop_control:
    loop_var: line_item

As I understand it, the module should create such a file and add content to it.

As a result, when you run the playbook, the files are created but their contents are empty:

$ find /etc/modprobe.d/ -size 0 -ls
  6030631      0 -rw-r--r--   1 root     root            0 paź  7 12:19 /etc/modprobe.d/cls_rsvp-blacklist.conf
  6029638      0 -rw-r--r--   1 root     root            0 paź  7 12:19 /etc/modprobe.d/cifs-blacklist.conf

Additionally, when launching the playbook, I receive a failure message. Below traceback ( -vvv)

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.general.kernel_blacklist_payload_rk2m8l96/ansible_community.general.kernel_blacklist_payload.zip/ansible/module_utils/basic.py", line 1003, in set_attributes_if_different
    raise Exception("Error while setting attributes: %s" % (out + err))
Exception: Error while setting attributes: /tmp/tmpnholykn5: Operation not supported

failed: [local] (item=cls_rsvp) => {
    "ansible_loop_var": "line_item",
    "changed": false,
    "details": "Error while setting attributes: /tmp/tmpnholykn5: Operation not supported\n",
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "blacklist_file": "/etc/modprobe.d/cls_rsvp-blacklist.conf",
            "name": "cls_rsvp",
            "state": "present"
        }
    },
    "line_item": "cls_rsvp",
    "mode": "0644",
    "msg": "chattr failed",
    "owner": "root",
    "path": "/tmp/tmpnholykn5",
    "size": 0,
    "state": "file",
    "uid": 0
}

I don't know why module display Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported.
In bash shell work perfect:

# rm -fv /etc/modprobe.d/cifs-blacklist.conf
removed '/etc/modprobe.d/cifs-blacklist.conf'
# touch /etc/modprobe.d/cifs-blacklist.conf
# echo 'test test' > /etc/modprobe.d/cifs-blacklist.conf

Issue Type

Bug Report

Component Name

kernel_blacklist

Ansible Version

$ ansible --version
ansible [core 2.14.10]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/bkida/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/bkida/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.5 (main, Aug 28 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /usr/lib/python3.11/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.2  

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.6.0  

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg

OS / Environment

Fedora 38

Steps to Reproduce

Copy example code from summary description and run on the same ansible / community.general version

Expected Results

Working module ;)

Actual Results

Error while setting attributes: /tmp/tmpwn_d8ybv: Operation not supported

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

cc @matze
click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) traceback labels Oct 7, 2023
@felixfontein
Copy link
Collaborator

The module copies the current file to a temporary place (while preserving permissions) and atomically moves it back.

The "preserving permissions" part of the first copying step seems to fail.

This extra copying step was added in 2ad7ed4, more specifically in b42ca59. @russoz do you remember why you did it that way?

@russoz
Copy link
Collaborator

russoz commented Oct 11, 2023

@felixfontein TBH, not really. But I found a better way to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants