I have been using ansible more and more within my Vagrant builds. I have been able to get it working by using ansible after the vagrant boxes are up and running by executing ansible-playbook on the host, but also have been testing using ansible within my Vagrantfile.
I have one question though that I am trying to figure out.
Ansible will ssh into the hosts to run the plays/playbooks that I have specified. However, to my understanding, ansible will read the ~/.ssh/config file to know how to connect to the host. At the moment, this seems to be a bit of chicken and egg scenario.
What I mean is, i need to have the vagrant boxes information in the config file in order for the
vagrant up to run correctly and execute the playbooks i specify in the vagrantfile.
If the hosts are not in
config it fails because ansible cant connect to the host (they do not exisit in ssh/config)
My question is, can you some how dynamically populate the config file so ansible can SSH into the boxes?
otherwise, I have to bring up the environments without the playbook in the vagrant file, run vagrant ssh-config >> ~/.ssh/config. Then it would work moving forward.
But i’d like to see if there are any alternatives.
much obliged for the help!