简体   繁体   中英

Vagrant and ansible & ssh

I'm following a few tutorials to learn vagrant and ansible. I get to a point in a tutorial where I have an inventory file of boxes that it will supposedly provision for me:

[loadbalancer]
lb01

[webserver]
app01
app02

[database]
db01

[control]
control ansible_connection=local

Please correct me where I'm wrong, but I think I should have setup the authorized_keys file for each of these machines manually by using "Vagrant up", followed by "vagrant ssh lb01" and placing my public key manually in authorized_keys. Or is there a quicker way to do this part? I certainly hope so.

Thanks! Mike

If you are using Vagrant, you can use the ansible provisioner.

  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
  end

Vagrant takes care of setting up the inventory file and the related SSH private keys for you.

If you do want to see what inventory file has been generated, you can find that at

.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM