ansible / mazer

Experimental Ansible Galaxy Content Manager
GNU General Public License v3.0
113 stars 18 forks source link

Add a way to convert traditional roles to collections #186

Closed alikins closed 5 years ago

alikins commented 5 years ago

Feature Request

To ease transitional from traditional style roles to the newer collection format, it would be useful to be able to convert a traditional style role into a collection that contains that role.

Use Case

What problem does this feature solve? Please describe. A clear and concise description of what the problem is. Ex. I have an issue when [...]

At some point, mazer will stop installing traditional style roles directly and will only support collections. To make it easier for users to use mazer and ansible 2.8 with collections, and to continue using traditional style releases with older ansible releases, this feature would provide way to convert an on disk traditional role repository, to a collection style repository.

Proposed Solution

Describe the solution you'd like A clear and concise description of what you want to happen. Add any considered drawbacks.

mazer 'convert-role'[1], when pointed at a directory with a role in it:

For ex, transform a role like:

ntp
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── LICENSE
├── meta
│   └── main.yml
├── molecule
│   └── default
│       ├── molecule.yml
│       ├── playbook.yml
│       ├── tests
│       │   └── test_default.py
│       └── yaml-lint.yml
├── README.md
├── tasks
│   ├── clock-rhel-6.yml
│   └── main.yml
├── templates
│   ├── clock.j2
│   └── ntp.conf.j2
└── vars
    ├── Archlinux.yml
    ├── Debian.yml
    ├── FreeBSD.yml
    ├── RedHat.yml
    └── Suse.yml

to:


ntp
├── galaxy.yml
├── README.md
└── roles
    └── ntp
        ├── defaults
        │   └── main.yml
        ├── handlers
        │   └── main.yml
        ├── LICENSE
        ├── meta
        │   └── main.yml
        ├── README.md
        ├── tasks
        │   ├── clock-rhel-6.yml
        │   └── main.yml
        ├── templates
        │   ├── clock.j2
        │   └── ntp.conf.j2
        ├── tests
        │   ├── README.md
        │   └── test.yml
        └── vars
            ├── Archlinux.yml
            ├── Debian.yml
            ├── FreeBSD.yml
            ├── RedHat.yml
            └── Suse.yml

There is existing code to do most of that, as it is used as implementation details of how mazer install installs traditional style roles as collections currently (a59757e5cbab905f63ecc8a1d468b7963da918a5)

Main drawbacks/concerns

[1] not final name

Alternatives

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

  1. Instead of transform an on disk role directory to an on disk collection directory, 'mazer build' could support creating a collection artifact directly from a traditional role.

Implementation

Teachability, Documentation, Adoption, Migration Strategy

mazer migrate-role-to-collection --namespace some_namespace --name some_name some_role/ --output-dir ./some_collection/

alikins commented 5 years ago

ping @chouseknecht @thaumos

alikins commented 5 years ago

@chouseknecht @thaumos A couple of open questions about this feature:

thaumos commented 5 years ago

Responses to previous comment...

One point I want to make aside from this... Let's make sure we aren't marrying ourselves to mazer being the entry point to this. I want this ultimately to be a molecule thing later.

alikins commented 5 years ago

@thaumos "* Source code modification: We should not have any tooling do modification. I hope I understand you correctly."

To clarify, I do not want mazer migrate_role to modify a roles plugin or module source code. This branch does not modify role plugin or module source code. And we agree that mazer migraterole should not modify the role plugin or module source code, even if that means plugins and modules used via the new collection loader will not work without further modification_.

alikins commented 5 years ago

@thaumos

  • Role type migration: I think Galaxy roles is for our MVP. If we can do non-Galaxy roles later, then cool. However, let's not block ourselves. For version, let's have them specify.

Currently (d293ee1164fc550c76272359c7a5a3e1b0b53e9e) migrate_role does no "auto" detection of version, and the version of the new collection must be specified with '--version'. That includes galaxy style roles and any others.

Adding some git based "auto" detection of the role version based on git tags could be added later however.

alikins commented 5 years ago

@thaumos

License determination: No, let's not try to interpret. Have them specify.

Seems reasonable, I'll add a way to specify.

I'll start with behavior like:

And assuming no difficulties, also: