Skip to content

Commit

Permalink
few scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kolosovpetro committed Sep 1, 2023
1 parent 5231511 commit d2b4206
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ sas_token = "sas_token"
| [azurerm_lb_nat_rule.green_ssh_nat](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/lb_nat_rule) | resource |
| [azurerm_lb_probe.http_probe](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/lb_probe) | resource |
| [azurerm_lb_rule.http_rule_blue](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/lb_rule) | resource |
| [azurerm_lb_rule.http_rule_green](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/lb_rule) | resource |
| [azurerm_network_interface_backend_address_pool_association.blue_slot_lb_association](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/network_interface_backend_address_pool_association) | resource |
| [azurerm_network_interface_backend_address_pool_association.green_slot_lb_association](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/network_interface_backend_address_pool_association) | resource |
| [azurerm_network_interface_nat_rule_association.blue_ssh_association](https://registry.terraform.io/providers/hashicorp/azurerm/3.71.0/docs/resources/network_interface_nat_rule_association) | resource |
Expand Down
20 changes: 2 additions & 18 deletions lb-rules.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "azurerm_lb_probe" "http_probe" {
loadbalancer_id = module.lb.id
name = "http-probe-blue"
name = "http-probe"
port = 80

depends_on = [
Expand All @@ -10,7 +10,7 @@ resource "azurerm_lb_probe" "http_probe" {

resource "azurerm_lb_rule" "http_rule_blue" {
loadbalancer_id = module.lb.id
name = "http-rule-blue"
name = "http-rule"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
Expand All @@ -23,19 +23,3 @@ resource "azurerm_lb_rule" "http_rule_blue" {
module.lb
]
}

resource "azurerm_lb_rule" "http_rule_green" {
loadbalancer_id = module.lb.id
name = "http-rule-green"
protocol = "Tcp"
frontend_port = 81
backend_port = 80
frontend_ip_configuration_name = module.lb.frontend_ip_configuration_name
backend_address_pool_ids = [module.lb.green_lb_pool_id]
probe_id = azurerm_lb_probe.http_probe.id

depends_on = [
azurerm_lb_probe.http_probe,
module.lb
]
}
10 changes: 10 additions & 0 deletions scripts/install_all_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo apt update -y

echo "=================== Installing Python and PIP ==================="
sudo apt install -y python3 python3-pip python3-dev build-essential
sudo pip3 install --upgrade pip

echo "=================== Installing Nginx ==================="
sudo apt install -y nginx build-essential
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

python_exists=$(whereis python3)

if [[ -n "$python_exists" ]]
then
echo "Python installed at: $python_exists"
exit 1
fi
#python_exists=$(whereis python3)
#
#if [[ -n "$python_exists" ]]
#then
# echo "Python installed at: $python_exists"
# exit 1
#fi

sudo apt update -y
sudo apt install -y python3 python3-pip python3-dev build-essential
Expand Down
10 changes: 10 additions & 0 deletions scripts/swap_to_blue.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
param(
[String] $prefix
)

Write-Host "Swapping to blue"

az network lb rule update --lb-name "lb-$prefix" `
--name "http-rule" `
--resource-group "rg-loadbalancer-$prefix" `
--backend-pool-name "blue-pool"
10 changes: 10 additions & 0 deletions scripts/swap_to_green.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
param(
[String] $prefix
)

Write-Host "Swapping to green"

az network lb rule update --lb-name "lb-$prefix" `
--name "http-rule" `
--resource-group "rg-loadbalancer-$prefix" `
--backend-pool-name "green-pool"

0 comments on commit d2b4206

Please sign in to comment.