ansible / mazer

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

Convert typical Ansible Playbook project to a Collection #200

Open alikins opened 5 years ago

alikins commented 5 years ago

Feature Request

Use Case

A lot of users use the typical 'playbook adjacent' project layout for managing playbooks. That style will continue to be supported in ansible, but it may be useful to provide tool to convert it to more of a collections based project.

This would help jumpstart use of the collection 'style'.

Use of the collection style of playbook projects will make it easier for users to adopt content to being managed with collections and/or galaxy in the future.

By 'playbook adjancent' project style, I'm referring to the styles described at https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html#directory-layout

some_git_repo/
      library/
           some_module.py
      module_utils/
           some_python_module.py
      callback_plugins/
           some_custom_callback.py
      roles/
           webserver_virtual_host/
               meta/
               tasks/
               <...>
      myhosts
      my_main_playbook.yml
      another_playbook.yml
      host_vars/
          <...>
      group_vars/
          <...>

And the tool here would migrate it to 'collection style'

some_git_repo/
   playbooks/
      my_main_playbook.yml
      another_playbook.yml
   roles/
        webserver_virtual_host/
            meta/
            tasks/
            <...>
    plugins/
        modules/
            some_module.py
        module_utils/
           some_python_module.py
        callback/
            some_custom_callback.py
     I_am_not_sure_where_host_vars_would_live_yet/

Proposed Solution

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

Alternatives

  1. Not doing it at all

Implementation

Implementation would likely be similar to migrate_role though it may have to be more flexible or heuristic given the variety of ways to structure an ansible playbook project. Not all ansible playbook project structures would be supported, probably just the subset that adhere near to the 'best practices' style.