Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
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
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
702
HADOOP
terraform
Commits
b69bdee8
Commit
b69bdee8
authored
Mar 23, 2021
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:
...
@@ -118,6 +118,7 @@ bootcmd:
-
cloud-init-per
once
manifests-dir
mkdir
-
p
/
etc
/
puppet
/
code
/
environments
/
production
/
manifests
-
cloud-init-per
once
manifests-dir
mkdir
-
p
/
etc
/
puppet
/
code
/
environments
/
production
/
manifests
packages
:
packages
:
-
ansible
-
puppet-master
-
puppet-master
puppet
:
puppet
:
...
@@ -141,6 +142,9 @@ write_files:
...
@@ -141,6 +142,9 @@ write_files:
bootcmd
:
bootcmd
:
-
cloud-init-per
once
puppet-start
systemctl
mask
puppet
-
cloud-init-per
once
puppet-start
systemctl
mask
puppet
packages
:
-
ansible
puppet
:
puppet
:
conf
:
conf
:
agent
:
agent
:
...
@@ -229,11 +233,15 @@ eval $(ssh-agent -s)
...
@@ -229,11 +233,15 @@ eval $(ssh-agent -s)
trap
"kill
$
SSH_AGENT_PID"
INT
TERM
trap
"kill
$
SSH_AGENT_PID"
INT
TERM
ssh-add
$
{
local_file
.
localkey
.
filename
}
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
if
[
-
z
"
$
NO_DEPLOYMENT"
]
;
then
./
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
git
archive
HEAD
|
$remote
'rm -rf terraform; mkdir terraform; cd terraform; tar x'
else
scp
-
o
PreferredAuthentications
=
publickey
-
p
$
{
local_file
.
output
.
filename
}
deployadm
@
$ip
:
~
/
terraform
/
./
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
files
ping
init
wait
$remote
-
o
ForwardAgent
=
yes
"cd terraform; SENSITIVE=
$
SENSITIVE ./orchestrate.py -c
${
local_file
.
output
.
filename
}
"
.
/
orchestrate
.
py
-
c
$
{
local_file
.
output
.
filename
}
-
n
deployment
fi
fi
kill
$SSH_AGENT_PID
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
...
@@ -130,14 +130,13 @@ ff02::2 ip6-allrouters
[all:vars]
[all:vars]
ansible_become=true
ansible_become=true
ansible_user=%s
ansible_user=%s
ansible_ssh_common_args=
\'
%s -o ForwardAgent=yes -o ProxyCommand=
"
ssh -W {{ ansible_host }}:22 -q
\
ansible_ssh_common_args=
\'
%s -o ForwardAgent=yes
\'
{{ ansible_user }}@%s
"
\'
[masters]
[masters]
%s ansible_host=%s
%s ansible_host=%s
[nodes]
[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
():
for
h
,
ip
in
hosts
.
items
():
if
h
==
master_hostname
:
if
h
==
master_hostname
:
continue
continue
...
@@ -148,19 +147,12 @@ ansible_ssh_common_args=\'%s -o ForwardAgent=yes -o ProxyCommand="ssh -W {{ ansi
...
@@ -148,19 +147,12 @@ ansible_ssh_common_args=\'%s -o ForwardAgent=yes -o ProxyCommand="ssh -W {{ ansi
if
'
ping
'
in
args
.
actions
:
if
'
ping
'
in
args
.
actions
:
print
(
'
== ping ==
'
,
flush
=
True
)
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
():
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
)
perform_command
(
cmd
,
0
)
for
ip
in
hosts
.
values
():
for
ip
in
hosts
.
values
():
remote_cmd
=
'
'
.
join
(
ssh
)
+
'
-o
ConnectTimeout=5
-o
StrictHostKeyChecking=no
%s :
'
%
ip
cmd
=
ssh
+
[
'
-o
'
,
'
ConnectTimeout=5
'
,
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
cmd
=
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
remote_cmd
]
'
%s@%s
'
%
(
user
,
ip
),
'
:
'
]
perform_command
(
cmd
,
0
)
perform_command
(
cmd
,
0
)
if
component
:
if
component
:
component
.
action
(
'
ping
'
)
component
.
action
(
'
ping
'
)
...
@@ -171,27 +163,19 @@ if 'init' in args.actions:
...
@@ -171,27 +163,19 @@ if 'init' in args.actions:
h
=
list
(
hosts
.
keys
())
+
[
'
%s.%s.
'
%
(
host
,
d
)
for
host
in
hosts
.
keys
()]
+
\
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
())
[
'
%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
=
[
commands
=
[
[
'
scp
'
,
'
-p
'
,
'
hosts
'
,
'
%s@%s:/tmp/
'
%
(
user
,
master_ip
)],
[
'
sudo
'
,
'
cp
'
,
'
-vp
'
,
'
hosts
'
,
'
/etc/hosts
'
],
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
]
]
]
for
ip
in
hosts
.
values
():
# the frontend to all nodes
# check the special case if it is not already frontend ('ssh-keygen -R' would be a problem)
for
i
in
h
:
if
ip
==
master_ip
:
continue
commands
+=
[
commands
+=
[
[
'
ssh-keygen
'
,
'
-R
'
,
ip
],
ssh
+
[
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
i
),
'
:
'
],
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
-o
'
,
'
ProxyCommand=ssh -W %s:22 -q %s@%s
'
%
(
ip
,
user
,
master_ip
),
'
-o
'
,
'
StrictHostKeyChecking=no
'
,
'
%s@%s
'
%
(
user
,
ip
),
'
:
'
]
]
]
commands
+=
[
commands
+=
[
[
'
ansible
'
,
'
-i
'
,
'
./inventory
'
,
'
-m
'
,
'
copy
'
,
'
-a
'
,
'
src=hosts dest=/etc/hosts
'
,
'
nodes
'
],
[
'
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
# node to node ssh keys
# (after the /etc/hosts is distributed)
# (after the /etc/hosts is distributed)
for
node
in
hosts
.
keys
():
for
node
in
hosts
.
keys
():
...
@@ -200,8 +184,7 @@ if 'init' in args.actions:
...
@@ -200,8 +184,7 @@ if 'init' in args.actions:
continue
continue
# the node to all nodes
# the node to all nodes
commands
+=
[
commands
+=
[
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s@%s
'
%
(
user
,
master_ip
),
'
'
.
join
(
ssh
)
ssh
+
[
'
-o
'
,
'
ForwardAgent=yes
'
,
'
%s.%s
'
%
(
node
,
d
),
'
%s
'
%
cycle_all
],
+
'
-o ForwardAgent=yes %s
\'
%s
\'
'
%
(
'
%s.%s
'
%
(
node
,
d
),
cycle_all
)],
]
]
perform_action
(
'
init
'
,
commands
)
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
sign in
to comment