Skip to content

Commit

Permalink
Merge pull request #14 from zerodha/dev
Browse files Browse the repository at this point in the history
Merge dev
  • Loading branch information
mr-karan authored Jan 8, 2024
2 parents 3c1c528 + db3a594 commit 3ffc2a8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/nomad-clients/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "aws_instance" "nomad_client" {
enable_docker_plugin = var.enable_docker_plugin
nomad_join_tag_key = "nomad_ec2_join"
nomad_join_tag_value = var.nomad_join_tag_value
nomad_file_limit = var.nomad_file_limit
nomad_client_cfg = templatefile("${path.module}/templates/nomad.tftpl", {
nomad_dc = var.cluster_name
nomad_acl_enable = var.nomad_acl_enable
Expand Down
1 change: 1 addition & 0 deletions modules/nomad-clients/launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ resource "aws_launch_template" "nomad_client" {
enable_docker_plugin = var.enable_docker_plugin
nomad_join_tag_key = "nomad_ec2_join"
nomad_join_tag_value = var.nomad_join_tag_value
nomad_file_limit = var.nomad_file_limit
nomad_client_cfg = templatefile("${path.module}/templates/nomad.tftpl", {
nomad_dc = var.cluster_name
nomad_acl_enable = var.nomad_acl_enable
Expand Down
11 changes: 11 additions & 0 deletions modules/nomad-clients/scripts/setup_client.tftpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,16 @@ search ap-south-1.compute.internal
EOF
}

# Increase the file limit
modify_nomad_systemd_config() {
if [ ${nomad_file_limit} > 65536 ]; then
sudo sed -i '/^LimitNOFILE/s/=.*$/=${nomad_file_limit}/' /lib/systemd/system/nomad.service
fi
}

# Enables nomad systemd service
start_nomad() {
sudo systemctl daemon-reload
sudo systemctl enable --now nomad
}

Expand Down Expand Up @@ -197,6 +205,9 @@ log "INFO" "Adding docker config to Nomad"
add_docker_to_nomad
%{ endif }

log "INFO" "Modify Nomad systemd config"
modify_nomad_systemd_config

log "INFO" "Starting Nomad service"
start_nomad

Expand Down
6 changes: 6 additions & 0 deletions modules/nomad-clients/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@ variable "nomad_acl_enable" {
type = bool
default = true
}

variable "nomad_file_limit" {
description = "Value for LimitNOFILE in nomad systemd config"
type = number
default = 900000
}
2 changes: 2 additions & 0 deletions modules/nomad-servers/launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ resource "aws_launch_template" "nomad_server" {
user_data = base64encode(templatefile("${path.module}/scripts/setup_server.tftpl.sh", {
nomad_acl_bootstrap_token = var.nomad_acl_bootstrap_token
nomad_acl_enable = var.nomad_acl_enable
nomad_file_limit = var.nomad_file_limit
nomad_server_cfg = templatefile("${path.module}/templates/nomad.tftpl", {
nomad_dc = var.cluster_name
aws_region = var.aws_region
Expand All @@ -20,6 +21,7 @@ resource "aws_launch_template" "nomad_server" {
nomad_join_tag_value = var.nomad_join_tag_value
nomad_acl_enable = var.nomad_acl_enable
})
nomad_file_limit = var.nomad_file_limit
}))

metadata_options {
Expand Down
11 changes: 11 additions & 0 deletions modules/nomad-servers/scripts/setup_server.tftpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ set_hostname() {
done
}

# Increase the file limit
modify_nomad_systemd_config() {
if [ ${nomad_file_limit} > 65536 ]; then
sudo sed -i '/^LimitNOFILE/s/=.*$/=${nomad_file_limit}/' /lib/systemd/system/nomad.service
fi
}

# Enables nomad systemd service
start_nomad() {
sudo systemctl daemon-reload
sudo systemctl enable --now nomad
}

Expand Down Expand Up @@ -149,6 +157,9 @@ set_hostname
log "INFO" "Rendering server config for nomad"
prepare_nomad_server_config

log "INFO" "Modify Nomad systemd config"
modify_nomad_systemd_config

log "INFO" "Starting Nomad service"
start_nomad

Expand Down
6 changes: 6 additions & 0 deletions modules/nomad-servers/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,9 @@ variable "vpc" {
type = string
nullable = false
}

variable "nomad_file_limit" {
description = "Value for LimitNOFILE in nomad systemd config"
type = number
default = 900000
}

0 comments on commit 3ffc2a8

Please sign in to comment.