[WIP] Add new provisioner: Ansible on the Guest VM#5340
[WIP] Add new provisioner: Ansible on the Guest VM#5340
Conversation
With this change, the existing host-based Ansible provisioner is refactored to share a maximum of code with this new guest-based Ansible provisioner. At this stage of development, the existing unit tests are intentionally modified as little as possible, to keep safe the existing funtionalities. Other issues resolved by this changeset: - Display a warning when running from a Windows host [GH-5292] - Don't show the ansible-command when VAGRANT_LOG is not defined and verbose option is disabled.
There was a problem hiding this comment.
The name ansible_local corresponds to Packer's ansible-local, but following underscore style used in Vagrant (e.g. chef_solo,...).
Note that this new provisioner is potentially able to also execute Ansible against remote machines (see the trick in ansible_local.html.md), and I personally would find a bit more correct to name it ansible_on_guest (or something similar). What do you think?
There was a problem hiding this comment.
The use of the term local in ansible_local is consistent with local-exec for vagrant push. (But obviously the naming schemes differ in other ways, such as - vs _ and whether local comes first or second.)
There was a problem hiding this comment.
We actually could add here a little notice to propose to use ansible_local provisioner instead...
|
You might also want to check the https://github.com/vovimayhem/vagrant-guest_ansible plugin which does roughly the same. Also this Gist might be helpful: |
CommandUnavailableWindows obviously inherits from CommandUnavailable!
|
Any update about merging this upstream? |
|
I think it's reasonable to leave out the Ansible auto install bit. Personally, I don't like that Vagrant installs crap in my VM in other situations. Any progress on getting this merged? I've had to basically use the shell provisioner to SSH into the VM and run the playbooks there. It's kind of a not-very-good process, and I'd love to use the legit ansible_local provisioner. I'd suggest changing the name, however. ansible_local could be construed to mean that Ansible will be run locally (i.e. on the host), as opposed to inside the guest VM. Perhaps |
|
Sorry, I have not time now to answer in details to all the above questions, but I try to address some parts below:
For the next steps:
PS: I might close this PR and start a new one, based on a new freshly rebased branch. I feel that some people have been using this branch to run self-patched version of Vagrant. If yes, please let us a not here and we won't delete this branch until this feature is officially released, thanks! |
|
@gildegoma, next Vagrant release will take many months, or maybe a year. Your plugin is incomplete, but it's already useful, even in its current state. Can you publish it as a standalone Vagrant plugin? That would allow my developers start using it right now, you'll get more feedback, and I will be able to help with pull requests. |
|
@mkuzmin I understand your point, but at the moment I unfortunately don't have time (i.e. no urgent need) to extract and maintain it as a plugin. By DRY'ing the code with the current So, meanwhile, I see the following variants (the first one is quite easy to setup actually):
Sorry for the delays! |
|
Closed in favour of #6500. |
|
Please note that the branch |
|
This is a friendly (pedantic) reminder: The |
@mitchellh @sethvargo Here is my attempt to implement #2103. My idea is to try to get it merged into 1.8 Milestone.
I created the branch directly in original repository, so that you can directly add things by your own (especially to quickly fix my English and Ruby mistakes, sorry in advance 😅). I am looking forward to receiving your comments 😀 !
The
ansible_localProvisioner (new feature)I'd be very thankful to the interested Vagrant users to check the current design and report as soon as possible if their needs wouldn't be satisfied, so we can adapt before this first release.
Note that the Ansible Installation Capability is already available for the following platforms (using the distribution package system (e.g. apt, yum, pacman, freebsd pkg, etc):
Open Questions
Discussed via code comments on this GitHub pull request.
Missing Features
The following functions are intentionally not developed in this initial version (but might be considered in future development iterations):
Automated installation of a specific Ansible version (e.g. via pip packaging).
Reasons: Lack of user feedback, experience to confirm this need. User still can build their own base box.
The
ansibleProvisionerBy keeping the existing unit test coverage almost unchanged, I'm quite confident that the refactored
ansibleprovisioner still behave the same (a.k.a free from new bugs!). I only added a few minor things that I hit on my coding path (Windows warning, and a buggy behavior whenVAGRANT_LOGis not defined).The Documentation
Many changes are also proposed here. I mainly tried to cut the things in four separate pages with the goal to help user to quickly find the relevant information:
ansibleprovisioner, with specific tips and tricksansible_localprovisioner, with specific tips and tricksLike for the code, I'm open to any other way to organize the things... just let me know what do you think.
Finalization Check-List
--no-coloroption to ansisble provisioner #5531, Allow Ansible provisioner to run reliably in parallel #5551, Impossible to hide ansible-playbook command details in console output #5803, Store the first SSH private key in generated Ansible inventory #5765, Fix invalid ini entry error when ansible_ssh_private_key_file contains spaces #6209, Absolutely force the Ansible remote (ssh) user to correspond to Vagrant ssh user #6348ansible_local, oransible_on_guest, or ...?TODOs (fix them or create new GitHub issues for later work)ansible_localcoverage, following http://betterspecs.org styling?)CHANGELOG entries