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
fec48847
Commit
fec48847
authored
4 years ago
by
František Dvořák
Browse files
Options
Downloads
Patches
Plain Diff
Hadoop: terraform recipe for machine generating Hadoop image
parent
d026a0a6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
image/imgen.tf
+143
-0
143 additions, 0 deletions
image/imgen.tf
with
143 additions
and
0 deletions
image/imgen.tf
0 → 100644
+
143
−
0
View file @
fec48847
#
# Terraform recipe for machine generating Hadoop image.
#
# Review variables before apply (*_network, ssh).
#
# Manual post steps:
#
# * tune security groups (not handled here)
# * copy in cloud credentials to ~debian/terraform/image/clouds.yaml
# * setup automatic image build and upload, something like:
#
# cd ~debian/terraform/image; rm -fv *.raw; ./build.sh && ./upload.sh *.raw debian-9-x86_64_hadoop_rc
#
provider
"openstack"
{
cloud
=
"openstack"
}
terraform
{
required_providers
{
openstack
=
{
source
=
"terraform-provider-openstack/openstack"
}
}
}
variable
"local_network"
{
description
=
"Local network name"
default
=
"group-project-network"
# default = "auto_allocated_network"
}
variable
"public_network"
{
description
=
"Public network name"
default
=
"public-muni-147-251-21-GROUP"
# default = "public-cesnet-78-128-250-PERSONAL"
}
variable
"ssh"
{
description
=
"SSH key name"
default
=
"openstack"
}
data
"template_cloudinit_config"
"ctx"
{
part
{
content
=
<<
EOT
#cloud-config
manage_etc_hosts
:
false
timezone
:
Europe
/
Prague
packages
:
-
cron-apt
-
fail2ban
-
rsync
-
wget
-
mc
-
git
-
openstack-debian-images
-
python-openstackclient
write_files
:
-
path
:
/
usr
/
local
/
sbin
/
set-hostname
.
sh
permissions
:
0755
content
:
|
#! /bin/sh
#
# script to set the hostname (except /etc/hosts)
#
if
[
-
z
"
$
1"
]
;
then
echo
"Usage:
$
0 HOSTNAME [DOMAIN]"
exit
0
fi
h
=
"
$
1"
d
=
"
$
2"
sed
-
e
"s/^
\(
manage_etc_hosts
\)
:.*/
\1
: False/"
-
i
/
etc
/
cloud
/
cloud
.
cfg
echo
"
$
h"
>
/
etc
/
hostname
hostname
"
$
h"
if
[
-
n
"
$
d"
]
;
then
domainname
"
$
d"
fi
line
=
"
$
h.
$
d
$
h.
$
d.
$
h"
ips
=
`
ip
address
show
scope
global
up
|
grep
'
\<
inet6
\?\>\s
'
|
awk
'{print
$
2}'
|
cut
-
d
'/'
-
f1
`
for
ip
in
$ips
;
do
echo
"
$
ip
$
line"
>>
/
etc
/
hosts
done
-
path
:
/
etc
/
cron-apt
/
action
.
d
/
9
-
upgrade
permissions
:
0644
content
:
|
-
q
-
q
dist-upgrade
-
path
:
/
etc
/
cron-apt
/
config
permissions
:
0644
content
:
|
#MAILTO=
MAILON
=
upgrade
RUNSEEP
=
1200
-
path
:
/
etc
/
fail2ban
/
jail
.
d
/
age
.
conf
permissions
:
0644
content
:
|
[
Definition
]
dbpurgeage
=
16
w
[
DEFAULT
]
bantime
=
8
w
runcmd
:
-
apt-get
purge
-
y
joe
nano
-
ln
-
sv
/
usr
/
lib
/
mc
/
mc
.
*
/
etc
/
profile
.
d
/
-
/
usr
/
local
/
sbin
/
set-hostname
.
sh
imgen
terra
-
su
-
debian
-
c
'git clone https://gitlab.meta.zcu.cz/HADOOP/terraform'
EOT
}
}
resource
"openstack_compute_instance_v2"
"server"
{
name
=
"imgen.terra"
flavor_name
=
"standard.tiny"
image_name
=
"debian-10-x86_64"
key_pair
=
var
.
ssh
user_data
=
data
.
template_cloudinit_config
.
ctx
.
rendered
network
{
name
=
var
.
local_network
}
}
resource
"openstack_networking_floatingip_v2"
"floatip"
{
pool
=
var
.
public_network
}
resource
"openstack_compute_floatingip_associate_v2"
"server-fip-1"
{
floating_ip
=
openstack_networking_floatingip_v2
.
floatip
.
address
instance_id
=
openstack_compute_instance_v2
.
server
.
id
}
output
"public_hosts"
{
value
=
{
imgen
=
openstack_compute_floatingip_associate_v2
.
server-fip-1
.
floating_ip
}
}
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