-
-
Notifications
You must be signed in to change notification settings - Fork 641
Added file provisioner to Vagrantfile to copy know_hosts from host to… #234
Conversation
Cool 👍 |
@@ -63,6 +63,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |||
mount_options: synced_folder.include?('mount_options') ? synced_folder['mount_options'] : [] | |||
end | |||
|
|||
# Provision using file provisioner to add known_hosts from host to guest. | |||
config.vm.provision "file", source: "~/.ssh/known_hosts", destination: "~/.ssh/known_hosts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work correctly on Windows? I haven't used the file provisioner with a file that may or may not exist, so haven't seen the behavior if the file doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geerlingguy you are right, I haven't test it on Windows and I can guess it won't work on it. I can move it to an ansible task just tell me where you prefer to place it then I can check if the file exists or not.
@ravbaba - You could probably do something like the following, maybe inside # Copy over known_hosts.
- name: Check if known_hosts file is present.
stat: path=~/.ssh/known_hosts
register: known_hosts
connection: local
sudo: no
- name: Copy known_hosts file from host into Drupal VM.
copy:
src: ~/.ssh/known_hosts
dest: ~/.ssh/known_hosts
mode: 0644
sudo: no
when: known_hosts.stat.exists Please see if that works. If so, that's probably a little cleaner, and should work fine on Windows hosts. |
@geerlingguy - I am going to check it on ios and ubuntu if I find some time today and on Windows but during the weekend. Thank you for the example ;) |
1158ede
to
67379dd
Compare
@geerlingguy - I've just tested it on my mac and it works for me, I added some modification to your code so please let me know if you are ok with it. I added your code to my PR. |
I tested it on ubuntu and it works as well, didn't manage to test it on windows. |
@@ -61,6 +61,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |||
config.vm.provision "ansible" do |ansible| | |||
ansible.playbook = "#{dir}/provisioning/playbook.yml" | |||
ansible.sudo = true | |||
ansible.extra_vars = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration is not needed, as Ansible picks up any configuration from config.yml automatically.
PR #234: Copy known_hosts from host to VM.
@geerlingguy - sorry, I've just noticed your comments. Thank you for merging and cleaning up the PR. |
It copies know_hosts from host to VM so you are avoiding a message which you need to confirm when you are trying to connect first time via ssh with a particular host.