WIP: Replace the include module with include_tasks or import_tasks #147

Draft
mtrossevin wants to merge 1 commit from replace_include into unstable
Owner

The behaviour of the include module is badly defined (it try to choose
between statically importing the tasks and dynamically including them)
and can cause problems depending on any number of constraints (mostly if
it choose the wrong behaviour).

Replace it with the import_tasks (always statically import tasks) unless
the include is in a loop in which case we replace it with
include_tasks (always dynamically include tasks).

The behaviour of the `include` module is badly defined (it try to choose between statically importing the tasks and dynamically including them) and can cause problems depending on any number of constraints (mostly if it choose the wrong behaviour). Replace it with the `import_tasks` (always statically import tasks) unless the `include` is in a loop in which case we replace it with `include_tasks` (always dynamically include tasks).
Author
Owner

We also replace include_role with import_role where relevant (so if the include_role itself isn't looped) as it is more efficient and make the tasks actually appear in ansible-playbook --list-tasks, it result in different behaviour where tags are concerned (they are applied on the imported tasks instead of only on the include_role) but I believe it is what we actually want most of the time (with remount-usr).

We also replace `include_role` with `import_role` where relevant (so if the `include_role` itself isn't looped) as it is more efficient and make the tasks actually appear in `ansible-playbook --list-tasks`, it result in different behaviour where tags are concerned (they are applied on the imported tasks instead of only on the `include_role`) but I believe it is what we actually want most of the time (with remount-usr).
mtrossevin force-pushed replace_include from 542292e0f3 to 73b7eff126 2022-03-02 13:36:06 +01:00 Compare
mtrossevin force-pushed replace_include from 73b7eff126 to 0a968e831d 2022-03-02 17:14:40 +01:00 Compare
mtrossevin force-pushed replace_include from 0a968e831d to 356f4e3c2b 2022-03-04 16:20:07 +01:00 Compare
Author
Owner

We also replace include_role with import_role where relevant (so if the include_role itself isn't looped) as it is more efficient and make the tasks actually appear in ansible-playbook --list-tasks, it result in different behaviour where tags are concerned (they are applied on the imported tasks instead of only on the include_role) but I believe it is what we actually want most of the time (with remount-usr).

After a few tests, that cause problems with handlers with the same name in different roles, so I reverted that change (should have made a different commit).

> We also replace `include_role` with `import_role` where relevant (so if the `include_role` itself isn't looped) as it is more efficient and make the tasks actually appear in `ansible-playbook --list-tasks`, it result in different behaviour where tags are concerned (they are applied on the imported tasks instead of only on the `include_role`) but I believe it is what we actually want most of the time (with remount-usr). After a few tests, that cause problems with handlers with the same name in different roles, so I reverted that change (should have made a different commit).
mtrossevin force-pushed replace_include from 356f4e3c2b to f49ffb1c2d 2022-03-07 09:27:50 +01:00 Compare
Owner

For info, I used this patch in a playbook and didn't encountered errors.

For info, I used this patch in a playbook and didn't encountered errors.
mtrossevin force-pushed replace_include from f49ffb1c2d to 956ecd4700 2022-03-30 16:40:58 +02:00 Compare
mtrossevin force-pushed replace_include from 956ecd4700 to 74d4d7c19c 2023-01-02 10:50:37 +01:00 Compare
mtrossevin force-pushed replace_include from 74d4d7c19c to 58cc3d6dcd 2023-01-02 11:53:29 +01:00 Compare
mtrossevin force-pushed replace_include from 58cc3d6dcd to 74a11d0982 2023-01-02 11:54:05 +01:00 Compare
mtrossevin force-pushed replace_include from 74a11d0982 to 7c632352a0 2023-01-03 14:44:05 +01:00 Compare
This pull request has changes conflicting with the target branch.
  • CHANGELOG.md
  • apache/tasks/auth.yml
  • apache/tasks/main.yml
  • apt/tasks/main.yml
  • bind/tasks/main.yml
  • certbot/tasks/main.yml
  • dovecot/tasks/main.yml
  • drbd/tasks/main.yml
  • elasticsearch/tasks/main.yml
  • etc-git/tasks/main.yml

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin replace_include:replace_include
git checkout replace_include

Merge

Merge the changes and update on Forgejo.
git checkout unstable
git merge --no-ff replace_include
git checkout unstable
git merge --ff-only replace_include
git checkout replace_include
git rebase unstable
git checkout unstable
git merge --no-ff replace_include
git checkout unstable
git merge --squash replace_include
git checkout unstable
git merge --ff-only replace_include
git checkout unstable
git merge replace_include
git push origin unstable
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: evolix/ansible-roles#147
No description provided.