Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Allow user defined post-provision-tasks to use tags while drupal vm does not #1061

Merged
merged 1 commit into from
Dec 22, 2016

Conversation

oxyc
Copy link
Collaborator

@oxyc oxyc commented Dec 20, 2016

At the moment Drupal VM does not use ansible tags out of the box, but I wanted to use it for my own custom post-provision tasks. By default all the pre/post-provision tasks are excluded as the include statements are without tags.

This PR fixes the issue by delegating the decision of tags to the post-provision scripts. Rather than setting the tag to user-provision or something similar, I think they should be set it to always so that users can take full advantage of tags. http://docs.ansible.com/ansible/playbooks_tags.html#special-tags

DRUPALVM_ANSIBLE_ARGS='--tags=foobar' vagrant provision

Currently I'm only tagging the config includes and the post/pre-provision tasks. But maybe we should also tag Include OS-specific variables. and such?

@oxyc
Copy link
Collaborator Author

oxyc commented Dec 20, 2016

Nevermind, that didn't work. @geerlingguy if it's possible to make this work somehow?

@geerlingguy
Copy link
Owner

@oxyc - What's not working? Did you add a tag to a custom task, then set the arg in the vagrant command, and it didn't use just that tag?

@geerlingguy
Copy link
Owner

@oxyc - Also note that tags should always be in an array (I'm 99% sure)—so, like tags: ['always'].

@oxyc
Copy link
Collaborator Author

oxyc commented Dec 21, 2016

If I tag the include task with always, then all the tasks within that file inherit the tag. Thus I can't limit the tasks that actually run :/ I didn't know that's how tag inheritance worked http://docs.ansible.com/ansible/playbooks_tags.html#tag-inheritance

I was hoping I could somehow read the included file, and only execute the tasks within that file that had a particular tag. Seems that's not possible as --tags=foo,bar means the union of foo and bar, rather than the intersection.

@oxyc oxyc closed this Dec 21, 2016
@oxyc
Copy link
Collaborator Author

oxyc commented Dec 21, 2016

@geerlingguy if you have any ideas on how to allow this, I'm very interested :)

@geerlingguy
Copy link
Owner

Hmm...

@geerlingguy
Copy link
Owner

That always behavior sounds more like a bug in Ansible.

@oxyc oxyc reopened this Dec 21, 2016
@oxyc
Copy link
Collaborator Author

oxyc commented Dec 21, 2016

I'll keep this open as a reminder to take a look at the ansible issue queue.

@oxyc
Copy link
Collaborator Author

oxyc commented Dec 21, 2016

It does work, I was just being an idiot. We only need to tag the tasks that allow config.yml to be loaded. After that ansible does check the tags for each task within the included files.

Oh, and tags does not need to be a list. If you prefer a list, I can fix it.

Ready for review.

@geerlingguy
Copy link
Owner

Oh, and tags does not need to be a list. If you prefer a list, I can fix it.

Ah yes... I just always do a list in case I need to modify it. It just feels more correct to me... I'm one of those insane people that dictates PHP functions should only return one and only one type (e.g. empty array, or array... not null, array, FALSE, etc.). Can you change it?

@oxyc
Copy link
Collaborator Author

oxyc commented Dec 22, 2016

There you go!

@geerlingguy geerlingguy merged commit 4c94124 into geerlingguy:master Dec 22, 2016
@oxyc oxyc deleted the allow-tags branch April 24, 2017 15:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants