Browse Source

Merge pull request #2518 from mnaamani/devops/add-subkey-to-prebuilt-ami

prebuilt ami: include subkey in image
Mokhtar Naamani 3 years ago
parent
commit
113de1be87

+ 1 - 1
.github/workflows/create-ami.yml

@@ -5,7 +5,7 @@ on:
     branches:
       - master
       - olympia
-      - test_branch
+      - create-joystream-node-ami
 
 jobs:
   build:

+ 2 - 2
devops/infrastructure/README.md

@@ -26,10 +26,10 @@ On Mac run the command:
 Follow [the official installation guide](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) for your system.
 
 # How to run
-Edit the file `bash-config.cfg` and update parameters like AWS_KEY_PAIR_NAME, KEY_PATH
+Copy and edit the file `deploy-config.sample.cfg` and update parameters like AWS_KEY_PAIR_NAME, KEY_PATH
 Run the `deploy-infra.sh` script to deploy the infrastructure
 
 ```
 cd devops/infrastructure
-./deploy-infra.sh
+./deploy-infra.sh your-deploy-config.cfg
 ```

+ 1 - 1
devops/infrastructure/bash-config.sample.cfg → devops/infrastructure/deploy-config.sample.cfg

@@ -10,7 +10,7 @@ VALIDATOR_EC2_INSTANCE_TYPE=t2.micro
 BUILD_EC2_INSTANCE_TYPE=t2.xlarge
 RPC_EC2_INSTANCE_TYPE=t2.micro
 
-# Set a prebuilt AMI if required
+# prebuilt AMI with joystream-node, chain-spec and subkey already built
 EC2_AMI_ID="ami-08ffec5991ca99db9"
 
 ACCOUNT_ID=$(aws sts get-caller-identity --profile $CLI_PROFILE --query Account --output text)

+ 5 - 6
devops/infrastructure/deploy-infra.sh

@@ -73,16 +73,15 @@ if [ $? -eq 0 ]; then
 
   if [ -z "$EC2_AMI_ID" ]
   then
-    echo -e "\n\n=========== Configuring the node servers ==========="
+    echo -e "\n\n=========== Compile joystream-node on build server ==========="
     ansible-playbook -i $INVENTORY_PATH --private-key $KEY_PATH build-code.yml \
       --extra-vars "branch_name=$BRANCH_NAME git_repo=$GIT_REPO build_local_code=$BUILD_LOCAL_CODE data_path=data-$NEW_STACK_NAME"
-  fi
 
-  echo -e "\n\n=========== Configuring the Build server ==========="
-  ansible-playbook -i $INVENTORY_PATH --private-key $KEY_PATH setup-admin.yml \
-    --extra-vars "local_dir=$LOCAL_CODE_PATH build_local_code=$BUILD_LOCAL_CODE"
+    echo -e "\n\n=========== Install additional utils on build server ==========="
+    ansible-playbook -i $INVENTORY_PATH --private-key $KEY_PATH setup-admin.yml
+  fi
 
-  echo -e "\n\n=========== Configuring the chain spec file and Pioneer app ==========="
+  echo -e "\n\n=========== Configure and start new validators, rpc node and pioneer ==========="
   ansible-playbook -i $INVENTORY_PATH --private-key $KEY_PATH chain-spec-pioneer.yml \
     --extra-vars "local_dir=$LOCAL_CODE_PATH network_suffix=$NETWORK_SUFFIX
                   data_path=data-$NEW_STACK_NAME bucket_name=$BUCKET_NAME number_of_validators=$NUMBER_OF_VALIDATORS"

+ 4 - 4
devops/infrastructure/deploy-single-node.sh

@@ -6,7 +6,7 @@ source common.sh
 
 if [ -z "$1" ]; then
   echo "ERROR: Configuration file not passed"
-  echo "Please use ./deploy-infra.sh PATH/TO/CONFIG to run this script"
+  echo "Please use ./deploy-single-node.sh PATH/TO/CONFIG to run this script"
   exit 1
 else
   echo "Using $1 file for config"
@@ -24,7 +24,7 @@ if [ ! -f "$KEY_PATH" ]; then
 fi
 
 # # Deploy the CloudFormation template
-echo -e "\n\n=========== Deploying single instance ==========="
+echo -e "\n\n=========== Deploying single node ==========="
 aws cloudformation deploy \
   --region $REGION \
   --profile $CLI_PROFILE \
@@ -45,7 +45,7 @@ if [ $? -eq 0 ]; then
 
   echo -e "New Node Public IP: $SERVER_IP"
 
-  echo -e "\n\n=========== Configuring the chain spec file and Pioneer app ==========="
-  ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH new-node-playbook.yml \
+  echo -e "\n\n=========== Configuring node ==========="
+  ansible-playbook -i $SERVER_IP, --private-key $KEY_PATH single-node-playbook.yml \
     --extra-vars "binary_file=$BINARY_FILE chain_spec_file=$CHAIN_SPEC_FILE"
 fi

+ 5 - 0
devops/infrastructure/github-action-playbook.yml

@@ -16,6 +16,11 @@
           name: common
           tasks_from: run-setup-build
 
+      - name: Install subkey
+        include_role:
+          name: admin
+          tasks_from: main
+
       - name: Basic AMI Creation
         amazon.aws.ec2_ami:
           instance_id: "{{ instance_id }}"

+ 12 - 1
devops/infrastructure/roles/admin/tasks/main.yml

@@ -7,7 +7,7 @@
 
 - name: Copy bash_profile content to bashrc for non-interactive sessions
   blockinfile:
-    block: "{{ bash_data.stdout }}"
+    block: '{{ bash_data.stdout }}'
     path: ~/.bashrc
     insertbefore: BOF
 
@@ -16,3 +16,14 @@
 
 - name: Install subkey
   shell: cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.1 --locked
+  async: 3600
+  poll: 0
+  register: install_result
+
+- name: Check whether install subkey task has finished
+  async_status:
+    jid: '{{ install_result.ansible_job_id }}'
+  register: job_result
+  until: job_result.finished
+  retries: 36
+  delay: 100

+ 0 - 0
devops/infrastructure/new-node-playbook.yml → devops/infrastructure/single-node-playbook.yml