Skip to content

Commit 7938a5b

Browse files
Output url (#16)
* ability to skip ansible * output vars for github * use lb_url for action outputs
1 parent ef6d08a commit 7938a5b

File tree

6 files changed

+51
-2
lines changed

6 files changed

+51
-2
lines changed

action.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ inputs:
4949
create_vpc:
5050
description: "Bool, whether a VPC should be created in the action. Default is false"
5151
default: false
52+
infrastructure_only:
53+
description: "Bool, does infrastructure (i.e. terraform) but **not** the deployment (i.e. ansible) . Default is true"
54+
default: false
5255

5356

5457
# ST2 config
@@ -60,9 +63,9 @@ inputs:
6063
description: String. Comma separated list of packs to install. This flag does not work with a --python3 only pack. (default `"st2"`). If you modify this option, be sure to also include `st2` in the list.
6164
default: "st2"
6265
outputs:
63-
vm_url:
66+
lb_url:
6467
description: "The URL of the generated app"
65-
value: ${{ steps.deploy.outputs.vm_url }}
68+
value: ${{ steps.deploy.outputs.lb_url }}
6669

6770
runs:
6871
using: 'composite'
@@ -93,6 +96,9 @@ runs:
9396
SUB_DOMAIN: ${{ inputs.sub_domain }}
9497
# CREATE_HOSTED_ZONE: ${{ inputs.CREATE_HOSTED_ZONE }}
9598
CREATE_VPC: ${{ inputs.create_vpc }}
99+
100+
# Skip ansible deployment if deploying only infrastructure
101+
ANSIBLE_SKIP_DEPLOY: ${{ inputs.infrastructure_only }}
96102
BITOPS_FAST_FAIL: true
97103

98104
# ST2 config
@@ -102,3 +108,20 @@ runs:
102108
run: |
103109
echo "running operations/_scripts/deploy/deploy.sh"
104110
$GITHUB_ACTION_PATH/operations/_scripts/deploy/deploy.sh
111+
112+
echo "Setting up vars for GitHub"
113+
$GITHUB_ACTION_PATH/operations/_scripts/deploy/export_vars.sh
114+
115+
# output results to GitHub
116+
- if: ${{ steps.deploy.outputs.lb_url != '' }}
117+
name: Print result created
118+
shell: bash
119+
run: |
120+
echo "## VM Created! :rocket:" >> $GITHUB_STEP_SUMMARY
121+
echo " ${{ steps.deploy.outputs.lb_url }}" >> $GITHUB_STEP_SUMMARY
122+
- if: ${{ steps.deploy.outputs.lb_url == '' }}
123+
name: Print result destroyed
124+
shell: bash
125+
run: |
126+
echo "## VM Destroyed! :boom:" >> $GITHUB_STEP_SUMMARY
127+
echo "Buckets and whole infrastructure should be gone now!" >> $GITHUB_STEP_SUMMARY

operations/_scripts/deploy/deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ docker run --rm --name bitops \
5353
-e SKIP_DEPLOY_HELM="${SKIP_DEPLOY_HELM}" \
5454
-e BITOPS_TERRAFORM_COMMAND="${TERRAFORM_COMMAND}" \
5555
-e TERRAFORM_DESTROY="${TERRAFORM_DESTROY}" \
56+
-e ANSIBLE_SKIP_DEPLOY="${ANSIBLE_SKIP_DEPLOY}" \
5657
-e TF_STATE_BUCKET="${TF_STATE_BUCKET}" \
5758
-e DEFAULT_FOLDER_NAME="_default" \
5859
-e CREATE_VPC="${CREATE_VPC}" \
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
# Export variables to GHA
3+
4+
BO_OUT="$GITHUB_ACTION_PATH/operations/bo-out.env"
5+
6+
echo "Check for $BO_OUT"
7+
if [ -f $BO_OUT ]; then
8+
echo "Outputting bo-out.env to GITHUB_OUTPUT"
9+
cat $BO_OUT >> $GITHUB_OUTPUT
10+
else
11+
echo "BO_OUT is not a file"
12+
fi
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "local_file" "export-bitops-variables" {
2+
filename = "/opt/bitops_deployment/bo-out.env"
3+
content = <<-EOT
4+
lb_url=${local.url}
5+
EOT
6+
}

operations/deployment/terraform/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module "Stackstorm-Single-VM" {
2626

2727
locals {
2828
availability_zones = "${formatlist("${var.region}%s", var.availability_zones)}"
29+
url = "${module.Stackstorm-Single-VM.loadbalancer_protocol}${module.Stackstorm-Single-VM.loadbalancer_public_dns}"
2930
}
3031

3132
output "availability_zone" {

operations/deployment/terraform/modules/04_elb.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ resource "aws_elb" "vm" {
3939
output "loadbalancer_public_dns" {
4040
description = "Public DNS address of the LB"
4141
value = aws_elb.vm.dns_name
42+
}
43+
output "loadbalancer_protocol" {
44+
description = "Protocol of the LB url"
45+
# TODO: handle ssl (see 01_acm.tf.skip)
46+
# value = local.fqdn_provided ? 'https://' : 'http://'
47+
value = "http://"
4248
}

0 commit comments

Comments
 (0)