testnet-ops/nitro-bridge-setup/run-nitro-bridge.yml
Prathamesh Musale 88e0b48540 Add ansible playbook to setup and run Nitro bridge (#4)
Part of [Automate testnet nitro deployments using Ansible](https://www.notion.so/Automate-testnet-nitro-deployments-using-Ansible-0d15579430204b8daba9a8aa31e07568)
Implement Ansible playbook to:
  - Deploy nitro contracts on L1
  - Deploy bridge contract on L2
  - Setup and run nitro bridge

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: #4
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
2024-09-09 06:11:31 +00:00

74 lines
2.5 KiB
YAML

- name: Setup go-nitro on host
hosts: "{{ target_host }}"
vars_files:
- setup-vars.yml
- bridge-vars.yml
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: Check if deployment exists for bridge node
stat:
path: "{{ nitro_directory }}/bridge-deployment"
register: bridge_deployment
- name: Generate spec file for bridge deployment
template:
src: "./templates/specs/bridge-nitro-spec.yml.j2"
dest: "{{ nitro_directory }}/bridge-nitro-spec.yml"
when: not bridge_deployment.stat.exists
- name: Create a deployment for the bridge node
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy create --spec-file bridge-nitro-spec.yml --deployment-dir bridge-deployment
args:
chdir: "{{ nitro_directory }}"
when: not bridge_deployment.stat.exists
- name: Start the nitro bridge
command: laconic-so deployment --dir bridge-deployment start
args:
chdir: "{{ nitro_directory }}"
- name: Wait for nitro-addresses.json to be created
wait_for:
path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json"
state: present
timeout: 60
- name: Print BRIDGE_ADDRESS
shell: laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"{{ optimism_chain_id }}\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json"
args:
chdir: "{{ nitro_directory }}"
register: bridge_address
- debug:
msg: "BRIDGE_ADDRESS: {{ bridge_address.stdout }}"