My Vagrantfile includes an instruction to do Ansible provisioning. Vagrant neatly generates an ansible inventory file in .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory , but it does not include ansible_ssh_private_key_file instructions for each host:
host-1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200 host-2 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2201 otherhost-1-1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2202 The consequence is that I can not control them with ansible-playbook directly, as vagrant sets different private keys for each hosts so even ansible-playbook --private-key $MYFILE -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory site.yml would not work. What does work is modifying the generated file: host-1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200 ansible_ssh_private_key_file=.vagrant/machines/host-1/virtualbox/private_key host-2 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2201 ansible_ssh_private_key_file=.vagrant/machines/host-2/virtualbox/private_key otherhost-1-1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2202 ansible_ssh_private_key_file=.vagrant/machines/otherhost-1-1/virtualbox/private_key Main question: How can I let vagrant specify this explicitly for ansible, in the generated inventory file, so that ansible can be run independently? Second I actually tried to make Vagrant include per-host (and per-group) variables in the generated inventory file -- for this and other purposes -- but this seems not possible: https://docs.vagrantup.com/v2/provisioning/ansible.html says "Group variables are intentionally not supported, as this practice is not recommended." . If anyone can explain me why this is not recommended, I'm curious. Because the Ansible documentation does not mention this, and happily describes how to use group variables (also in inventory files). Thanks in advance, Eric -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
