File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ resource "aws_launch_template" "runner" {
7474 tag_specifications {
7575 resource_type = " instance"
7676 tags = local. tags
77+ pre_install = var. userdata_pre_install
78+ post_install = var. userdata_post_install
7779 }
7880
7981 user_data = base64encode (templatefile (" ${ path . module } /templates/user-data.sh" , {
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ exec > >(tee /var/log/user-data.log | logger -t user-data -s 2>/dev/console) 2>&
1717
1818yum update -y
1919
20+ ${pre_install}
21+
2022# Install docker
2123amazon-linux-extras install docker
2224service docker start
@@ -40,11 +42,14 @@ while [[ $(aws ssm get-parameters --names ${environment}-$INSTANCE_ID --with-dec
4042 sleep 1
4143done
4244config=$( aws ssm get-parameters --names ${environment} -$INSTANCE_ID --with-decryption --region $REGION | jq -r " .Parameters | .[0] | .Value" )
45+ aws ssm delete-parameter --names ${environment} -$INSTANCE_ID --with-decryption --region $REGION
4346
4447export RUNNER_ALLOW_RUNASROOT=1
4548./config.sh --unattended --name $INSTANCE_ID --work " _work" $config
4649
4750chown -R ec2-user:ec2-user .
48-
4951./svc.sh install ec2-user
52+
53+ ${post_install}
54+
5055./svc.sh start
Original file line number Diff line number Diff line change @@ -70,3 +70,16 @@ variable "ami_owners" {
7070 type = list (string )
7171 default = [" amazon" ]
7272}
73+
74+
75+ variable "userdata_pre_install" {
76+ description = " User-data script snippet to insert before GitLab runner install"
77+ type = string
78+ default = " "
79+ }
80+
81+ variable "userdata_post_install" {
82+ description = " User-data script snippet to insert after GitLab runner install"
83+ type = string
84+ default = " "
85+ }
You can’t perform that action at this time.
0 commit comments