Selectively running tasks but using static includes

This is a terrible weakness in Ansible for me. I don’t want to choose between dynamic and static imports. I want to be able to do both.

I want to be able to use features like --list-tasks and --list-tags but I also want to be able to selectively run tagged tasks within a role. Has anyone come up with a workaround?

Can you describe a scenario where you would want to do this? For me it would help to understand the context and whether we might propose alternative solutions.

Walter

Hey Mark, I don’t think there is a work-around for this.

However, the “Subject:” line is broken. There are no “static includes”. Includes are dynamic, full stop.
Likewise in your second sentence: “I don’t want to choose between dynamic and static imports.” There are no dynamic imports, only static imports.

Anyway, you aren’t alone. Nobody wants to choose between dynamic includes and static imports. But we have to.

Honestly, I agree with you. The array of unexpected behaviors surrounding includes vs. imports, especially wrt tags, is a terrible weaknesses. Newbies never get it right, which in my opinion is a fairly strong indication that the feature is misdesigned.

The documentation explaining imports vs includes wrt tags has improved tremendously over the last couple of years. It currently says at one point, “[U]sing both includes and imports in a single playbook can lead to difficult-to-diagnose bugs.” but it doesn’t give any examples, in part probably because difficult-to-diagnose bugs are also difficult-to-explain bugs. All things considered, stopping at saying “combining these two parallel misdesigned features is a bad idea” is sufficient, so I’ll give them a pass on not explaining what can go wrong.

It’s unfortunate that --list-tasks and --list-tags don’t work for all cases. But if the tool itself can’t explain what to expect, it’s not surprising users have a hard time finding the right incantations.