Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ardhi Putra Pratama
teaching
Commits
1d7138b3
Commit
1d7138b3
authored
Jan 29, 2018
by
Ardhi Putra Pratama
Browse files
Add extra stuff on cluster management
parent
fa513508
Changes
2
Hide whitespace changes
Inline
Side-by-side
misc/Vagrantfile
0 → 100644
View file @
1d7138b3
require
'fileutils'
Vagrant
.
require_version
">= 1.6.0"
# Defaults for config options defined in CONFIG
$num_instances
=
3
$instance_name_prefix
=
"cl-ardhi"
$enable_serial_logging
=
false
$share_home
=
true
$vm_gui
=
false
$vm_memory
=
3072
$vm_cpus
=
2
$forwarded_ports
=
{}
# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if
ENV
[
"NUM_INSTANCES"
].
to_i
>
0
&&
ENV
[
"NUM_INSTANCES"
]
$num_instances
=
ENV
[
"NUM_INSTANCES"
].
to_i
end
def
vm_gui
$vb_gui
.
nil?
?
$vm_gui
:
$vb_gui
end
def
vm_memory
$vb_memory
.
nil?
?
$vm_memory
:
$vb_memory
end
def
vm_cpus
$vb_cpus
.
nil?
?
$vm_cpus
:
$vb_cpus
end
Vagrant
.
configure
(
"2"
)
do
|
config
|
# always use Vagrants insecure key
config
.
ssh
.
insert_key
=
false
config
.
vm
.
box
=
"ubuntu/xenial64"
# enable hostmanager
config
.
hostmanager
.
enabled
=
true
# configure the host's /etc/hosts
config
.
hostmanager
.
manage_host
=
true
(
1
..
$num_instances
).
each
do
|
i
|
config
.
vm
.
define
vm_name
=
"%s-%02d"
%
[
$instance_name_prefix
,
i
]
do
|
config
|
config
.
vm
.
hostname
=
vm_name
if
$enable_serial_logging
logdir
=
File
.
join
(
File
.
dirname
(
__FILE__
),
"log"
)
FileUtils
.
mkdir_p
(
logdir
)
serialFile
=
File
.
join
(
logdir
,
"%s-serial.txt"
%
vm_name
)
FileUtils
.
touch
(
serialFile
)
config
.
vm
.
provider
:virtualbox
do
|
vb
,
override
|
vb
.
customize
[
"modifyvm"
,
:id
,
"--uart1"
,
"0x3F8"
,
"4"
]
vb
.
customize
[
"modifyvm"
,
:id
,
"--uartmode1"
,
serialFile
]
end
end
$forwarded_ports
.
each
do
|
guest
,
host
|
config
.
vm
.
network
"forwarded_port"
,
guest:
guest
,
host:
host
,
auto_correct:
true
end
config
.
vm
.
provider
:virtualbox
do
|
vb
|
vb
.
gui
=
vm_gui
vb
.
memory
=
vm_memory
vb
.
cpus
=
vm_cpus
end
ip
=
"172.17.10.
#{
i
+
100
}
"
config
.
vm
.
network
:private_network
,
ip:
ip
end
end
end
misc/cluster_adduser-key.sh
0 → 100755
View file @
1d7138b3
#!/bin/bash
username
=
$1
password
=
$2
p_headnode
=
"PASSWORD HEAD"
u_headnode
=
"USERNAME HEAD"
hosts
=(
cluster01 cluster03 cluster04 cluster05 cluster06
)
# end of configuration
pass
=
$(
perl
-e
'print crypt($ARGV[0], "password")'
$password
)
mkdir
/var/mirror/user/
$username
for
hostname
in
${
hosts
[@]
}
do
ssh
-t
$u_headnode
@
$hostname
"echo
$p_headnode
| sudo -S useradd -m -p
$pass
-s /bin/bash
$username
;"
sshpass
-p
"
$password
"
ssh
-o
StrictHostKeyChecking
=
no
-t
$username
@
$hostname
"ssh-keygen -f /home/
$username
/.ssh/id_rsa -t rsa -N '';"
done
for
mehost
in
${
hosts
[@]
}
do
for
hostname
in
${
hosts
[@]
}
do
sshpass
-p
"
$password
"
ssh
-t
-o
"StrictHostKeyChecking no"
$username
@
$mehost
"sshpass -p
$password
ssh-copy-id -o 'StrictHostKeyChecking no'
$username
@
$hostname
"
done
done
echo
$p_headnode
|
sudo
-S
chown
-R
$username
:
$username
/var/mirror/user/
$username
exit
0
Write
Preview
Supports
Markdown
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