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" {
74
74
tag_specifications {
75
75
resource_type = " instance"
76
76
tags = local. tags
77
+ pre_install = var. userdata_pre_install
78
+ post_install = var. userdata_post_install
77
79
}
78
80
79
81
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>&
17
17
18
18
yum update -y
19
19
20
+ ${pre_install}
21
+
20
22
# Install docker
21
23
amazon-linux-extras install docker
22
24
service docker start
@@ -40,11 +42,14 @@ while [[ $(aws ssm get-parameters --names ${environment}-$INSTANCE_ID --with-dec
40
42
sleep 1
41
43
done
42
44
config=$( 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
43
46
44
47
export RUNNER_ALLOW_RUNASROOT=1
45
48
./config.sh --unattended --name $INSTANCE_ID --work " _work" $config
46
49
47
50
chown -R ec2-user:ec2-user .
48
-
49
51
./svc.sh install ec2-user
52
+
53
+ ${post_install}
54
+
50
55
./svc.sh start
Original file line number Diff line number Diff line change @@ -70,3 +70,16 @@ variable "ami_owners" {
70
70
type = list (string )
71
71
default = [" amazon" ]
72
72
}
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