Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Devops CW Fork
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Byron Biggs
Devops CW Fork
Commits
a8cd0b41
Commit
a8cd0b41
authored
4 months ago
by
Byron Biggs
Browse files
Options
Downloads
Patches
Plain Diff
First attempt for NGINX
parent
0cd3080c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Terraform/plan.tf
+59
-38
59 additions, 38 deletions
Terraform/plan.tf
Terraform/server1.sh
+54
-2
54 additions, 2 deletions
Terraform/server1.sh
with
113 additions
and
40 deletions
Terraform/plan.tf
+
59
−
38
View file @
a8cd0b41
terraform
{
required_version
=
">= 0.14.0"
required_version
=
">= 0.14.0"
required_providers
{
openstack
=
{
source
=
"terraform-provider-openstack/openstack"
...
...
@@ -8,44 +8,65 @@ required_version = ">= 0.14.0"
}
}
resource
"openstack_networking_floatingip_v2"
"floating_ip_1"
{
pool
=
var
.
pool
}
resource
"openstack_networking_floatingip_v2"
"floating_ip_1"
{
pool
=
var
.
pool
}
resource
"openstack_compute_secgroup_v2"
"security_group"
{
name
=
var
.
security_name
description
=
var
.
security_description
rule
{
from_port
=
22
to_port
=
22
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
rule
{
from_port
=
8080
to_port
=
8080
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
rule
{
from_port
=
8081
to_port
=
8081
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
resource
"openstack_compute_secgroup_v2"
"security_group"
{
name
=
var
.
security_name
description
=
var
.
security_description
rule
{
from_port
=
22
to_port
=
22
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
resource
"openstack_compute_instance_v2"
"instance_1"
{
name
=
var
.
name1
image_name
=
var
.
image
flavor_name
=
var
.
flavor
security_groups
=
[
openstack_compute_secgroup_v2
.
security_group
.
name
]
key_pair
=
var
.
keypair
user_data
=
file
(
var
.
server1_script
)
network
{
name
=
var
.
network
}
rule
{
from_port
=
8080
to_port
=
8080
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
rule
{
from_port
=
8081
to_port
=
8081
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
# Adding rule for HTTP traffic (port 80)
rule
{
from_port
=
80
to_port
=
80
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
resource
"openstack_compute_floatingip_associate_v2"
"floating_ip_1"
{
floating_ip
=
openstack_networking_floatingip_v2
.
floating_ip_1
.
address
instance_id
=
openstack_compute_instance_v2
.
instance_1
.
id
# Adding rule for HTTPS traffic (port 443) if needed
rule
{
from_port
=
443
to_port
=
443
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
}
resource
"openstack_compute_instance_v2"
"instance_1"
{
name
=
var
.
name1
image_name
=
var
.
image
flavor_name
=
var
.
flavor
security_groups
=
[
openstack_compute_secgroup_v2
.
security_group
.
name
]
key_pair
=
var
.
keypair
user_data
=
file
(
var
.
server1_script
)
network
{
name
=
var
.
network
}
}
resource
"openstack_compute_floatingip_associate_v2"
"floating_ip_1"
{
floating_ip
=
openstack_networking_floatingip_v2
.
floating_ip_1
.
address
instance_id
=
openstack_compute_instance_v2
.
instance_1
.
id
}
# Output the floating IP for use in Jenkins
output
"floating_ip_1"
{
value
=
openstack_networking_floatingip_v2
.
floating_ip_1
.
address
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Terraform/server1.sh
+
54
−
2
View file @
a8cd0b41
...
...
@@ -130,11 +130,63 @@ sudo unzip -d /opt/gradle gradle-7.6-bin.zip
echo
"export PATH=
\$
PATH:/opt/gradle/gradle-7.6/bin"
>>
~/.bashrc
source
~/.bashrc
# Install NGINX
echo
"=== Installing and configuring NGINX ==="
sudo
dnf
install
nginx
-y
sudo
systemctl start nginx
sudo
systemctl
enable
nginx
# Configure NGINX as reverse proxy for Spring Boot
echo
"=== Configuring NGINX as reverse proxy ==="
cat
<<
EOF
> /etc/nginx/conf.d/springboot.conf
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host
\$
host;
proxy_set_header X-Real-IP
\$
remote_addr;
proxy_set_header X-Forwarded-For
\$
proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto
\$
scheme;
}
}
EOF
# Remove default nginx configuration
sudo rm
-f
/etc/nginx/conf.d/default.conf
# Restart NGINX to apply changes
sudo
systemctl restart nginx
# Build and run the Polish community group application
echo
"=== Building
and running
Polish community application ==="
echo
"=== Building Polish community application ==="
cd
~/fork-team-10-polish-community-group
export
PATH
=
$PATH
:/opt/gradle/gradle-7.6/bin
gradle build
nohup
gradle bootrun &
# Create a systemd service for Spring Boot application
echo
"=== Creating systemd service for Spring Boot ==="
cat
<<
EOF
> /etc/systemd/system/springboot.service
[Unit]
Description=Spring Boot Application
After=syslog.target network.target
[Service]
User=root
WorkingDirectory=/root/fork-team-10-polish-community-group
ExecStart=/opt/gradle/gradle-7.6/bin/gradle bootRun
SuccessExitStatus=143
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Enable and start the Spring Boot service
sudo
systemctl daemon-reload
sudo
systemctl
enable
springboot
sudo
systemctl start springboot
echo
"=== Provisioning complete ==="
\ No newline at end of file
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