- name: Setup and run nitro nodes hosts: "{{ target_host }}" vars_files: - setup-vars.yml - nitro-vars.yml environment: PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin" tasks: - name: Install yq get_url: url: https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 dest: /usr/bin/yq mode: '0755' become: yes - 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 go-nitro stack repo command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull ignore_errors: yes - name: Clone repositories required for nitro-stack command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node setup-repositories --git-ssh --pull ignore_errors: yes - name: Build containers command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild when: not skip_container_build - name: Generate spec file for L1 nitro node template: src: "./templates/specs/l1-nitro-spec.yml.j2" dest: "{{ nitro_directory }}/l1-nitro-spec.yml" - name: Generate spec file for L2 nitro node template: src: "./templates/specs/l2-nitro-spec.yml.j2" dest: "{{ nitro_directory }}/l2-nitro-spec.yml" - name: Check if deployment exists for L1 nitro node stat: path: "{{ nitro_directory }}/l1-nitro-deployment" register: l1_deployment - name: Create a deployment for L1 nitro node command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l1-nitro-spec.yml --deployment-dir l1-nitro-deployment args: chdir: "{{ nitro_directory }}" when: not l1_deployment.stat.exists - name: Check if deployment exists for L2 nitro node stat: path: "{{ nitro_directory }}/l2-nitro-deployment" register: l2_deployment - name: Create a deployment for L2 nitro node command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l2-nitro-spec.yml --deployment-dir l2-nitro-deployment args: chdir: "{{ nitro_directory }}" when: not l2_deployment.stat.exists - name: Check if the config.env file is empty for L1 deployment shell: "[ -s {{ nitro_directory }}/l1-nitro-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 L1 nitro deployment if it is empty template: src: "./templates/configs/l1-nitro-config.env.j2" dest: "{{ nitro_directory }}/l1-nitro-deployment/config.env" when: file_check_result.stdout == 'File is empty' - name: Check if the config.env file is empty for L2 deployment shell: "[ -s {{ nitro_directory }}/l2-nitro-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 L2 nitro deployment if it is empty template: src: "./templates/configs/l2-nitro-config.env.j2" dest: "{{ nitro_directory }}/l2-nitro-deployment/config.env" when: file_check_result.stdout == 'File is empty' - name: Start deployment for L1 nitro node command: laconic-so deployment --dir l1-nitro-deployment start args: chdir: "{{ nitro_directory }}" - name: Start deployment for L2 nitro node command: laconic-so deployment --dir l2-nitro-deployment start args: chdir: "{{ nitro_directory }}"