galaxyproject / ansible-galaxy

An Ansible role for managing a Galaxy server
https://galaxy.ansible.com/galaxyproject/galaxy
57 stars 75 forks source link

Support for setting `GALAXY_INSTALL_PREBUILT_CLIENT` #207

Closed hexylena closed 1 month ago

hexylena commented 6 months ago

Since we're not using run.sh, we'll need to re-implement it, but it would be really nice to have support for this variable. I don't think there's many (any?) other run.sh variables we really want to make configurable but this is definitely one.

dometto commented 5 months ago

Is this being worked on? If not, I would be happy to open a PR. The ability to support the prebuilt client is crucial for us as we are aiming to do cloud deployments of galaxy, and building is slowing down deployment unacceptably long. Optionally using the prebuilt client in ansible would be a great solution!

In fact, I've modified the client.yml tasks and already got this to work in its most basic form with:

- name: Install prebuilt client via with yarn
  yarn:
    executable: "yarn --network-timeout 300000 --check-files"
    path: "{{ galaxy_server_dir }}"
  environment:
    PATH: "{{ galaxy_venv_dir }}/bin:{{ ansible_env.PATH }}"
    VIRTUAL_ENV: "{{ galaxy_venv_dir }}"
  when: not __galaxy_from_git.stat.exists or (__galaxy_client_build_version != __galaxy_current_commit_id)

- name: Stage prebuilt client
  command: "yarn run stage"
  args:
    chdir: "{{ galaxy_server_dir }}"
  environment:
    PATH: "{{ galaxy_server_dir }}/client/node_modules/.bin:{{ galaxy_venv_dir }}/bin:{{ ansible_env.PATH }}"
    VIRTUAL_ENV: "{{ galaxy_venv_dir }}"
  when: "__galaxy_major_version is version('23.0', '>=')"

I noticed that the client_build_hash.txt does not match the expected git commit value, so currently the role executes these steps every time I run my playbook, but I assume this would be fixed as soon as a new release of the prebuilt client is done?

natefoo commented 5 months ago

Thanks! A PR would definitely be welcome.

The make-based build process currently updates client_build_hash.txt, so we'd need to do something else in this case. You could as a final step write {{ __galaxy_current_commit_id }} to {{ galaxy_static_dir }}/client_build_hash.txt with a task like:

- name: Write client_build_hash.txt
  copy:
    content: "{{ __galaxy_current_commit_id }}"
    dest: "{{ galaxy_static_dir }}/client_build_hash.txt"
    mode: "0644"
dometto commented 5 months ago

Thanks for the suggestion! Or maybe it makes sense to just skip the entire comparison between commit hashes in case galaxy_use_prebuilt_client (or some such) is set to true? Instead, we could e.g. use the yarn module to manage the client dependency and run yarn run stage only when its state changes.

natefoo commented 5 months ago

Yes, that would be even better. To fit with existing naming maybe galaxy_client_use_prebuilt?