2024-09-05 13:33:33 +00:00
|
|
|
- name: Deploy nitro contracts
|
|
|
|
hosts: "{{ target_host }}"
|
|
|
|
|
|
|
|
vars_files:
|
|
|
|
- setup-vars.yml
|
2024-09-06 06:10:03 +00:00
|
|
|
- contract-vars.yml
|
2024-09-05 13:33:33 +00:00
|
|
|
|
|
|
|
environment:
|
|
|
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Create directory for nitro bridge deployment
|
|
|
|
file:
|
|
|
|
path: "{{ nitro_directory }}"
|
|
|
|
state: directory
|
|
|
|
become: yes
|
|
|
|
|
|
|
|
- name: Clone go-nitro stack repo
|
|
|
|
command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Change owner of nitro-directory
|
|
|
|
file:
|
|
|
|
path: "{{ nitro_directory }}"
|
|
|
|
owner: "{{ansible_user}}"
|
|
|
|
group: "{{ansible_user}}"
|
|
|
|
state: directory
|
|
|
|
recurse: yes
|
|
|
|
become: yes
|
|
|
|
|
|
|
|
- name: Clone repositories required for nitro-stack
|
|
|
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories --git-ssh --pull
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Build containers
|
|
|
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers --force-rebuild
|
|
|
|
when: not skip_container_build
|
|
|
|
|
|
|
|
- name: Generate spec file for nitro contracts deployment
|
|
|
|
template:
|
|
|
|
src: "./templates/specs/nitro-contracts-spec.yml.j2"
|
|
|
|
dest: "{{ nitro_directory }}/nitro-contracts-spec.yml"
|
|
|
|
|
|
|
|
- name: Check if deployment exists for nitro contracts
|
|
|
|
stat:
|
|
|
|
path: "{{ nitro_directory }}/nitro-contracts-deployment"
|
|
|
|
register: nitro_contracts_deployment
|
|
|
|
become: yes
|
|
|
|
|
|
|
|
- name: Create a deployment for nitro contracts
|
|
|
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy create --spec-file nitro-contracts-spec.yml --deployment-dir nitro-contracts-deployment
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
when: not nitro_contracts_deployment.stat.exists
|
|
|
|
|
|
|
|
- name: Start deployment for nitro-contracts
|
|
|
|
command: laconic-so deployment --dir nitro-contracts-deployment start
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
|
|
|
|
- name: Wait for the contracts to be deployed
|
|
|
|
wait_for:
|
|
|
|
path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json"
|
|
|
|
timeout: 60
|
|
|
|
|
|
|
|
- name: Export NA_ADDRESS
|
|
|
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json"
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
register: na_address
|
|
|
|
- debug:
|
|
|
|
msg: "NA_ADDRESS: {{ na_address.stdout }}"
|
|
|
|
|
|
|
|
- name: Export CA_ADDRESS
|
|
|
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json"
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
register: ca_address
|
|
|
|
- debug:
|
|
|
|
msg: "CA_ADDRESS: {{ ca_address.stdout }}"
|
|
|
|
|
|
|
|
- name: Export VPA_ADDRESS
|
|
|
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json"
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
register: vpa_address
|
|
|
|
- debug:
|
|
|
|
msg: "VPA_ADDRESS: {{ vpa_address.stdout }}"
|
|
|
|
|
|
|
|
- name: Export L1_ASSET_ADDRESS
|
|
|
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json"
|
|
|
|
args:
|
|
|
|
chdir: "{{ nitro_directory }}"
|
|
|
|
register: l1_asset_address
|
|
|
|
- debug:
|
|
|
|
msg: "L1_ASSET_ADDRESS: {{ l1_asset_address.stdout }}"
|
|
|
|
|
|
|
|
- name: Set contract addresses
|
|
|
|
set_fact:
|
|
|
|
na_address: "{{ na_address.stdout }}"
|
|
|
|
ca_address: "{{ ca_address.stdout }}"
|
|
|
|
vpa_address: "{{ vpa_address.stdout }}"
|
|
|
|
l1_asset_address: "{{ l1_asset_address.stdout }}"
|