ansible-collection-php_roles icon indicating copy to clipboard operation
ansible-collection-php_roles copied to clipboard

Integration test failing, possibly due to Ansible bug with roles-in-collections

Open geerlingguy opened this issue 4 years ago • 7 comments

The bug is that I get 'with_flattened' is not a valid attribute for a Task in CI. See details here: https://github.com/ansible/ansible/issues/71884

Currently, CI builds are failing because of this. Note that the upstream role itself is passing, so it seems like a problem when a role is run inside a collection, maybe?

geerlingguy avatar Sep 23 '20 16:09 geerlingguy

(Alternatively, I could ditch with_flattened and use | flatten with a loop and a combine... don't want to do that unless necessary though. See: https://github.com/ansible/ansible/blob/3e9943bc5e7a9cd393757aa8100d7fed80bd316e/docs/docsite/rst/user_guide/shared_snippets/with2loop.txt#L62-L77).

geerlingguy avatar Sep 23 '20 16:09 geerlingguy

It was a problem that the community.general collection wasn't present inside the ansible-test environment, so Ansible couldn't use the with_flattened plugin.

geerlingguy avatar Sep 23 '20 18:09 geerlingguy

I'm seeing a similar error when trying to use the php role with AWX:

{ "reason": "'with_flattened' is not a valid attribute for a Task\n\nThe error appears to be in '/runner/requirements_roles/geerlingguy.php/tasks/configure.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure configuration directories exist.\n ^ here\n\nThis error can be suppressed as a warning using the \"invalid_task_attribute_failed\" configuration\n\nThe error appears to be in '/runner/requirements_roles/geerlingguy.php/tasks/configure.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Ensure configuration directories exist.\n ^ here\n" }

Bart97 avatar Feb 11 '22 21:02 Bart97

@Bart97 - Unfortunately I haven't really updated this collection in a while, mostly because I'm still not using it anywhere (I still use the dependent roles directly).

geerlingguy avatar Feb 11 '22 22:02 geerlingguy

@Bart97 - Unfortunately I haven't really updated this collection in a while, mostly because I'm still not using it anywhere (I still use the dependent roles directly).

I've tried using the geerlingguy.php role directly and I've encountered the same issue. Adding community.general to my playbook's requirements seems to solve the problem. I'm not sure if it's something I'm supposed to do, or if it could be somehow added to the role's requirements.

Bart97 avatar Feb 12 '22 11:02 Bart97

@Bart97 - That's one other downside with collections—roles can't depend on them (and collections can't depend on roles either)...

In my case, I always install Ansible via Pip (so pip3 install ansible), which gives me the Ansible "Community" edition (whatever it's called these days) which has all the common collections built in (I don't have to add on any other collections that might be required by traditional Ansible roles and playbooks that don't use FQCNs).

geerlingguy avatar Feb 12 '22 16:02 geerlingguy

If someone's followed your Ansible Best Practice advice and moved Collections to the repo they're working on, they'll need to explicitly re-import this collection:

#requirements.yml:
collections:
  - name: community.general
    version: 5.1.0

ansible-galaxy install -r requirements.yml

alexfpoole avatar Jun 14 '22 11:06 alexfpoole