Vagrantfile setup to allow Ansible to SSH in

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a vagrantfile from a book about Ansible for Devops. The issue I have is that I can SSH into the servers but Ansible cannot. Here is my vagrantfile;
# -*- mode: ruby -*-
# vi: set ft=ruby
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration
config.vm.box = "geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.dev"
app.vm.network :private_network, ip: "192.168.60.4"
end
# Application server 2
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.dev"
app.vm.network :private_network, ip: "192.168.60.5"
end
# Database server
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.dev"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
And my Ansible hosts file;
# Application servers
[app]
192.168.60.4
192.168.60.5
# Database servers
[db]
192.168.60.6
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be appliedto all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
I know I can explicitly add ansible_ssh_port=2200 etc but I'd rather have it setup in the vagrantfile
ssh vagrant ansible
add a comment |Â
up vote
0
down vote
favorite
I have a vagrantfile from a book about Ansible for Devops. The issue I have is that I can SSH into the servers but Ansible cannot. Here is my vagrantfile;
# -*- mode: ruby -*-
# vi: set ft=ruby
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration
config.vm.box = "geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.dev"
app.vm.network :private_network, ip: "192.168.60.4"
end
# Application server 2
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.dev"
app.vm.network :private_network, ip: "192.168.60.5"
end
# Database server
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.dev"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
And my Ansible hosts file;
# Application servers
[app]
192.168.60.4
192.168.60.5
# Database servers
[db]
192.168.60.6
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be appliedto all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
I know I can explicitly add ansible_ssh_port=2200 etc but I'd rather have it setup in the vagrantfile
ssh vagrant ansible
See vagrantup.com/docs/vagrantfile/ssh_settings.html .config.ssh.port,config.ssh.hostand more.
â Valentin B
Oct 22 '17 at 9:44
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a vagrantfile from a book about Ansible for Devops. The issue I have is that I can SSH into the servers but Ansible cannot. Here is my vagrantfile;
# -*- mode: ruby -*-
# vi: set ft=ruby
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration
config.vm.box = "geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.dev"
app.vm.network :private_network, ip: "192.168.60.4"
end
# Application server 2
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.dev"
app.vm.network :private_network, ip: "192.168.60.5"
end
# Database server
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.dev"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
And my Ansible hosts file;
# Application servers
[app]
192.168.60.4
192.168.60.5
# Database servers
[db]
192.168.60.6
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be appliedto all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
I know I can explicitly add ansible_ssh_port=2200 etc but I'd rather have it setup in the vagrantfile
ssh vagrant ansible
I have a vagrantfile from a book about Ansible for Devops. The issue I have is that I can SSH into the servers but Ansible cannot. Here is my vagrantfile;
# -*- mode: ruby -*-
# vi: set ft=ruby
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration
config.vm.box = "geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.dev"
app.vm.network :private_network, ip: "192.168.60.4"
end
# Application server 2
config.vm.define "app2" do |app|
app.vm.hostname = "orc-app2.dev"
app.vm.network :private_network, ip: "192.168.60.5"
end
# Database server
config.vm.define "db" do |db|
db.vm.hostname = "orc-db.dev"
db.vm.network :private_network, ip: "192.168.60.6"
end
end
And my Ansible hosts file;
# Application servers
[app]
192.168.60.4
192.168.60.5
# Database servers
[db]
192.168.60.6
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be appliedto all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
I know I can explicitly add ansible_ssh_port=2200 etc but I'd rather have it setup in the vagrantfile
ssh vagrant ansible
asked Oct 22 '17 at 9:32
eekfonky
172417
172417
See vagrantup.com/docs/vagrantfile/ssh_settings.html .config.ssh.port,config.ssh.hostand more.
â Valentin B
Oct 22 '17 at 9:44
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11
add a comment |Â
See vagrantup.com/docs/vagrantfile/ssh_settings.html .config.ssh.port,config.ssh.hostand more.
â Valentin B
Oct 22 '17 at 9:44
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11
See vagrantup.com/docs/vagrantfile/ssh_settings.html .
config.ssh.port, config.ssh.host and more.â Valentin B
Oct 22 '17 at 9:44
See vagrantup.com/docs/vagrantfile/ssh_settings.html .
config.ssh.port, config.ssh.host and more.â Valentin B
Oct 22 '17 at 9:44
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
You are using an ssh key to authenticate ansible, and as such you configure in vagrant a user with an ssh key, as in:
config.ssh.insert_key = true
config.ssh.username = "deploy-user"
config.ssh.private_key_path = "shared/deploy-user.pem"
I also advise the ssh user not to be root, but a user with sudo capabilities when in a production setting.
The other alternative is to put the ansible user rsa private/public key by hand in a newly provisioned system. The place is ~ansible_user/.ssh/authorized_keys
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You are using an ssh key to authenticate ansible, and as such you configure in vagrant a user with an ssh key, as in:
config.ssh.insert_key = true
config.ssh.username = "deploy-user"
config.ssh.private_key_path = "shared/deploy-user.pem"
I also advise the ssh user not to be root, but a user with sudo capabilities when in a production setting.
The other alternative is to put the ansible user rsa private/public key by hand in a newly provisioned system. The place is ~ansible_user/.ssh/authorized_keys
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
add a comment |Â
up vote
1
down vote
You are using an ssh key to authenticate ansible, and as such you configure in vagrant a user with an ssh key, as in:
config.ssh.insert_key = true
config.ssh.username = "deploy-user"
config.ssh.private_key_path = "shared/deploy-user.pem"
I also advise the ssh user not to be root, but a user with sudo capabilities when in a production setting.
The other alternative is to put the ansible user rsa private/public key by hand in a newly provisioned system. The place is ~ansible_user/.ssh/authorized_keys
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You are using an ssh key to authenticate ansible, and as such you configure in vagrant a user with an ssh key, as in:
config.ssh.insert_key = true
config.ssh.username = "deploy-user"
config.ssh.private_key_path = "shared/deploy-user.pem"
I also advise the ssh user not to be root, but a user with sudo capabilities when in a production setting.
The other alternative is to put the ansible user rsa private/public key by hand in a newly provisioned system. The place is ~ansible_user/.ssh/authorized_keys
You are using an ssh key to authenticate ansible, and as such you configure in vagrant a user with an ssh key, as in:
config.ssh.insert_key = true
config.ssh.username = "deploy-user"
config.ssh.private_key_path = "shared/deploy-user.pem"
I also advise the ssh user not to be root, but a user with sudo capabilities when in a production setting.
The other alternative is to put the ansible user rsa private/public key by hand in a newly provisioned system. The place is ~ansible_user/.ssh/authorized_keys
edited Oct 22 '17 at 10:29
answered Oct 22 '17 at 10:17
Rui F Ribeiro
36.1k1271114
36.1k1271114
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
add a comment |Â
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
I have something like that in the etc/ansible/hosts file
â eekfonky
Oct 22 '17 at 10:21
1
1
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
@eekfonky Of course you have, but that is on ansible side. The system being provisioned has to have the SSH ansible public key there for ansible to be able to login.
â Rui F Ribeiro
Oct 22 '17 at 10:32
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f399677%2fvagrantfile-setup-to-allow-ansible-to-ssh-in%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
See vagrantup.com/docs/vagrantfile/ssh_settings.html .
config.ssh.port,config.ssh.hostand more.â Valentin B
Oct 22 '17 at 9:44
I did see them, but I'm unsure of the parameters
â eekfonky
Oct 22 '17 at 9:48
Here is an example gist.github.com/franciscotfmc/9517513d0e185eca5b2247f17d913004
â Valentin B
Oct 22 '17 at 9:52
Please note that you are using a key in ansible, and in vagrant you have config.ssh.insert_key=false
â Rui F Ribeiro
Oct 22 '17 at 10:11