Closed bernt-matthias closed 5 years ago
Sure, easy enough.
Cool. Would simplify usage in ansible.
It looks like there's a subset of the error states we're not catching properly.
https://github.com/galaxy-iuc/parsec/commit/4bfef53b23dfe4f2f04aa80723c5c4b3f3ed11c7
$ parsec histories show_history asdf
Malformed id ( asdf ) specified, unable to decode
$ echo $?
1
looks better now on the unreleased branch.
you're using this in ansible? Cool! Can you share about your use case?
Just starting to manage quotas (currently only the default quota) with ansible.
Something like:
- name: query default quota id
shell: |
. {{ galaxy_server_dir }}/.venv/bin/activate &&
parsec --galaxy_instance {{ inventory_hostname }} quotas get_quotas | jq --raw-output '.[] | select(.name=="default").id'
register: command_output
- set_fact:
default_quota_id={{ command_output.stdout }}
- name: "Ansible | Print a message if a variable is undefined"
debug:
msg: "{{ default_quota_id }}"
# currently only on bioinf2-dev
- name: setup galaxy default quota
shell: |
. {{ galaxy_server_dir }}/.venv/bin/activate &&
parsec --galaxy_instance {{ inventory_hostname }} quotas create_quota --default registered default "Default quota" "{{ galaxy_default_quota }}" =
when: inventory_hostname == "bioinf2-dev" and default_quota_id == ""
- name: query default quota size
shell: |
. {{ galaxy_server_dir }}/.venv/bin/activate &&
parsec --galaxy_instance {{ inventory_hostname }} quotas show_quota {{ default_quota_id }} | jq --raw-output '.display_amount'
register: command_output
- set_fact: default_quota_size={{ command_output.stdout | regex_replace(' ([MGT])B', '\\1')}}
- name: "Ansible | Print a message if a variable is undefined"
debug:
msg: "{{ default_quota_size }}"
- name: update galaxy default quota
shell: |
. {{ galaxy_server_dir }}/.venv/bin/activate &&
parsec --galaxy_instance {{ inventory_hostname }} quotas update_quota --default registered --amount "{{ galaxy_default_quota }}" --operation = {{ default_quota_id }}i
when: inventory_hostname == "bioinf2-dev" and default_quota_id != "" and default_quota_size != galaxy_default_quota
register: command_output
failed_when: "'Bad Request' in command_output.stderr"
But not finished yet
Wow, super cool. Thanks for sharing!
Thanks for the super fast response.
I'll try and get a release out soon, but I'm guessing you're pulling from the branch already. Sorry it's a bit slow.
Would it be possible to return a non-zero exit code in case of an error like: