Make placement groups optional

This commit is contained in:
a@a.ru 2019-04-17 23:55:47 +03:00
parent fec2784897
commit e07d05cc0f
8 changed files with 23 additions and 82 deletions

View File

@ -31,7 +31,7 @@ chain_custom_environment:
ETHEREUM_JSONRPC_TRACE_URL: "http://localhost:8545" # Network RPC endpoint in trace mode. Can be the same as the previous variable
ETHEREUM_JSONRPC_WS_URL: "ws://localhost:8546" # Network RPC endpoint in websocket mode
NETWORK_PATH: "/poa/core" # relative URL path, for example: blockscout.com/$NETWORK_PATH
SECRET_KEY_BASE: "TPGMvGK0iIwlXBQuQDA5KRqk77VETbEBlG4gAWeb93TvBsYAjvoAvdODMd6ZeguPwf2YTRY3n7uvxXzQP4WayQ==" # Secret key for production assets protection. Use mix phx.gen.secret to generate
SECRET_KEY_BASE: "TPGMvGK0iIwlXBQuQDA5KRqk77VETbEBlG4gAWeb93TvBsYAjvoAvdODMd6ZeguPwf2YTRY3n7uvxXzQP4WayQ==" # Secret key for production assets protection. Use `mix phx.gen.secret` or `openssl rand -base64 64 | tr -d '\n'` to generate
CHECK_ORIGIN: false # Used to check the origin of requests when the origin header is present
PORT: 4000 # Port the application runs on
COIN: "POA" # Coin name at the Coinmarketcap, used to display current exchange rate

View File

@ -34,6 +34,9 @@ pool_size: 30
## The following variable represents the elixir version that will be used to run BlockScout instance. Will be used to download the Elixir at the following link: https://github.com/elixir-lang/elixir/releases/download/{{ elixir_version }}/Precompiled.zip
elixir_version: "v1.7.4"
## Whether or not to use the placement group for the BlockScout instances.
use_placement_group: false
# DB related variables
## This value represents the name of the DB that will be created/attached. Must be unique. Will be prefixed with `prefix` variable.

View File

@ -7,7 +7,7 @@
fail:
msg: "The prefix '{{ item }}' is invalid. It must consist only of the lowercase characters a-z and digits 0-9, and must not more than 5 characters long."
when: item.key|length > 5 or item.key is not match("^[a-z0-9]+$")
with_dict: "{{ chains }}"
with_dict: "{{ chain_custom_environment }}"
- name: Check if terraform is installed
command: which terraform

View File

