Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
John-Paul Robinson
ohpc_vagrant
Commits
b3e0d494
Commit
b3e0d494
authored
Jan 08, 2019
by
John-Paul Robinson
Browse files
Merge branch 'louistw/ohpc_vagrant-feat-copy-ssh-key-to-vm'
parents
de6527d2
6e6fc44f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Vagrantfile
View file @
b3e0d494
...
...
@@ -3,6 +3,9 @@
Vagrant
.
configure
(
"2"
)
do
|
config
|
# don't configure host-specific keys, config will use the user's key
config
.
ssh
.
insert_key
=
false
config
.
vm
.
define
"ohpc"
do
|
ohpc
|
ohpc
.
vm
.
box
=
"ravi89/centos7.5"
ohpc
.
vm
.
box_version
=
"1"
...
...
@@ -22,12 +25,23 @@ Vagrant.configure("2") do |config|
auto_correct:
true
end
config
.
vm
.
provider
:virtualbox
do
|
vb
|
vb
.
customize
[
"modifyvm"
,
:id
,
"--natdnshostresolver1"
,
"on"
]
vb
.
memory
=
"2048"
end
# define user's key and insecure default
# insecure default is required for initial provisioning
config
.
ssh
.
private_key_path
=
[
"~/.ssh/id_rsa"
,
"~/.vagrant.d/insecure_private_key"
]
# append user's key to vagrant config to avoid overwrite of existing authorized_keys
# https://stackoverflow.com/a/31153912/8928529
config
.
vm
.
provision
"ssh_pub_key"
,
type:
"shell"
do
|
s
|
ssh_pub_key
=
File
.
readlines
(
"
#{
Dir
.
home
}
/.ssh/id_rsa.pub"
).
first
.
strip
s
.
inline
=
<<-
SHELL
echo
#{
ssh_pub_key
}
>> /home/vagrant/.ssh/authorized_keys
SHELL
end
config
.
vm
.
provision
"shell"
,
inline:
<<-
SHELL
if [ -f /vagrant/localenv.sh ]; then
. /vagrant/localenv.sh
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment