replicating https://github.com/ansible/ansible/pull/8974 to support the new module repo layout. The actual code changes are copied from https://github.com/tepwil/ansible/commit/260ab8