@ -40,7 +40,7 @@ resource "aws_launch_configuration" "explorer" {
}
resource "aws_placement_group" "explorer" {
count = "${length(var.chains)}"
count = "${var.use_placement_group ? length(var.chains): 0}"
name = "${var.prefix}-explorer-placement-group${count.index}"
strategy = "cluster"
}
@ -51,7 +51,7 @@ resource "aws_autoscaling_group" "explorer" {
max_size = "${length(var.chains) * 4}"
min_size = "${length(var.chains)}"
desired_capacity = "${length(var.chains)}"
placement_group = "${aws_placement_group.explorer.*.id[count.index]}"
placement_group = "${var.use_placement_group ? aws_placement_group.explorer.*.id[count.index] : "zero"}"
launch_configuration = "${aws_launch_configuration.explorer.name}"
vpc_zone_identifier = ["${aws_subnet.default.id}"]
availability_zones = ["${data.aws_availability_zones.available.names}"]
@ -69,25 +69,7 @@ resource "aws_autoscaling_group" "explorer" {
]
depends_on = [
"aws_ssm_parameter.new_relic_app_name",
"aws_ssm_parameter.new_relic_license_key",
"aws_ssm_parameter.pool_size",
"aws_ssm_parameter.ecto_use_ssl",
"aws_ssm_parameter.exq_blocks_concurrency",
"aws_ssm_parameter.exq_concurrency",
"aws_ssm_parameter.exq_internal_transactions_concurrency",
"aws_ssm_parameter.exq_receipts_concurrency",
"aws_ssm_parameter.exq_transactions_concurrency",
"aws_ssm_parameter.secret_key_base",
"aws_ssm_parameter.port",
"aws_ssm_parameter.db_username",
"aws_ssm_parameter.db_password",
"aws_ssm_parameter.db_host",
"aws_ssm_parameter.db_port",
"aws_ssm_parameter.ethereum_url",
"aws_ssm_parameter.trace_url",
"aws_ssm_parameter.ws_url",
"aws_ssm_parameter.network_path",
"aws_ssm_parameter.db_host"
]
lifecycle {

View File

@ -9,44 +9,14 @@ variable "instance_type" {}
variable "root_block_size" {}
variable "pool_size" {}
variable "elixir_version" {}
variable "use_placement_group" {}
variable "key_content" {
default = ""
}
variable "chain_jsonrpc_variant" {
default = {}
}
variable "chains" {
default = {}
}
variable "chain_trace_endpoint" {
default = {}
}
variable "chain_ws_endpoint" {
default = {}
}
variable "chain_logo" {
default = {}
}
variable "chain_coin" {
default = {}
}
variable "chain_network" {
default = {}
}
variable "chain_subnetwork" {
default = {}
}
variable "chain_network_path" {
default = {}
}
variable "chain_network_icon" {
default = {}
}
variable "chain_graphiql_transaction" {
default = {}
}
variable "chain_db_id" {
default = {}
@ -84,25 +54,11 @@ variable "chain_db_version" {
default = {}
}
variable "new_relic_app_name" {}
variable "new_relic_license_key" {}
variable "secret_key_base" {}
variable "secret_key_base" {
default = {}
}
variable "alb_ssl_policy" {}
variable "alb_certificate_arn" {}
variable "use_ssl" {}
variable "chain_block_transformer" {
default = {}
}
variable "chain_heart_beat_timeout" {
default = {}
}
variable "chain_heart_command" {
default = {}
}
variable "chain_blockscout_version" {
variable "use_ssl" {
default = {}
}

View File

@ -55,6 +55,13 @@
prompt: "Are you absolutely sure you want to execute the deployment plan shown above? [False]"
register: user_answer
- name: Insert vars into parameter store
include: parameter_store.yml
loop: "{{ chain_custom_environment.keys() }}"
loop_control:
loop_var: chain
index_var: index
- name: Terraform provisioning
shell: "echo yes | {{ terraform_location }} apply"
args:
@ -75,13 +82,6 @@
chdir: "roles/main_infra/files"
when: user_answer.user_input|bool == True
- name: Use role in loop
include: parameter_store.yml
loop: "{{ chain_custom_environment.keys() }}"
loop_control:
loop_var: chain
index_var: index
- name: Output info from Terraform
debug:
value: output.stdout_lines.instructions.value

View File

@ -1,6 +1,6 @@
- name: Prepare variables for Parameter Store
set_fact:
chain_upper_env: "{{ chain_ps_env | combine ({item.key|lower : item.value}) }}"
chain_ps_env: "{{ chain_ps_env | combine ({item.key|lower : item.value}) }}"
with_dict: "{{ chain_custom_environment[chain] }}"
vars:
chain_ps_env: {}

View File

@ -8,7 +8,7 @@ db_subnet_cidr = "{{ db_subnet_cidr }}"
dns_zone_name = "{{ dns_zone_name }}"
instance_type = "{{ instance_type }}"
root_block_size = "{{ root_block_size }}"
use_placement_group = "{{ use_placement_group }}"
alb_ssl_policy = "{{ alb_ssl_policy }}"
alb_certificate_arn = "{{ alb_certificate_arn }}"
elixir_version = "{{ elixir_version }}"