Skip to content

"[Errno 36] File name too long" on a task creating a directory (ansible-core 2.19) #4717

@Byh0ki

Description

@Byh0ki
Summary

Hello, since a recent update (not sure which 😕), I get a

WARNING  Ignored exception from ArgsRule.matchtasks while processing tasks/install.yml (tasks): [Errno 36] File name too long: '{"ANSIBLE_MODULE_ARGS": {"path": "{{ service_subdir.path }}", "mode": "{{ service_subdir.mode | d(\'0644\') }}", "owner": "{{ service_subdir.owner | d(\'root\') }}", "group": "{{ service_subdir.group | d(\'root\') }}", "state": "{{ service_subdir.enabled | d(true) | ternary(\'directory\', \'absent\') }}"}}'

For this kind of tasks:

- name: Create needed directories for the service
  ansible.builtin.file:
    path: "{{ service_subdir.path }}"
    mode: "{{ service_subdir.mode | d('0644') }}"
    owner: "{{ service_subdir.owner | d('root') }}"
    group: "{{ service_subdir.group | d('root') }}"
    state: "{{ service_subdir.enabled | d(true) | ternary('directory', 'absent') }}"
  loop:
    - {path: "{{ service_dir }}"}
    - {path: "{{ service_files_dir }}"}
    - path: "{{ service_files_dir }}/{{ service_files_extra_dir_name }}"
      enabled: "{{ service_settings.extra_files | d({}) }}"
    - {path: "{{ service_data_dir }}"}
    - {path: "{{ service_logs_dir }}"}
  loop_control:
    loop_var: service_subdir

All the variables are properly defined and I have no issue during execution of the ansible role. The variables are not particularly special either:

service_dir: "/srv/service"
service_files_dir: "{{ service_dir }}/files"
service_data_dir: "{{ service_dir }}/data"
Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 25.7.1.dev0 using ansible-core:2.19.0 ansible-compat:25.6.0 ruamel-yaml:0.18.10 ruamel-yaml-clib:0.2.12
  • ansible installation method: OS package
  • ansible-lint installation method: OS package

OS: Arch Linux

STEPS TO REPRODUCE

ansible-lint config:

---

exclude_paths:
  - .cache

offline: false

skip_list:
  - name[template]
  - jinja
  - yaml

warn_list:
  - key-order[task]

use_default_rules: true

Test playbook:

---

- name: Test playbook
  hosts: localhost

  vars:
    service_dir: "/srv/service"
    service_files_dir: "{{ service_dir }}/files"
    service_data_dir: "{{ service_dir }}/data"
    service_logs_dir: "{{ service_dir }}/logs"

  tasks:
    - name: Create needed directories for the service
      ansible.builtin.file:
        path: "{{ service_subdir.path }}"
        mode: "{{ service_subdir.mode | d('0644') }}"
        owner: "{{ service_subdir.owner | d('root') }}"
        group: "{{ service_subdir.group | d('root') }}"
        state: "{{ service_subdir.enabled | d(true) | ternary('directory', 'absent') }}"
      loop:
        - {path: "{{ service_dir }}"}
        - {path: "{{ service_files_dir }}"}
        - path: "{{ service_files_dir }}/{{ service_files_extra_dir_name }}"
          enabled: "{{ service_settings.extra_files | d({}) }}"
        - {path: "{{ service_data_dir }}"}
        - {path: "{{ service_logs_dir }}"}
      loop_control:
        loop_var: service_subdir

Running ansible-lint test.yml will trigger the console / binary warning but output no actual test warning for some reason

WARNING  Project directory /.ansible cannot be used for caching as it is not writable.
WARNING  Using unique temporary directory /tmp/.ansible-0aaa for caching.
WARNING  Ignored exception from ArgsRule.matchtasks while processing test.yml (playbook): [Errno 36] File name too long: '{"ANSIBLE_MODULE_ARGS": {"path": "{{ service_subdir.path }}", "mode": "{{ service_subdir.mode | d(\'0644\') }}", "owner": "{{ service_subdir.owner | d(\'root\') }}", "group": "{{ service_subdir.group | d(\'root\') }}", "state": "{{ service_subdir.enabled | d(true) | ternary(\'directory\', \'absent\') }}"}}'

Passed: 0 failure(s), 0 warning(s) on 1 files. Last profile that met the validation criteria was 'production'.
Desired Behavior

No warning or at least an actionable message.

Actual Behavior

A warning is returned by ansible-lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions