The Wayback Machine - https://web.archive.org/web/20200716091305/https://github.com/ansible/ansible/issues/66255
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

role_skeleton read by ansible-galaxy collection init #66255

Open
greg-hellings opened this issue Jan 7, 2020 · 6 comments
Open

role_skeleton read by ansible-galaxy collection init #66255

greg-hellings opened this issue Jan 7, 2020 · 6 comments

Comments

@greg-hellings
Copy link
Contributor

@greg-hellings greg-hellings commented Jan 7, 2020

SUMMARY

When executing ansible-galaxy collection init with a value in galaxy.role_skeleton inside of ansible.cfg, the role skeleton directory is read to create a new collection. Based on its name, the role_skeleton value should not apply to a collection init call.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible-galaxy

ANSIBLE VERSION
ansible 2.9.2
  config file = /home/ghelling/.ansible.cfg
  configured module search path = ['/home/ghelling/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ghelling/venv/tools3/lib64/python3.7/site-packages/ansible
  executable location = /home/ghelling/venv/tools3/bin/ansible
  python version = 3.7.5 (default, Oct 17 2019, 12:16:48) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
CONFIGURATION
ANSIBLE_PIPELINING(/home/ghelling/.ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/ghelling/.ansible.cfg) = -o ControlMaster=auto -o ControlPersist=600s -o IdentitiesOnly=yes
ANSIBLE_SSH_CONTROL_PATH(/home/ghelling/.ansible.cfg) = %(directory)s/%%h-%%r
ANSIBLE_SSH_CONTROL_PATH_DIR(/home/ghelling/.ansible.cfg) = /tmp
DEFAULT_CALLBACK_WHITELIST(/home/ghelling/.ansible.cfg) = ['timer', 'profile_tasks']
DEFAULT_FORKS(/home/ghelling/.ansible.cfg) = 10
DEFAULT_STDOUT_CALLBACK(/home/ghelling/.ansible.cfg) = yaml
GALAXY_ROLE_SKELETON(/home/ghelling/.ansible.cfg) = /home/ghelling/config/source/oasis/roles/meta_skeleton
GALAXY_ROLE_SKELETON_IGNORE(/home/ghelling/.ansible.cfg) = ['^.git$', '^.*/.git_keep$', '\\..*.swp']
HOST_KEY_CHECKING(/home/ghelling/.ansible.cfg) = False
OS / ENVIRONMENT

All

STEPS TO REPRODUCE
ansible-galaxy collection init mynamespace.mycollection
EXPECTED RESULTS

Creates a collection directory based on the default collection skeleton

ACTUAL RESULTS

Templates the custom skeleton directory defined by GALAXY_ROLE_SKELETON exactly as if ansible-galaxy init myrole had been called, but with an empty value for role_name. Files are contained within the proper mynamespace/mycollection folder depth, though, as expected. However, they are the role skeleton files instead of the collection skeleton.

@ansibot
Copy link
Contributor

@ansibot ansibot commented Jan 7, 2020

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@sivel
Copy link
Member

@sivel sivel commented Apr 13, 2020

On the surface this is an easy fix, but I'm unsure what else may need to change as a result of this:

diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
index 89a9dcc547..94f312c1b4 100644
--- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py
@@ -217,7 +217,7 @@ class GalaxyCLI(CLI):
                                  help='The path in which the skeleton {0} will be created. The default is the '
                                       'current working directory.'.format(galaxy_type))
         init_parser.add_argument('--{0}-skeleton'.format(galaxy_type), dest='{0}_skeleton'.format(galaxy_type),
-                                 default=C.GALAXY_ROLE_SKELETON,
+                                 default=C.GALAXY_ROLE_SKELETON if galaxy_type == 'role' else None,
                                  help='The path to a {0} skeleton that the new {0} should be based '
                                       'upon.'.format(galaxy_type))

Does the underlying collection code handle None?

More testing, and a changelog would be required.

I'm not pursuing this further at this time.

@sivel sivel added the easyfix label Apr 13, 2020
@geerlingguy
Copy link
Contributor

@geerlingguy geerlingguy commented Apr 13, 2020

The other question would be—do we eventually want to support custom collection skeletons? That would be a separate feature request, but I know enough people have found role skeletons to be a huge productivity booster, that I would imagine custom collection skeletons would be the same. (I didn't realize this didn't exist yet.)

@greg-hellings
Copy link
Contributor Author

@greg-hellings greg-hellings commented Apr 13, 2020

The other question would be—do we eventually want to support custom collection skeletons? That would be a separate feature request, but I know enough people have found role skeletons to be a huge productivity booster, that I would imagine custom collection skeletons would be the same. (I didn't realize this didn't exist yet.)

Since we have a default collection skeleton, and we support custom role skeletons, I can't image we wouldn't want to support custom collection skeletons. I don't plan to make as many collections as I have roles - that's one of the things I like about collections. But I do plan to make at least one for each product we support and would love to have skeleton support.

@sivel
Copy link
Member

@sivel sivel commented Apr 13, 2020

To further clarify, this is only an issue for users who have explicitly configured GALAXY_ROLE_SKELETON

@geerlingguy
Copy link
Contributor

@geerlingguy geerlingguy commented Apr 13, 2020

@sivel - I also noticed in the docs it mentions:

Role or collection skeleton directory to use as a template for the init action in ansible-galaxy, same as --role-skeleton.

(Emphasis mine) So if this is fixed that docs line also needs updating since the variable would no longer apply to collections.

So I guess the bug is that right now the variable name is misleading, and there's only one variable used for two different types of content, which makes the experience broken if you already it use roles and want to start creating collections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.