ansible.netcommon icon indicating copy to clipboard operation
ansible.netcommon copied to clipboard

version: null in galaxy.yml causes warnings when installing over git

Open chrispoupart opened this issue 3 years ago • 2 comments

SUMMARY

Setting version: null in galaxy.yml causes warnings when installing the collection over git.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

galaxy.yml's value: key.

ANSIBLE VERSION
ansible 2.10.6
  config file = None
  configured module search path = ['/home/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chris/.local/lib/python3.9/site-packages/ansible
  executable location = /home/chris/.local/bin/ansible
  python version = 3.9.2 (default, Feb 20 2021, 00:00:00) [GCC 10.2.1 20201125 (Red Hat 10.2.1-9)]
STEPS TO REPRODUCE

With Ansible 2.10, the ability to install collections from git repositories was added to provide some level of feature parity with how roles are handled.

To do that, you would add the following to your requirements.yml file:

---
collections:
- name: https://github.com/ansible-collections/ansible.netcommon.git
  version: 2.0.0
  type: git

And then install with ansible-galaxy install -r requirements.yml

EXPECTED RESULTS

It is expected that the collection installs without error. For example, create a requirements.yml:

---
collections:
- name: https://github.com/ansible-collections/community.crypto.git
  version: 1.4.0
  type: git

then:

ansible-galaxy -r install requirements.yml
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'community.crypto:1.4.0' to '/home/chris/Documents/git/linux/server-management/collections/ansible_collections/community/crypto'
Created collection for community.crypto at /home/chris/Documents/git/linux/server-management/collections/ansible_collections/community/crypto
community.crypto (1.4.0) was installed successfully
ACTUAL RESULTS

The collection installs, but it's unclear if the desired version is installed, and ansible-galaxy complains about the version, and instead installs "*".

Starting galaxy collection install process
Process install dependency map
[WARNING]: Collection at '/home/cpoupa1/.ansible/tmp/ansible-local-627044vpjyx0s5/tmp7p91x8r8/ansible.netcommon' does not have a valid
version set, falling back to '*'. Found version: 'None'
Installing 'ansible.netcommon:*' to '/home/chris/Documents/git/linux/server-management/collections/ansible_collections/ansible/netcommon'
Created collection for ansible.netcommon at /home/chris/Documents/git/linux/server-management/collections/ansible_collections/ansible/netcommon
ansible.netcommon (*) was installed successfully

Please note that installing from Galaxy is not always a viable option. In our case, many of our servers that run Ansible playbooks don't have access to the outside world. Instead, we mirror any external roles and collections to our internal git repository and install from there.

chrispoupart avatar Mar 16 '21 16:03 chrispoupart

I'll also add that this completely fails when running with the 2.11 (devel) branch:

$ ansible --version
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC
4.8.5 20150623 (Red Hat 4.8.5-39)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under
development. This is a rapidly changing source of code and can become unstable at any point.
ansible 2.11.0.dev0 (devel 5078a0baa2) last updated 2021/02/22 16:25:30 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chris/git/ansible/lib/ansible
  ansible collection location = /home/chris/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chris/git/ansible/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
  jinja version = 2.11.3
  libyaml = True
$ ansible-galaxy install -r ./requirements.yml
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC
4.8.5 20150623 (Red Hat 4.8.5-39)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under
development. This is a rapidly changing source of code and can become unstable at any point.
Starting galaxy collection install process
ERROR! Collection metadata file at `/home/chris/git/server-management/collections/ansible_collections/ansible/netcommon/MANIFEST.json` is expected to have a valid SemVer version value but got None

chrispoupart avatar Mar 17 '21 14:03 chrispoupart

I'm not a maintainer for this collection but thanks for creating the issue, it's something that was brought to my attention.

I am able to install ansible.netcommon from git with the latest versions of ansible-core (2.11.10 / 2.12.4) with a requirements.yml file:

collections:
  - name: https://github.com/ansible-collections/ansible.netcommon
    version: 2.6.1
    type: git
> ansible-galaxy collection install -r requirements.yml --verbose
No config file found; using defaults
Starting galaxy collection install process
Process install dependency map
Cloning into '/home/dmsimard/.ansible/tmp/ansible-local-2508638lcvzp1eq/tmpywfj4f9b/ansible.netcommon1pgk5hvm'...
remote: Enumerating objects: 2831, done.
remote: Counting objects: 100% (699/699), done.
remote: Compressing objects: 100% (505/505), done.
remote: Total 2831 (delta 384), reused 403 (delta 182), pack-reused 2132
Receiving objects: 100% (2831/2831), 989.47 KiB | 3.88 MiB/s, done.
Resolving deltas: 100% (1667/1667), done.
Note: switching to '2.5.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 7a68f4a Update changelog for 2.5.1 (#368)
Starting collection install process
Downloading https://galaxy.ansible.com/download/ansible-utils-2.5.2.tar.gz to /home/dmsimard/.ansible/tmp/ansible-local-2508638lcvzp1eq/tmpywfj4f9b/ansible-utils-2.5.2-g1ok9ijn
Installing 'ansible.netcommon:*' to '/tmp/collections/ansible_collections/ansible/netcommon'
Created collection for ansible.netcommon:* at /tmp/collections/ansible_collections/ansible/netcommon
ansible.netcommon:* was installed successfully
Installing 'ansible.utils:2.5.2' to '/tmp/collections/ansible_collections/ansible/utils'
ansible.utils:2.5.2 was installed successfully

The problem is that the version of ansible.netcommon is detected as * (Installing 'ansible.netcommon:*' to '/tmp/collections/ansible_collections/ansible/netcommon') so it is not possible to tell which version is actually installed:

> ansible-galaxy collection list ansible.netcommon

# /tmp/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon *      

# /home/dmsimard/dev/virtualenvs/ansible/lib64/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 2.5.1  

I will try to put visibility on this issue to see if it can be addressed.

dmsimard avatar Apr 06 '22 13:04 dmsimard