Yea, definitely running into a issue where the box was not up yet and ansible was trying to execute. That seems to be I fixed that. However it appears that my ansible section is not executing for some reason. Here is my Vagrantfile: Vagrant.configure("2") do |config| #config.vm.synced_folder "../data", "/vagrant_data" (1..NODE_COUNT).each do |index| config.vm.define "proxy0#{index}" do |subconfig| subconfig.ssh.private_key_path = ["/Users/jason/.ssh/vagrant", "~/.vagrant.d/insecure_private_key"] subconfig.vm.provision "file", source: "/Users/jason/.ssh/vagrant.pub", destination: "~/.ssh/authorized_keys" subconfig.ssh.insert_key = false #subconfig.ssh.username = "vagrant" #subconfig.ssh.password = "vagrant" #subconfig.ssh.insert_key = false subconfig.vm.provider "virtualbox" do |vb| vb.name = "proxy0#{index}" vb.memory = 1024 vb.cpus = 1 end subconfig.vm.box = PLUS_IMAGE subconfig.vm.hostname = "proxy0#{index}" subconfig.vm.network :private_network, ip: "172.16.10.#{index + 20}" subconfig.vm.network "forwarded_port", guest: 80, host: "#{HA_PORT_START + index}" subconfig.vm.network "forwarded_port", guest: 8080, host: "#{DASHBOARD + index}" subconfig.vm.provision "os-setup", :type => "shell", :path => "provisioners/scripts/os-setup.sh" subconfig.vm.provision "setup-hosts", :type => "shell", :path => "provisioners/scripts/setup-hosts.sh" do |s| s.args = ["enp0s8"] end
if config == NODE_COUNT config.vm.provision "ansible" do |ansible| #ansible.limit = "all" ansible.playbook = "./provisioners/ansible/mainplus.yml" ansible.inventory_path = "./provisioners/ansible/inventory" end end end end You can see I put the if statement below, but it does not seem to be triggering (I tried with and without the # in front of ansible.limit). Is that in the right place? I feel like its something small and i am very close. Thanks for the help. Jason On Wednesday, August 12, 2020 at 11:28:28 AM UTC-7 jason.wi...@gmail.com wrote: > Hmm, that would make sense. > Let me modify the vagrantfile and a little and respond with my latest > results > THanks for all the help! > > > > On Wednesday, August 12, 2020 at 8:31:22 AM UTC-7 dnmo...@gmail.com wrote: > >> I think the issue you are running into is that it's running the playbook >> before the VM has actually finished spinning up. If you look at my >> Vagrantfile, I actually wait to start running the playbooks after the last >> VM is created. >> >> if index == (itr.length-1) then >> config.vm.provision "ansible" do |ansible| >> ansible.limit = "plu1" >> ansible.playbook = "./playbook.yml" >> ansible.inventory_path = "inventory" >> ansible.raw_arguments = ["--flush-cache"] >> ansible.verbose = "-vvvv" >> end >> end >> >> On Wednesday, August 12, 2020 at 11:13:30 AM UTC-4, Jason Williams wrote: >> >>> Yea, the box comes up fine and the private key works, as it should, but >>> ansible fails when executing the playbook: >>> Here is the error output: >>> >>> ==> proxy01: Running provisioner: ansible... >>> proxy01: Running ansible-playbook... >>> >>> PLAY [all] >>> ********************************************************************* >>> >>> TASK [Gathering Facts] >>> ********************************************************* >>> fatal: [web02]: UNREACHABLE! => {"changed": false, "msg": "Failed to >>> connect to the host via ssh: ", "unreachable": true} >>> fatal: [proxy01]: UNREACHABLE! => {"changed": false, "msg": "Failed to >>> connect to the host via ssh: ssh: Could not resolve hostname proxy01: >>> nodename nor servname provided, or not known", "unreachable": true} >>> fatal: [proxy02]: UNREACHABLE! => {"changed": false, "msg": "Failed to >>> connect to the host via ssh: ssh: Could not resolve hostname proxy02: >>> nodename nor servname provided, or not known", "unreachable": true} >>> >>> Am I correct in assuming ansible reads ~/.ssh/config to SSH into the >>> vagrant box? >>> >>> Much obliged! >>> >>> >>> >>> >>> On Wed, Aug 12, 2020 at 8:09 AM D Morgan <dnmo...@gmail.com> wrote: >>> >> If you comment out these three lines does it work as expected? >>>> >>>> subconfig.ssh.private_key_path = ["/Users/jason/.ssh/vagrant", >>>> "~/.vagrant.d/insecure_private_key"] >>>> subconfig.vm.provision "file", source: "/Users/jason/.ssh/vagrant.pub", >>>> destination: "~/.ssh/authorized_keys" >>>> subconfig.ssh.insert_key = false >>>> >>>> >>>> >>>> On Wednesday, August 12, 2020 at 9:34:34 AM UTC-4, >>>> jason.wi...@gmail.com wrote: >>>>> >>>>> Hey folks. >>>>> Looking for some help on how to get my setup working correctly. >>>>> I can use ansible AFTER vagrant up is working, by running: >>>>> >>>>> vagrant ssh-config >> ~/.ssh/config >>>>> Now can read the file and SSH into the host and run the playbooks. >>>>> >>>>> How does that work when i am running ansilbe within vagrant up? Do you >>>>> need to add the hosts into ~/.ssh/config ahead of time? >>>>> Just looking for help on how to get this working properly >>>>> >>>>> Thanks >>>>> >>>> -- >>>> This mailing list is governed under the HashiCorp Community Guidelines >>>> - https://www.hashicorp.com/community-guidelines.html. Behavior in >>>> violation of those guidelines may result in your removal from this mailing >>>> list. >>>> >>>> GitHub Issues: https://github.com/hashicorp/vagrant/issues >>>> Discuss: https://discuss.hashicorp.com/c/vagrant/24 >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Vagrant" group. >>>> To unsubscribe from this topic, visit >>>> https://groups.google.com/d/topic/vagrant-up/LWuwDW97f04/unsubscribe. >>>> >>> To unsubscribe from this group and all its topics, send an email to >>>> vagra...@googlegroups.com. >>> >>> >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/vagrant-up/a09130c8-e73b-4f07-b945-3a7057269402o%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/vagrant-up/a09130c8-e73b-4f07-b945-3a7057269402o%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/hashicorp/vagrant/issues Discuss: https://discuss.hashicorp.com/c/vagrant/24 --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/28c567b2-9c1a-4f51-bb9b-49f9d49995cbn%40googlegroups.com.