forked from cerc-io/testnet-ops
106 lines
4.1 KiB
YAML
106 lines
4.1 KiB
YAML
- name: Setup L1 and L2 optimism on remote host
|
|
hosts: "{{ target_host }}"
|
|
|
|
vars_files:
|
|
- vars.yml
|
|
|
|
environment:
|
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
|
|
|
tasks:
|
|
- name: Create directory for nitro-stack
|
|
file:
|
|
path: "{{ nitro_directory }}"
|
|
state: directory
|
|
|
|
- name: Change owner of nitro-directory
|
|
file:
|
|
path: "{{ nitro_directory }}"
|
|
owner: "{{ansible_user}}"
|
|
group: "{{ansible_user}}"
|
|
state: directory
|
|
recurse: yes
|
|
|
|
- name: Clone fixturenet-eth-stack
|
|
command: laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-eth-stacks --pull
|
|
|
|
- name: Clone fixturenet-optimism-stack
|
|
command: laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-optimism-stack --pull
|
|
ignore_errors: true
|
|
|
|
- name: Clone required repositories for fixturenet-eth
|
|
command: laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth setup-repositories --pull
|
|
|
|
- name: Clone required repositories for fixturenet-optimism
|
|
command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism setup-repositories --pull
|
|
ignore_errors: true
|
|
|
|
- name: Remove any older foundary image with 'latest' tag
|
|
docker_image:
|
|
name: "ghcr.io/foundry-rs/foundry"
|
|
state: absent
|
|
tag: latest
|
|
|
|
- name: Build container images for L1
|
|
command: laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth build-containers --force-rebuild
|
|
when: not skip_container_build
|
|
|
|
- name: Build container images for L2
|
|
command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism build-containers --force-rebuild
|
|
when: not skip_container_build
|
|
|
|
- name: Remove any dangling docker images
|
|
command: docker image prune -f
|
|
|
|
- name: Copy over spec file for L1 deployment
|
|
template:
|
|
src: "./templates/specs/l1-spec.yml.j2"
|
|
dest: "{{ nitro_directory }}/fixturenet-eth-spec.yml"
|
|
|
|
- name: Copy over spec file for L2 deployment
|
|
template:
|
|
src: "./templates/specs/l2-spec.yml.j2"
|
|
dest: "{{ nitro_directory }}/fixturenet-optimism-spec.yml"
|
|
|
|
- name: Check if the deployment directory exists for L1
|
|
stat:
|
|
path: "{{ nitro_directory }}/fixturenet-eth-deployment"
|
|
register: l1_deployment_dir
|
|
|
|
- name: Create a deployment from the spec file for L1
|
|
command: laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy create --spec-file fixturenet-eth-spec.yml --deployment-dir fixturenet-eth-deployment
|
|
args:
|
|
chdir: "{{ nitro_directory }}"
|
|
when: not l1_deployment_dir.stat.exists
|
|
|
|
- name: Check if the deployment directory exists for L2
|
|
stat:
|
|
path: "{{ nitro_directory }}/fixturenet-optimism-deployment"
|
|
register: l2_deployment_dir
|
|
|
|
- name: Create a deployment from the spec file for L2
|
|
command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism deploy create --spec-file fixturenet-optimism-spec.yml --deployment-dir fixturenet-optimism-deployment
|
|
args:
|
|
chdir: "{{ nitro_directory }}"
|
|
when: not l2_deployment_dir.stat.exists
|
|
|
|
- name: Place both deployments in the same namespace
|
|
copy:
|
|
src: "{{ nitro_directory }}/fixturenet-eth-deployment/deployment.yml"
|
|
dest: "{{ nitro_directory }}/fixturenet-optimism-deployment/deployment.yml"
|
|
remote_src: "{{ target_host != 'localhost' }}"
|
|
|
|
- name: Check if the config.env file is empty
|
|
shell: "[ -s '{{ nitro_directory }}/fixturenet-eth-deployment/config.env' ] && echo 'File is not empty' || echo 'File is empty'"
|
|
register: file_check_result
|
|
|
|
- name: Display the result of the file check
|
|
debug:
|
|
msg: "{{ file_check_result.stdout }}"
|
|
|
|
- name: Copy config.env for fixturenet eth deployment if it is empty
|
|
template:
|
|
src: "./templates/configs/eth-config.env"
|
|
dest: "{{ nitro_directory }}/fixturenet-eth-deployment/config.env"
|
|
when: file_check_result.stdout == 'File is empty'
|