Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
terraform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
702
HADOOP
terraform
Commits
b69bdee8
Commit
b69bdee8
authored
4 years ago
by
František Dvořák
Browse files
Options
Downloads
Patches
Plain Diff
Remote deployment
* no frontend node * only launcher in the terraform
parent
d87ddb0a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
deploy.tf
+12
-4
12 additions, 4 deletions
deploy.tf
orchestrate.py
+12
-29
12 additions, 29 deletions
orchestrate.py
with
24 additions
and
33 deletions
deploy.tf
+
12
−
4
View file @
b69bdee8
...
...
@@ -118,6 +118,7 @@ bootcmd:
-
cloud-init-per
once
manifests-dir
mkdir
-
p
/
etc
/
puppet
/
code
/
environments
/
production
/
manifests
packages
:
-
ansible
-
puppet-master
puppet
:
...
...
@@ -141,6 +142,9 @@ write_files:
bootcmd
:
-
cloud-init-per
once
puppet-start
systemctl
mask
puppet
packages
:
-
ansible
puppet
:
conf
:
agent
:
...
...
@@ -229,11 +233,15 @@ eval $(ssh-agent -s)
trap
"kill
$
SSH_AGENT_PID"
INT
TERM
ssh-add
$
{
local_file
.
localkey
.
filename
}
ip
=
$
{
openstack_compute_floatingip_associate_v2
.
server-fip-1
.
floating_ip
}
remote
=
"ssh -o PreferredAuthentications=publickey deployadm@
$
ip"
while
!
ping
-
c
1
-
i
2
-
q
$ip
;
do
sleep
5
;
done
ssh-keygen
-
R
$ip
while
!
$remote
-
o
ConnectTimeout
=
5
-
o
StrictHostKeyChecking
=
no
:
;
do
sleep
5
;
done
if
[
-
z
"
$
NO_DEPLOYMENT"
]
;
then
./
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
else
./
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
files
ping
init
wait
.
/
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
-
n
deployment
git
archive
HEAD
|
$remote
'rm -rf terraform; mkdir terraform; cd terraform; tar x'
scp
-
o
PreferredAuthentications
=
publickey
-
p
$
{
local_file
.
output
.
filename
}
deployadm
@
$ip
:
~
/
terraform
/
$remote
-
o
ForwardAgent
=
yes
"cd terraform; SENSITIVE=
$
SENSITIVE ./orchestrate.py -c
${
local_file
.
output
.
filename
}
"
fi
kill
$SSH_AGENT_PID
...
...
This diff is collapsed.
Click to expand it.
orchestrate.py
+
12
−
29
View file @
b69bdee8
...
...
@@ -130,14 +130,13 @@ ff02::2 ip6-allrouters
[all:vars]
ansible_become=true
ansible_user=%s
ansible_ssh_common_args=
\'
%s -o ForwardAgent=yes -o ProxyCommand=
"
ssh -W {{ ansible_host }}:22 -q
\
{{ ansible_user }}@%s
"
\'
ansible_ssh_common_args=
\'
%s -o ForwardAgent=yes
\'
[masters]
%s ansible_host=%s
[nodes]
'''
%
(
user
,
args
.
ssh_opts
,
master_ip
,
master_hostname
,
hosts
[
master_hostname
]))
'''
%
(
user
,
args
.
ssh_opts
,
master_hostname
,
hosts
[
master_hostname
]))
for
h
,
ip
in
hosts
.
items
():
if
h
==
master_hostname
:
continue
...
...
@@ -148,19 +147,12 @@ ansible_ssh_common_args=\'%s -o ForwardAgent=yes -o ProxyCommand="ssh -W {{ ansi
if
'
ping
'
in
args
.
actions
:
print
(
'
== ping ==
'
,
flush
=
True
)
cmd
=
[
'
ping
'
,
'
-c
'
,
'
1
'
,
'
-i
'
,
'
2
'
,
'
-q
'
,
master_ip
]
perform_command
(
cmd
,
0
)
cmd
=
[
'
ssh-keygen
'
,
'
-R
'
,
master_ip
]
perform_command
(
cmd
)
cmd
=
ssh
+
[
'
-o
'
,
'
ConnectTimeout=5
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
'
:
'
]
perform_command
(
cmd
,
0
)
for
ip
in
hosts
.
values
():
cmd
=
ssh
+
[
'
%s@%s
'
%
(
user
,
master_ip
),
'
ping
'
,
'
-c
'
,
'
1
'
,
'
-i
'
,
'
2
'
,
'
-q
'
,
ip
]
cmd
=
[
'
ping
'
,
'
-c
'
,
'
1
'
,
'
-i
'
,
'
2
'
,
'
-q
'
,
ip
]
perform_command
(
cmd
,
0
)
for
ip
in
hosts
.
values
():
remote_cmd
=
'
'
.
join
(
ssh
)
+
'
-o
ConnectTimeout=5
-o
StrictHostKeyChecking=no
%s :
'
%
ip
cmd
=
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
remote_cmd
]
cmd
=
ssh
+
[
'
-o
'
,
'
ConnectTimeout=5
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
ip
),
'
:
'
]
perform_command
(
cmd
,
0
)
if
component
:
component
.
action
(
'
ping
'
)
...
...
@@ -171,27 +163,19 @@ if 'init' in args.actions:
h
=
list
(
hosts
.
keys
())
+
[
'
%s.%s.
'
%
(
host
,
d
)
for
host
in
hosts
.
keys
()]
+
\
[
'
%s.%s
'
%
(
host
,
d
)
for
host
in
hosts
.
keys
()]
+
list
(
hosts
.
values
())
cycle_all
=
(
'
echo -n At:; uname -n; for h in %s; do
'
%
'
'
.
join
(
h
))
+
'
'
.
join
(
ssh
)
\
+
'
-o StrictHostKeyChecking=no $h :; done
'
commands
=
[
[
'
scp
'
,
'
-p
'
,
'
hosts
'
,
'
%s@%s:/tmp/
'
%
(
user
,
master_ip
)],
ssh
+
[
'
%s@%s
'
%
(
user
,
master_ip
),
'
sudo mv -v /tmp/hosts /etc/hosts
'
],
# the frontend to all nodes
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
cycle_all
]
[
'
sudo
'
,
'
cp
'
,
'
-vp
'
,
'
hosts
'
,
'
/etc/hosts
'
],
]
for
ip
in
hosts
.
values
():
# check the special case if it is not already frontend ('ssh-keygen -R' would be a problem)
if
ip
==
master_ip
:
continue
# the frontend to all nodes
for
i
in
h
:
commands
+=
[
[
'
ssh-keygen
'
,
'
-R
'
,
ip
],
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
-o
'
,
'
ProxyCommand=ssh -W %s:22 -q %s@%s
'
%
(
ip
,
user
,
master_ip
),
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
ip
),
'
:
'
]
ssh
+
[
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
i
),
'
:
'
],
]
commands
+=
[
[
'
ansible
'
,
'
-i
'
,
'
./inventory
'
,
'
-m
'
,
'
copy
'
,
'
-a
'
,
'
src=hosts dest=/etc/hosts
'
,
'
nodes
'
],
]
cycle_all
=
(
'
echo -n At:; uname -n; for h in %s; do
'
%
'
'
.
join
(
h
))
+
'
'
.
join
(
ssh
)
\
+
'
-o StrictHostKeyChecking=no %s@$h :; done
'
%
user
# node to node ssh keys
# (after the /etc/hosts is distributed)
for
node
in
hosts
.
keys
():
...
...
@@ -200,8 +184,7 @@ if 'init' in args.actions:
continue
# the node to all nodes
commands
+=
[
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
'
'
.
join
(
ssh
)
+
'
-o ForwardAgent=yes %s
\'
%s
\'
'
%
(
'
%s.%s
'
%
(
node
,
d
),
cycle_all
)],
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s.%s
'
%
(
node
,
d
),
'
%s
'
%
cycle_all
],
]
perform_action
(
'
init
'
,
commands
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment