diff --git a/ansible/stage2.yml b/ansible/stage2.yml new file mode 100644 index 00000000..a0b63a3f --- /dev/null +++ b/ansible/stage2.yml @@ -0,0 +1,13 @@ +--- +- name: Execute getbestchainlock + hosts: wallet_nodes + tasks: + - name: Run dash-cli getbestchainlock + ansible.builtin.command: dash-cli getbestchainlock + register: chainlock_output + ignore_errors: true + + - name: Check for chainlock + ansible.builtin.fail: + msg: "Chainlock failure: no chainlock found." + when: '"error" in chainlock_output.stderr' diff --git a/bin/deploy b/bin/deploy index 6f5c51e6..60792ac7 100755 --- a/bin/deploy +++ b/bin/deploy @@ -14,10 +14,13 @@ Options: -i --only-infrastructure - Only build infrastructure using Terraform -p --only-provisioning - Only provisioning using Ansible -f --force-deployment - Force deployment of a devnet branch on a different devnet + -s --stage - Stage of deployment, defaults to first stage (1) -a= --ansible-args= - Pass extra arguments to ansible-playbook command --ansible-playbook= - Specify custom playbook. Default: deploy -h --help - Show help" + +STAGE=1 #Default for i in "$@" do case ${i} in @@ -36,6 +39,9 @@ case ${i} in --ansible-playbook=*) ansible_playbook="${i#*=}.yml" ;; + -s=*|--stage=*) + STAGE="${i#*=}" + ;; -h|--help) echo "$CMD_USAGE" exit 0 @@ -50,31 +56,34 @@ done . ./lib/cli/terraform.sh . ./lib/cli/ansible.sh -echo "Deploying $NETWORK_NAME network..."; - -# TODO: this fails if not at the HEAD of a given branch -BRANCH=$(git symbolic-ref --short HEAD) -if [[ $BRANCH == "devnet-"* ]]; then - if [[ $BRANCH != $NETWORK_NAME ]] && [[ $FORCED_DEPLOYMENT != 1 ]]; then - echo "Wrong Devnet - Check you're in the correct branch. Use -f to force if you're sure" - exit 1 - fi -fi - -# Setup infrastructure using Terraform - -if [ -z ${ONLY_PROVISIONING} ]; then - terraform_run_command "apply" -else - echo "Skipping Terraform infrastructure deployment" -fi - -# Install software and configure dash network using Ansible - -if [ -z ${ONLY_INFRASTRUCTURE} ]; then - ansible_run_playbook "$ansible_playbook" -else - echo "Skipping Ansible provisioning" -fi - - +case ${STAGE} in + 1) + echo "Deploying $NETWORK_NAME network... stage (1)"; + + # TODO: this fails if not at the HEAD of a given branch + BRANCH=$(git symbolic-ref --short HEAD) + if [[ $BRANCH == "devnet-"* ]]; then + if [[ $BRANCH != $NETWORK_NAME ]] && [[ $FORCED_DEPLOYMENT != 1 ]]; then + echo "Wrong Devnet - Check you're in the correct branch. Use -f to force if you're sure" + exit 1 + fi + fi + + # Setup infrastructure using Terraform + if [ -z ${ONLY_PROVISIONING} ]; then + terraform_run_command "apply" + else + echo "Skipping Terraform infrastructure deployment" + fi + + # Install software and configure dash network using Ansible + if [ -z ${ONLY_INFRASTRUCTURE} ]; then + ansible_run_playbook "$ansible_playbook" + else + echo "Skipping Ansible provisioning" + fi + ;; + 2) + ansible_run_playbook "stage2.yml" + ;; +esac