{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- set api_token = arvados.cluster.tokens.system_root | yaml_encode %}
{%- set api_host = arvados.cluster.Services.Controller.ExternalURL | regex_replace('^http(s?)://', '', ignorecase=true) %}
{%- set api_token = arvados.cluster.tokens.system_root | yaml_encode %}
{%- set api_host = arvados.cluster.Services.Controller.ExternalURL | regex_replace('^http(s?)://', '', ignorecase=true) %}
{%- set vm_name = vm_params.name | default(vm) %}
{%- set cmd_query_vm_uuid = 'ARVADOS_API_TOKEN=' ~ api_token ~
{%- set vm_name = vm_params.name | default(vm) %}
{%- set cmd_query_vm_uuid = 'ARVADOS_API_TOKEN=' ~ api_token ~
- require:
- pkg: arvados-controller-package-install-pkg-installed
- cmd: arvados-controller-service-running-service-ready-cmd-run
- require:
- pkg: arvados-controller-package-install-pkg-installed
- cmd: arvados-controller-service-running-service-ready-cmd-run
# We need to use the UUID generated in the previous command to see if there's a
# scoped token for it. There's no easy way to pass the value from a shellout
# We need to use the UUID generated in the previous command to see if there's a
# scoped token for it. There's no easy way to pass the value from a shellout
# the file content is a token uuid :|
arvados-controller-resources-virtual-machines-{{ vm }}-get-vm_uuid-cmd-run:
cmd.run:
# the file content is a token uuid :|
arvados-controller-resources-virtual-machines-{{ vm }}-get-vm_uuid-cmd-run:
cmd.run:
- name: {{ cmd_query_vm_uuid }} | head -1 | tee /tmp/{{ vm }}
- require:
- cmd: arvados-controller-resources-virtual-machines-{{ vm }}-record-cmd-run
- name: {{ cmd_query_vm_uuid }} | head -1 | tee /tmp/{{ vm }}
- require:
- cmd: arvados-controller-resources-virtual-machines-{{ vm }}-record-cmd-run
# There's no direct way to query the scoped_token for a given virtual_machine
# so we need to parse the api_client_authorization list through some jq
{%- set cmd_query_scoped_token_url = 'VM_UUID=$(cat /tmp/' ~ vm ~ ') && ' ~
' ARVADOS_API_TOKEN=' ~ api_token ~
# There's no direct way to query the scoped_token for a given virtual_machine
# so we need to parse the api_client_authorization list through some jq
{%- set cmd_query_scoped_token_url = 'VM_UUID=$(cat /tmp/' ~ vm ~ ') && ' ~
' ARVADOS_API_TOKEN=' ~ api_token ~
' /usr/bin/jq -e \'.items[].scopes[] | select(. == "GET ' ~
'/arvados/v1/virtual_machines/\'${VM_UUID}\'/logins")\' && ' ~
'unset VM_UUID'
' /usr/bin/jq -e \'.items[].scopes[] | select(. == "GET ' ~
'/arvados/v1/virtual_machines/\'${VM_UUID}\'/logins")\' && ' ~
'unset VM_UUID'
api_client_authorization \
create \
--api-client-authorization '{"scopes":["GET /arvados/v1/virtual_machines/'${VM_UUID}'/logins"]}'
api_client_authorization \
create \
--api-client-authorization '{"scopes":["GET /arvados/v1/virtual_machines/'${VM_UUID}'/logins"]}'
- pkg: arvados-controller-package-install-pkg-installed
- pkg: arvados-controller-resources-virtual-machines-jq-pkg-installed
- cmd: arvados-controller-resources-virtual-machines-{{ vm }}-get-vm_uuid-cmd-run
- pkg: arvados-controller-package-install-pkg-installed
- pkg: arvados-controller-resources-virtual-machines-jq-pkg-installed
- cmd: arvados-controller-resources-virtual-machines-{{ vm }}-get-vm_uuid-cmd-run