Role2collection
Tooling to assist in migrating to collections
Install / Use
/learn @ansible-community/Role2collectionREADME
role2collection
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.
role2collection
NOTE: This script requires Python 3.8 or newer
Help
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
Example use
$ python3.8 role2collection.py --extra-path CONTRIBUTING.md roles/role.name collections/ansible_collections/ns/name
What this tool does
- Migrates standard role directories and a few files into a role within a collection:
defaultsfileshandlersmetataskstemplatestestsvarsREADME.md/READMELICENSE.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_utilsimports inmodulesandmodule_utilsto support the migration - Migrates all other directories or files into the root of the collection
Notes
- Does not perform
doc_fragmentsrewrites - Does not do anything with the
testsdirectory, 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-pathto support this
