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

ansible_local's pip installer has a hardcoded curl get_pip.py piped to python #9584

Closed
chadswen opened this issue Mar 16, 2018 · 5 comments · Fixed by #10625
Closed

ansible_local's pip installer has a hardcoded curl get_pip.py piped to python #9584

chadswen opened this issue Mar 16, 2018 · 5 comments · Fixed by #10625

Comments

@chadswen
Copy link

chadswen commented Mar 16, 2018

When the ansible_local provisioner configures ansible.install_mode = pip this command is invoked:

machine.communicate.execute "curl https://bootstrap.pypa.io/get-pip.py | sudo python"

Piping curl into python with a static command prevents me from setting get_pip.py args. In my case I need to set a proxy, but I don't want to set a proxy for the entire provisioner as that causes issues when running certain playbooks. As far as I can tell there's no way to set a proxy for only the ansible install phase of the provisioner.

As a workaround, I use a shell provisioner to install pip manually with my custom get_pip.py args before ansible_local runs, but I still have to wait for ansible_local's static curl | python command to timeout on every install which is fairly annoying. I would use the package manger ansible install_mode, but my ansible playbooks require specific ansible versions and you can only target an ansible version with the pip install_mode.

Vagrant version

Vagrant 2.0.2

@chadswen chadswen changed the title pip installer has a hardcoded curl get_pip.py piped to python ansible_local's pip installer has a hardcoded curl get_pip.py piped to python Mar 16, 2018
@gildegoma
Copy link
Collaborator

gildegoma commented Mar 19, 2018

@chadswen Thank you for reporting this use case. The (Ansible) provisioners are not aiming at supporting any use case, and for "advanced/complex" situations we try to find the adequate balance (code complexity, ROI, Vagrant flexibility for customization, etc.).

In my case I need to set a proxy, but I don't want to set a proxy for the entire provisioner as that causes issues when running certain playbooks.

Running behind a proxy is typically subject to variance and somehow hard to fully cover by relying on standard configuration capabilities (for instance the Docker provisioner also installs with hardcoded curl commands).

So, you did the right thing with implementing your own ansible setup via a shell provisioner:

As a workaround, I use a shell provisioner to install pip manually with my custom get_pip.py args before ansible_local runs, but I still have to wait for ansible_local's static curl | python command to timeout on every install which is fairly annoying.

Now, to avoid this useless and annoying wait, you can extend your shell provisioner to also install ansible, and then configure the ansible_local provisioner to not install ansible by setting the install option to false. The provisioner will then only verify that the expected version is available.

Please let me know if this solution works for you and if you agree to close this issue (i.e. no feature request). Thanks!

@chadswen
Copy link
Author

chadswen commented Mar 19, 2018

@gildegoma I'd hate to stop using the ansible installer. It installs the specific version of ansible as required by my playbook and that feature saves me from rewriting a fair amount of code with a shell provisioner.

My only problem is that there is no way to set args when ansible_local installs pip before it installs ansible. I can set args just fine when it installs ansible using ansible.pip_args, but the curl | python command I linked from the OP is hardcoded to always pull from the internet without any configuration options for how that is done.

@gildegoma
Copy link
Collaborator

gildegoma commented Mar 20, 2018

The issue is quite clear to me, and I do appreciate that the existing features are used ;-)

that feature saves me from rewriting a fair amount of code with a shell provisioner

I guess it shouldn't be that large (e.g. pip install ...), but I ear your "frustration" to be so close from the goal without having a hook to catch.

@chadswen what would be your proposal to resolve this?

I would propose to introduce a new pip_install_command option, with
"curl https://bootstrap.pypa.io/get-pip.py | sudo python" as default.
What do you think? Interested to work on it?

@chadswen
Copy link
Author

@gildegoma That solution would work quite well. I can't volunteer to work on it right now, but perhaps in the future if it isn't picked up.

Thanks!

@gildegoma gildegoma added this to the Secondary milestone Mar 21, 2018
vdebroy added a commit to vdebroy/vagrant that referenced this issue Jan 28, 2019
gitebra pushed a commit to gitebra/vagrant that referenced this issue Apr 10, 2019
* commit 'cd3909d7cede3a58a2b3439add3f8cb53a770919':
  Update CHANGELOG
  Update CHANGELOG
  Update CHANGELOG
  Move up doc string for `vagrant snapshot pop`
  Ensure non-existent machines do not attempt to list snapshots
  Do not rely on IPAddr#prefix as it's not available on older rubies
  Update guest capabilities for coreos
  Fixing bug I introduced. Thanks @chrisroberts!
  Updated based on recommended changes per review.
  Updated documentation. Fixes hashicorp#9584.
  Handling the cases for UNSET_VALUE, i.e., config is not finalized.
  Config has pip_install_cmd for Provisioner to pick it up. Tests updated.
  Ubuntu code updated because it calls Debian code.
  Exposing pip_install_cmd to callers as optional.
  Handling empty strings passed as pip_install_command.
  Adding pip_install_cmd as a default parameter to get_pip. Unit Tests.
@gildegoma gildegoma modified the milestones: Secondary, 2.2.5 Dec 1, 2019
@ghost
Copy link

ghost commented Jan 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants