---
# Configure chain spec, start joystream-node service on the servers and build Pioneer

- name: Create and copy the chain-spec file
  hosts: all

  tasks:
    - name: Generate chain-spec file and data keys either on localhost or admin server
      include_role:
        name: common
        tasks_from: chain-spec-node-keys
      vars:
        local_or_admin: "{{ groups['build'][0] if run_on_admin_server|bool else 'localhost' }}"
        admin_code_dir: "{{ remote_code_path if run_on_admin_server|bool else local_dir }}"

- name: Copy secret, auth and start joystream-node service for validators
  hosts: validators
  gather_facts: no

  roles:
    - validators

- name: Configure RPC service and start it
  hosts: rpc
  gather_facts: no

  roles:
    - rpc

- name: Build Pioneer and copy artifacts to S3
  hosts: build
  gather_facts: no

  tasks:
    - include_role:
        name: admin
        tasks_from: deploy-pioneer
