Skip to content

"Create dashboard folders" fails if it finds no folders, using Ansible 2.19 #438

@mtraynham

Description

@mtraynham

Ansible team recently made a change which is much more strict on conditionals and loops.

With Ansible 2.19, these two steps will fail if the custom dashboards directory only contains JSON files and no sub-directories.

https://github.com/grafana/grafana-ansible-collection/blob/6.0.4/roles/grafana/tasks/dashboards.yml#L174-L194

The first task with ansible.builtin.find sets the __dashboards_subdirs to a string value of "All paths examined" instead of the expected list.

The second task then fails with the following,

TASK [grafana.grafana.grafana : Create dashboard folders] ******************************************************************************************************************************************************************************************************************************
task path: ansible/.collections/ansible_collections/grafana/grafana/roles/grafana/tasks/dashboards.yml:187
[ERROR]: The `loop` value must resolve to a 'list', not 'str'.
Origin: ansible/.collections/ansible_collections/grafana/grafana/roles/grafana/tasks/dashboards.yml:195:17

193             group: "grafana"
194             mode: "0755"
195           loop: "{{ __dashboards_subdirs.files | map(attribute='path') | sort | regex_replace(grafana_dashboards_...
                    ^ column 17

Provide a list of items/templates, or a template resolving to a list.

fatal: [grafana-0]: FAILED! => {
    "msg": "The `loop` value must resolve to a 'list', not 'str'."
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions