fix a number of bugs
This commit is contained in:
parent
5290e2c5f2
commit
d1a4ea6e9f
|
@ -0,0 +1,2 @@
|
|||
[defaults]
|
||||
force_handlers = True
|
|
@ -1,3 +1,12 @@
|
|||
- name: Save config file
|
||||
hosts: localhost
|
||||
roles:
|
||||
- { role: s3, when: "backend|bool == true" }
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_REGION: "{{ region }}"
|
||||
|
||||
- name: Deploy BlockScout
|
||||
hosts: localhost
|
||||
tasks:
|
||||
|
@ -7,8 +16,4 @@
|
|||
loop: "{{ chains.keys() }}"
|
||||
loop_control:
|
||||
loop_var: chain
|
||||
index_var: index
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_REGION: "{{ region }}"
|
||||
index_var: index
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
resource "aws_ssm_parameter" "elixir_version" {
|
||||
count = "${var.new_relic_license_key == "" ? 0 : length(var.chains)}"
|
||||
count = "${length(var.chains)}"
|
||||
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/elixir_version"
|
||||
value = "${var.elixir_version}"
|
||||
type = "String"
|
||||
|
|
|
@ -14,6 +14,7 @@ function log() {
|
|||
}
|
||||
|
||||
parameters_json="{}"
|
||||
|
||||
function fetch_ssm_with_token() {
|
||||
if [ -z "$1" ]; then
|
||||
log "(fetch_ssm_with_token) Calling ssm without token"
|
||||
|
@ -39,7 +40,7 @@ function fetch_ssm_with_token() {
|
|||
|
||||
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -P /tmp
|
||||
|
||||
yum install -y /tmp/epel-release-latest-7.noarch.rpm
|
||||
yum localinstall -y /tmp/epel-release-latest-7.noarch.rpm
|
||||
|
||||
yum update -y
|
||||
|
||||
|
@ -132,18 +133,10 @@ EOF
|
|||
log "Installing Erlang.."
|
||||
|
||||
wget http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_1_general/esl-erlang_21.1-1~centos~7_amd64.rpm
|
||||
yum install -y wxGTK-devel unixODBC-devel >"$LOG"
|
||||
yum install -y esl-erlang_21.1-1~centos~7_amd64.rpm >"$LOG"
|
||||
|
||||
ELIXIR_VERSION="$(get_param 'elixir_version')"
|
||||
log "Installing Elixir to /opt/elixir.."
|
||||
mkdir -p /opt/elixir
|
||||
wget https://github.com/elixir-lang/elixir/releases/download/${ELIXIR_VERSION}/Precompiled.zip >"$LOG"
|
||||
unzip Precompiled.zip -d /opt/elixir >"$LOG"
|
||||
log "Elixir installed successfully!"
|
||||
yum localinstall -y wxGTK-devel unixODBC-devel >"$LOG"
|
||||
yum localinstall -y esl-erlang_21.1-1~centos~7_amd64.rpm >"$LOG"
|
||||
|
||||
log "Fetching configuration from Parameter Store..."
|
||||
#parameters_json=$(aws ssm get-parameters-by-path --region "$REGION" --path "/$PREFIX/$CHAIN")
|
||||
fetch_ssm_with_token
|
||||
params=$(echo "$parameters_json" | jq '.Parameters[].Name' --raw-output)
|
||||
log "$(printf 'Found the following parameters:\n\n%s\n' "$params")"
|
||||
|
@ -154,6 +147,13 @@ function get_param() {
|
|||
--raw-output
|
||||
}
|
||||
|
||||
ELIXIR_VERSION="$(get_param 'elixir_version')"
|
||||
log "Installing Elixir to /opt/elixir.."
|
||||
mkdir -p /opt/elixir
|
||||
wget https://github.com/elixir-lang/elixir/releases/download/${ELIXIR_VERSION}/Precompiled.zip >"$LOG"
|
||||
unzip Precompiled.zip -d /opt/elixir >"$LOG"
|
||||
log "Elixir installed successfully!"
|
||||
|
||||
DB_USER="$(get_param 'db_username')"
|
||||
DB_PASS="$(get_param 'db_password')"
|
||||
DB_HOST="$(get_param 'db_host')"
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
force: true
|
||||
when: skip_fetch | bool != true
|
||||
|
||||
- name: Git clean
|
||||
command: "git clean -fdx"
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}"
|
||||
when: skip_fetch | bool != true
|
||||
|
||||
- name: Merge branches
|
||||
command: "git merge {{ chain_merge_commit[chain] }}"
|
||||
args:
|
||||
|
@ -31,15 +37,28 @@
|
|||
state: absent
|
||||
|
||||
- name: Compile BlockScout
|
||||
command: mix do deps.get, local.rebar --force, deps.compile, compile, ecto.drop, ecto.create, ecto.migrate
|
||||
command: "mix do {{ item }}"
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}"
|
||||
with_items:
|
||||
- deps.get
|
||||
- local.rebar --force
|
||||
- deps.compile
|
||||
- compile
|
||||
- ecto.drop
|
||||
- ecto.create
|
||||
- ecto.migrate
|
||||
|
||||
- name: Install Node modules at apps/block_scout_web/assets
|
||||
command: npm install && node_modules/webpack/bin/webpack.js --mode production
|
||||
command: npm install
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}/apps/block_scout_web/assets"
|
||||
|
||||
- name: Execute webpack.js at apps/block_scout_web/assets/node_modules/webpack/bin
|
||||
command: node_modules/webpack/bin/webpack.js --mode production
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}/apps/block_scout_web/assets"
|
||||
|
||||
- name: Instal Node modules at apps/explorer
|
||||
command: npm install
|
||||
args:
|
||||
|
@ -51,31 +70,34 @@
|
|||
chdir: "blockscout-{{ chain }}/apps/block_scout_web"
|
||||
|
||||
- name: Start server
|
||||
command: mix phx.server &
|
||||
environment:
|
||||
- BLOCKSCOUT_VERSION: "{{ chain_blockscout_version[chain].value }}"
|
||||
- COIN: "{{ chain_coin[chain].value }}"
|
||||
- ETHEREUM_JSONRPC_HTTP_URL: "{{ chains[chain].value }}"
|
||||
- ETHEREUM_JSONRPC_TRACE_URL: "{{ chain_trace_endpoint[chain].value }}"
|
||||
- ETHEREUM_JSONRPC_WS_URL: "{{ chain_ws_endpoint[chain].value }}"
|
||||
- ETHEREUM_JSONRPC_VARIANT: "{{ chain_jsonrpc_variant[chain].value }}"
|
||||
- HEART_BEAT_TIMEOUT: "{{ chain_heart_beat_timeout[chain].value }}"
|
||||
- HEART_COMMAND: "{{ chain_heart_command[chain].value }}"
|
||||
- LOGO: "{{ chain_logo[chain].value }}"
|
||||
- NETWORK: "{{ chain_network[chain].value }}"
|
||||
- SUBNETWORK: "{{ chain_subnetwork[chain].value }}"
|
||||
- NETWORK_ICON: "{{ chain_network_icon[chain].value }}"
|
||||
- "{{ chain_custom_environment_chain }}"
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}"
|
||||
vars:
|
||||
chain_custom_environment_chain: "{{ chain_cec[chain] | default('') }}"
|
||||
chain_cec: "{{ chain_custom_environment | default('') }}"
|
||||
|
||||
- name: User prompt
|
||||
pause:
|
||||
prompt: "Please, open your browser and open 4000 port at the machine were Ansible is currently run. BlockScout should appear. Ensure that there is no visual artifacts and then press Enter to continue. Press Ctrl+C if you face any issues to cancel the deployment."
|
||||
|
||||
block:
|
||||
- name: Start server
|
||||
command: "mix phx.server"
|
||||
environment: "{{ chain_env }}"
|
||||
ignore_errors: true
|
||||
args:
|
||||
chdir: "blockscout-{{ chain }}"
|
||||
vars:
|
||||
chain_env: "{{ chain_custom_environment_chain | combine({'BLOCKSCOUT_VERSION': chain_blockscout_version[chain], 'COIN': chain_coin[chain], 'ETHEREUM_JSONRPC_HTTP_URL': chains[chain], 'ETHEREUM_JSONRPC_TRACE_URL': chain_trace_endpoint[chain], 'ETHEREUM_JSONRPC_WS_URL': chain_ws_endpoint[chain], 'ETHEREUM_JSONRPC_VARIANT': chain_jsonrpc_variant[chain], 'HEART_BEAT_TIMEOUT': chain_heart_beat_timeout[chain], 'HEART_COMMAND': chain_heart_command[chain], 'LOGO': chain_logo[chain], 'NETWORK': chain_network[chain], 'SUBNETWORK': chain_subnetwork[chain], 'NETWORK_ICON': chain_network_icon[chain]}) }}"
|
||||
chain_custom_environment_chain: "{{ chain_cec[chain] | default({}) }}"
|
||||
chain_cec: "{{ chain_custom_environment | default ({}) }}"
|
||||
async: 10000
|
||||
poll: 0
|
||||
- name: User prompt
|
||||
pause:
|
||||
prompt: "Please, open your browser and open 4000 port at the machine were Ansible is currently run. BlockScout should appear. Ensure that there is no visual artifacts and then press Enter to continue. Press Ctrl+C and then A if you face any issues to cancel the deployment."
|
||||
rescue:
|
||||
- name: 'Stop execution'
|
||||
fail:
|
||||
msg: "Execution aborted."
|
||||
always:
|
||||
- name: kill server
|
||||
command: "pkill -e {{ item }}"
|
||||
with_items:
|
||||
- beam.smp
|
||||
- node
|
||||
failed_when: false
|
||||
|
||||
- name: Build static assets
|
||||
command: mix phx.digest
|
||||
args:
|
||||
|
@ -86,15 +108,19 @@
|
|||
state: absent
|
||||
path: "{{ item }}"
|
||||
with_items:
|
||||
- "blockscout-{{ chain }}/build/"
|
||||
- "blockscout-{{ chain }}/_build/"
|
||||
- "blockscout-{{ chain }}/deps/"
|
||||
- "blockscout-{{ chain }}/apps/block_scout_web/assets/node_modules/"
|
||||
- "blockscout-{{ chain }}/apps/explorer/node_modules/"
|
||||
- "blockscout-{{ chain }}/logs/dev/"
|
||||
|
||||
- name: Upload Blockscout to S3
|
||||
command: "aws deploy push --application-name={{ application_name }} --s3-location {{ s3_connection_string }} --source=blockscout-{{ chain }}"
|
||||
command: "aws deploy push --application-name={{ prefix }}-explorer --s3-location s3://{{ prefix }}-explorer-codedeploy-releases/blockscout-{{ chain }}.zip --source=blockscout-{{ chain }}"
|
||||
register: push_output
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_REGION: "{{ region }}"
|
||||
|
||||
- name: User prompt
|
||||
pause:
|
||||
|
@ -107,9 +133,7 @@
|
|||
value: "{{ item.value }}"
|
||||
with_items:
|
||||
- { name: elixir_version, value: "{{ elixir_version }}" }
|
||||
- { name: block_transformet, value: "{{ chain_block_transformer[chain] }}" }
|
||||
- { name: new_relic_app_name, value: "{{ chain_new_relic_app_name[chain] }}" }
|
||||
- { name: new_relic_license_key, value: "{{ chain_new_relic_license_key[chain] }}" }
|
||||
- { name: block_transformer, value: "{{ chain_block_transformer[chain] }}" }
|
||||
- { name: pool_size, value: "{{ pool_size }}" }
|
||||
- { name: ecto_use_ssl, value: "{{ use_ssl }}" }
|
||||
- { name: ethereum_jsonrpc_variant, value: "{{ chain_jsonrpc_variant[chain] }}" }
|
||||
|
@ -123,19 +147,23 @@
|
|||
- { name: network_path, value: "{{ chain_network_path[chain] }}" }
|
||||
- { name: network_icon, value: "{{ chain_network_icon[chain] }}" }
|
||||
- { name: graphiql_transaction, value: "{{ chain_graphiql_transaction[chain] }}" }
|
||||
- { name: exq_blocks_concurrency, value: 1 }
|
||||
- { name: exq_concurrency, value: 1 }
|
||||
- { name: exq_internal_transactions_concurrency, value: 1 }
|
||||
- { name: exq_receipts_concurrency, value: 1 }
|
||||
- { name: exq_transactions_concurrency, value: 1 }
|
||||
- { name: secret_key_base, value: "{{ secret_key_base }}" }
|
||||
- { name: alb_ssl_policy, value: "{{ alb_ssl_policy }}" }
|
||||
- { name: alb_certificate_arn, value: "{{ alb_certificate_arn }}" }
|
||||
- { name: heart_beat_timeout, value: "{{ chain_heart_beat_timeout[chain] }}" }
|
||||
- { name: heart_command, value: "{{ chain_heart_command[chain] }}" }
|
||||
- { name: blockscout_version, value: "{{ chain_blockscout_version[chain] }}" }
|
||||
# DB info will not be refreshed
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_REGION: "{{ region }}"
|
||||
when: user_answer.user_input|bool == true
|
||||
# DB and New Relic info will not be refreshed
|
||||
|
||||
- name: Deploy Blockscout
|
||||
command: "{{ push_output.stdout | regex_replace('^--deployment-group-name <deployment-group-name> --deployment-config-name <deployment-config-name> --description <description>$', '') }} --deployment-group-name {{ prefix }}-explorer-dg{{ index }} --deployment-config-name CodeDeployDefault.OneAtATime --description '{{ chain_blockscout_version[chain] }}'"
|
||||
command: "{{ push_output.stdout_lines[1] }} --deployment-group-name {{ prefix }}-explorer-dg{{ index }} --deployment-config-name CodeDeployDefault.OneAtATime --description '{{ chain_blockscout_version[chain] }}'"
|
||||
when: user_answer.user_input|bool == true
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
||||
AWS_REGION: "{{ region }}"
|
||||
|
|
Loading…
Reference in New Issue