Tooling to assist in migrating to collections
These tools may cover many common cases, but do not aim to address all cases.
After using these tools, users should manually verify the changes, and may be required to make further changes to produce functional content.
NOTE: This script requires Python 3.8 or newer
usage: role2collection.py [-h] [--extra-path EXTRA_PATH] ROLE_PATH COLLECTION_PATH
positional arguments:
ROLE_PATH Path to a role to migrate
COLLECTION_PATH Path to collection where role should be migrated
optional arguments:
-h, --help show this help message and exit
--extra-path EXTRA_PATH
Extra role relative file/directory path to keep with the role. May be supplied multiple
times
$ python3.8 role2collection.py --extra-path CONTRIBUTING.md roles/role.name collections/ansible_collections/ns/name
- Migrates standard role directories and a few files into a role within a collection:
defaults
files
handlers
meta
tasks
templates
tests
vars
README.md
/README
LICENSE.txt
/LICENSE
- For any other file or directory you wish to keep with a role use
--extra-path
- Migrates plugins from the role into the collection level plugin directories
- Rewrites
module_utils
imports inmodules
andmodule_utils
to support the migration - Migrates all other directories or files into the root of the collection
- Does not perform
doc_fragments
rewrites - Does not do anything with the
tests
directory, other than keep them with the role - Does not modify anything in role YAML files
- Overwrites duplicate files
- Does not come with any warranties
- Does not special case any 3rd party tool directory or files, use
--extra-path
to support this