---
# Run setup and build code

- name: Creat bash profile file
  command: 'touch /home/ubuntu/.bash_profile'

- name: Run setup script
  command: ./setup.sh
  args:
    chdir: '{{ remote_code_path }}'

- name: Build joystream node
  shell: . ~/.bash_profile && yarn cargo-build
  args:
    chdir: '{{ remote_code_path }}'
  # Run in async fashion for max duration of 1 hr
  async: 3600
  poll: 0
  register: build_result

- name: Check on build async task
  async_status:
    jid: '{{ build_result.ansible_job_id }}'
  register: job_result
  until: job_result.finished
  # Max number of times to check for status
  retries: 36
  # Check for the status every 100s
  delay: 100
