geerlingguy / ansible-collection-php_roles

Collection of PHP roles for Ansible
https://galaxy.ansible.com/geerlingguy/php_roles
MIT License
30 stars 14 forks source link

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

Closed geerlingguy closed 2 years ago

geerlingguy commented 4 years ago

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 commented 4 years ago

(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 commented 4 years ago

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.

Bart97 commented 2 years ago

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" }

geerlingguy commented 2 years ago

@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).

Bart97 commented 2 years ago

@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.

geerlingguy commented 2 years ago

@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).

alexfpoole commented 2 years ago

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