amrox / asdf-pyapp

A generic Python Application plugin the asdf version manager.
MIT License
60 stars 8 forks source link

Can I switch between ansible-base and ansible-core? #21

Closed okamos closed 2 years ago

okamos commented 2 years ago

Is your feature request related to a problem? Please describe. Can I switch between ansible-base and ansible-core? I use both ansible 2.10.x and 2.11.x or higher. I installed ansible-core and ansible-base, asdf uses the first installed. When switching between ansible-base and ansible-core, one of them had to be removed

Describe the solution you'd like Switch between ansible-base and ansible-core without remove the ansible-core or ansible-base.

Describe alternatives you've considered Nothing.

Additional context The script messages when I installed both.

okamoto_shinichi[~] asdf list 2>&1 | grep -A 1 ansible
ansible-core
  2.12.4
okamoto_shinichi[~] ansible --version
ansible [core 2.12.4]
  config file = None
  configured module search path = ['/Users/okamoto_shinichi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/venv/lib/python3.10/site-package
  ansible collection location = /Users/okamoto_shinichi/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/bin/ansible
  python version = 3.10.1 (main, Dec 23 2021, 17:57:48) [Clang 13.0.0 (clang-1300.0.27.3)]
  jinja version = 3.1.1
  libyaml = True
okamoto_shinichi[~] asdf plugin add ansible-base https://github.com/amrox/asdf-pyapp.git
okamoto_shinichi[~] asdf install ansible-base 2.10.17

okamoto_shinichi[~] asdf global ansible-base 2.10.17
okamoto_shinichi[~] asdf list 2>&1 | grep -A 1 ansible
ansible-base
  2.10.17
ansible-core
  2.12.4
okamoto_shinichi[~] asdf reshim
okamoto_shinichi[~] ansible --version
ansible [core 2.12.4]
  config file = None
  configured module search path = ['/Users/okamoto_shinichi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/venv/lib/python3.10/site-package
  ansible collection location = /Users/okamoto_shinichi/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/bin/ansible
  python version = 3.10.1 (main, Dec 23 2021, 17:57:48) [Clang 13.0.0 (clang-1300.0.27.3)]
  jinja version = 3.1.1
  libyaml = True
amrox commented 2 years ago

I'm actually not too familiar with ansible, but this seems to due to the fact that both plugins define the ansible shim. It seems like this problem has been addressed in asdf itself so I'll take a look to see what we can do in this plugin.

In the meantime, you might want to try asdf-direnv. It allows you to bypass shims entirely. I tested it out in my setup and I was able to get ansible-base and ansible-core installed side by side without needing to reshim.

okamos commented 2 years ago

@amrox Awesome!! asdf-direnv works completely for me.

okamoto_shinichi[aws-oisixradaichi-infra] asdf direnv shell ansible-base 2.10.17
direnv: using asdf ansible-base 2.10.17
okamoto_shinichi[aws-oisixradaichi-infra] ansible --version
ansible 2.10.17
  config file = None
  configured module search path = ['/Users/okamoto_shinichi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/okamoto_shinichi/.asdf/installs/ansible-base/2.10.17/venv/lib/python3.10/site-packages/ansible
  executable location = /Users/okamoto_shinichi/.asdf/installs/ansible-base/2.10.17/bin/ansible
  python version = 3.10.1 (main, Dec 23 2021, 17:57:48) [Clang 13.0.0 (clang-1300.0.27.3)]
okamoto_shinichi[aws-oisixradaichi-infra] asdf direnv shell ansible-core 2.12.4
direnv: using asdf ansible-core 2.12.4
okamoto_shinichi[aws-oisixradaichi-infra] ansible --version
ansible [core 2.12.4]
  config file = None
  configured module search path = ['/Users/okamoto_shinichi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/okamoto_shinichi/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/okamoto_shinichi/.asdf/installs/ansible-core/2.12.4/bin/ansible
  python version = 3.10.1 (main, Dec 23 2021, 17:57:48) [Clang 13.0.0 (clang-1300.0.27.3)]
  jinja version = 3.1.1
  libyaml = True