I've been looking into similar stuff with ansible. It seems like there is a problem with the archive module in general (as of version 2.4, not sure if its been fixed yet). I saw on their git hub that a pull request that fixes the archive module exclude_path option has been put up, but I don't think its been merged into the code yet.
The problem has to do with exactly how the items in the exclude_path interact with the items in the path. As far as I can tell it makes exclude_path extremely hard to use and almost useless, but then again I don't fully understand the problem so maybe I just don't see the 'correct' way to format to work around the issue.
I've been trying to think of a work-around that I like for the current tarball I want to create and I stumbled on this hoping to find someone who had already come up with a good work-around.
My leading thoughts are:
- try to do it with the shell or command module and the tar command
- use a bunch of smaller ansible file copy operations to create a staging directory that looks like what I want and then tar up that
I don't really like either which is why I was hoping to find a better work-around....