-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Support Ansible “Local Playbooks” #2103
Comments
/cc @commandtab |
+1 for this |
Fixing this would allow running vagrant with ansible on Windows (#1946) which is always useful for cross-platform collaboration. It's an issue for us as we're collaborating with a freelancer on a project and we can't get him set up yet. I'm trying to think about a workaround using the shell provisioner, but it's a bit irritating. For the feature, I think it would be nice if it were switchable, like the multiple modes of Puppet and Chef. |
I am working on a plugin for this to execute playbook directly in the vm with |
I start writing the plugin |
I agree that this feature request makes a lot of sense! @jaugustin are you interested to work on adding this functionality to the main Ansible provisioner? |
@gildegoma If someone askme I can work on it :) |
In my opinion, pull request for this should absolutely be accepted. As already said above, @mitchellh confirm? First, it would be great to plot the expected architecture for such "multiple transport" support. Below a few thoughts... Many thanks in advance for your review. Considering that many Nice to have: optionally bootstrap Ansible installation on the target VM. Though this one could be done independently, maybe later in a following iteration. |
👍 Specially on windows, which ansible does not support as a control machine. |
/cc @gildegoma - Does Ansible support multiple private keys? Vagrant now does, so this isn't exactly safe.
Yes, this sounds great. :) |
FYI: I've started to work on this feature request and plan to a open pull request in the next weeks... About the design: it will be only one Ansible provisioner, with two possible
|
Sorry for the delay, but I first want to introduce the specs (#3287). It still on my roadmap though! |
I've been using https://github.com/geerlingguy/JJG-Ansible-Windows for running playbooks from within Windows machines, and it seems to work well for either Cygwin or PowerShell-based installs. The only thing that doesn't seem to work that great is terminal colors coming through Cygwin... but that's a small thing. I'd love to see official support, though! |
Huge 👍 for this ! And packer is doing the local provisioning with ansible. |
+1 |
Any update on this? |
My work in progress is available at https://github.com/gildegoma/vagrant/commits/ansible-on-guest (be aware that this branch might be rebased in the future to be kept "merge compatible" with upstream master). In the current stage, the local (or guest-based) provisioning already works fine, but code, unit tests and docs are unfortunately not enough mature to be proposed as pull request yet. Before starting to "finalize" this (hum, see all the trailing TODOs), I first need to validate some central points, and be sure that the current direction is good:
I am sorry, but at the moment I am lacking of time to further work on all of this, and for that reason I could not ping @mitchellh to make this "intermediate" review. I'll keep you informed, but if someone is interested in helping to accelerate this development, please announce you! You're welcome and I'd be happy to pair/delegate so we can get it in "sooner"! And as always, ❤️ to your thoughts and feedbacks! For people interested to give a try to the current code, something like that can be used: Vagrant.configure("2") do |config|
config.vm.define 'machine1' do |machine|
machine.vm.box = 'ubuntu/trusty64'
machine.vm.hostname = 'machine1'
# Install ansible on the target VM
machine.vm.provision :shell, :inline => <<EOS
set -e
if ! command -V ansible-playbook >/dev/null 2>/dev/null; then
sudo apt-get update -qq
sudo apt-get install -qq ansible
fi
EOS
# run ansible from the guest VM
machine.vm.provision 'ansible-local' do |ansible|
ansible.playbook = "your-playbook.yml"
end
end
end |
@gildegoma awesome work ! I would help but ruby is not on my "known languages" list right now. |
Would love to see this integrated. 👍 |
Vagrantfile # Install ansible at remote host.
config.vm.provision "shell", path: "provisioning/init.sh", keep_color: true
# Copy ansible playbook to guest machine
config.vm.provision "file", source: "provisioning/guest/inventory", destination: "/home/vagrant/inventory"
config.vm.provision "file", source: "provisioning/guest/playbook.yml", destination: "/home/vagrant/playbook.yml"
# Run it!!!
config.vm.provision "shell",
path: "provisioning/ansible.sh",
keep_color: true init.sh #!/bin/sh
sudo apt-get -yq install software-properties-common
sudo apt-add-repository -y ppa:ansible/ansible
sudo apt-get -yq update
sudo apt-get -yq install ansible
sudo apt-get -yq install python-mysqldb
sudo apt-get -yq install libnotify-bin ansible.sh #!/bin/sh
sudo ansible-playbook -i /home/vagrant/inventory /home/vagrant/playbook.yml playbook.yml ---
# This playbook will be executed at guest host.
- hosts: 127.0.0.1
connection: local
gather_facts: no
tasks:
-name: ... The only issue is ansible output has no echo till the end of full process. |
Hello Guys! Please have a look at #5340, and let us know if it would meet your needs (or not) 😄 |
This is great news! Thank you for this work, that's really a big feature. |
This is looking awesome! I didn't have a chance to test locally yet, but glanced through the proposed workflow and it makes sense to me—I especially like that it basically mirrors Packer's usage/terminology, making the metal shift from Packer->Vagrant->Packer less annoying :) |
@mkuzmin Thanks for jumping into testing it so quickly :) Please keep us informed if you hit any bug or trouble! Do you run it on Windows? @geerlingguy Thanks for your vote for Packer's terminology! Please let us know if you do some beta testing as well :) |
Yes, I have Windows on a host, and Ubuntu inside a box. |
I'm supporting PR /pull/5340, though I've got a simple question: why do we need a new provisioner? Can't we add a |
@warrenseine asked:
Warren, thanks for asking. I also initially thought about a single provisioner. But while working further on this feature, it turns out that splitting in two provisioners was (certainly) the best approach. The first reasons that lead to this decision were purely technical. But from the end-user perspective, I think that it also makes sense since the location of the Ansible control machine implies different capabilities and constraints. Here are the main reasons for this design:
Note that all the common stuff is stored in a shared codebase, and we'll take care to keep things clean with the upcoming additions ;-). I hope this answer your question... and I keep all ears to more ideas and critics! |
The arguments sound reasonable. Speaking on Ansible runtime installation, I have another feature request. Are you going to support |
@gildegoma Thanks for the detailed explanation. It makes sense. |
FYI: |
At the moment, the Ansible provisioner only supports running Ansible running over SSH. IMHO, this complicates the setup and requires Ansible on the host system (unlike the Puppet provisioner, for example).
Ansible supports running playbooks on localhost: http://www.ansibleworks.com/docs/playbooks2.html#id20
The text was updated successfully, but these errors were encountered: