-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Improving installation of Bundler #217
Comments
Yeah, I was wondering the same but didn't have any idea how to solve the issue :/ |
@thbar thank you very much for filing this issue ❤️
You mean in the proposed PRs, don't you? I think this is indeed the way to go: Allow to optionally specify a Bundler version per Ruby. The probably tricky thing to implement: an optional "detailed" format for elements of the rvm1_rubies:
- 'ruby-2.7.1' # latest release of bundler (if rvm1_bundler_install is true)
- { ruby: '2.2.10', bundler: '1.17.3' } # install bundler v1.17.3 (if rvm1_bundler_install is true) In the same "spirit" of roles declaration in a play: - hosts: webservers
roles:
- common
- { role: foo_app_instance, dir: '/opt/a', app_port: 5000 }
- { role: foo_app_instance, dir: '/opt/b', app_port: 5001 } |
You welcome @gildegoma! Indeed I was concerned about PR merged too fast, and having to handle back compatibility & changes later.
Yes, this is what I meant indeed! I thought of exactly the Hash structure you are proposing, keeping backward compatibility with a single string too (but maybe not forever, time will tell). When you wrote I wonder also about:
Let's mull over that a bit. Maybe having #215 sorted out first will be a good thing, so we can write tests more easily to ensure we have backward compatibility here! |
I am closing the various related PRs for now. I noticed an extra bit of feedback which we can take into account to design a more complete solution:
We should make it easy to avoid the installation of bundler completely, in addition to what's already outlined above. |
@Kulgar has good thoughts on Slack related to another solution: the removal of installation of bundler from this role. I must verify on my end what this would mean, but it is probably a better solution actually. I'll let him comment here so we can discuss! |
So, yeah, I was mostly saying that maybe we shouldn't care about bundler within this rvm ansible role. We can easily handle bundler installation thanks to the ansible gem module. I already do that for almost all my ansible projects after I installed ruby through this rvm role and it works just fine. Here is an example of a task I created: - name: Ensure bundler gem is installed in right version (with some other gems)
tags:
- update-ruby
- update-gems
become_user: "{{ rvm_user }}"
gem:
name: "{{ item.name }}"
version: "{{ item.version }}"
user_install: no
with_items: "{{ base_gems }}"
# and the items:
base_gems:
- name: bundler
version: 1.17.3 In case you need to install bundler for a specific ruby version, I found this old issue: #46
That way, it would be totally possible to specify which ruby version we want to use to install the gem. Or if it is more convenient, a simple shell command doing: So... there are a lot of easy way to deal with your bundler installation yourself in your playbooks. I don't think rvm ansible should take care of that, because rvm ansible is a role to install RVM and rubies, not to install gems... I think it is best to rely on the official Ansible module for that part :-) I think it is best to let the devops deal with the bundler installation themselves and provide them with some documentations on how to do that within the readme or wiki of this ansible role, like : "how to install bundler for a specific ruby version?", or "how to install a gem for a specific gemset created in rvm", etc. What do you think? |
@Kulgar overall I feel letting the user install bundler is more flexible & powerful, compared to the attempts I pointed to. The only drawback is that what is described in #46 is not elegant at all. Maybe this could be solved with a bit of documentation or templates, though. I will have to play around with it in the coming weeks on client projects to figure out what I really prefer, personally! @gildegoma curious to have your opinion here. Both takes have drawbacks & advantages. Let us know what you think! |
I was mostly pointing to #46 to show different examples of what can be done. So it may be best to install bundler from the remote app folder where a .ruby-version is specified. So that bundler is installed in the right version for the right ruby version used by the app. |
I had the opportunity (thanks to clients needs) to practice more in that area over the last few weeks. I must say I still prefer to have bundler installed via Ansible in my cases (not by the application), but I do not use this role for that specific part anymore (I use My position would be at this point, based on what I know now:
The rationale behind that is after working in more depth on that topic, I believe it is hard to have a unique solution for everyone (well it could be found, with a lot more time & polish). For instance, in my cases, here is what I'm doing:
But other people would maybe use "default" flags, or uninstall some incorrect versions, or handle error logic differently. Thoughts? |
I have summarised my current solution in this article: https://thibautbarrere.com/2020/09/19/managing-bundler-and-rubygems-with-ansible |
I will close for now. I must add to my article that in some cases, for JRuby only, I must first remove an pre-existing bundler installation. I will share some code on demand here. |
Poke @rvm/ansible. I'm consolidating a couple of thoughts here as a basis for discussion.
No strong certainties here, mostly a brain dump at this point, and I could be wrong here or there!
There are a number of attempts to let someone specify the version of Bundler:
I believe we'll still have a couple of problems with those approaches:
It could be perfectly acceptable for now, but even if that's the case, more testing will be needed.
I'll do more testing & revisit this.
EDIT: if for some reason there is an "order problem" (like I believe I met in the past), we could resort to hooks like Ansistrano does, but I'm not sure at all it is necessary yet, just referencing that for completeness.
The text was updated successfully, but these errors were encountered: