From ad82d3d221ed76f4477a4c11104f5cb9a200860d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Pansanel?= Date: Mon, 12 Jun 2023 18:19:46 +0200 Subject: [PATCH] Add the possiblity to restrict the json query when creating the VOMS files. --- defaults/main.yml | 1 + tasks/cache_config.yml | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3a69530..4662560 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,3 +20,4 @@ vomses_dir: /etc/vomses lavoisier: base_url: "https://operations-portal.egi.eu/api" vo_id_card_endpoint: "/vo-voms/json" +voms_data_query: 'data[*]' diff --git a/tasks/cache_config.yml b/tasks/cache_config.yml index 26316da..48eec25 100644 --- a/tasks/cache_config.yml +++ b/tasks/cache_config.yml @@ -12,11 +12,17 @@ - "{{ voms_dir }}" - "{{ vomses_dir }}" +# Restricts request to supported VO if defined +- name: Set VOMS data query + set_fact: + voms_data_query: "data[?{{ [\"name == '\"] | product(supported_vos) | map(\"join\") | product([\"'\"]) | map(\"join\") | join(\"||\") }}]" + when: supported_vos is defined + - name: Create LSC directories file: path: "{{ voms_dir }}/{{ item }}" state: directory - loop: "{{ vo_voms | json_query('data[*].name') }}" + loop: "{{ vo_voms | json_query(voms_data_query~'.name') }}" # LSC files should have the format: # certificate DN @@ -30,7 +36,7 @@ {{ item.DN}} {{ item.CA_DN}} loop: - "{{ vo_voms | json_query('data[*]') | subelements('voms') | to_json | + "{{ vo_voms | json_query(voms_data_query) | subelements('voms') | to_json | from_json | json_query('[*].{name: [0].name, hostname: [1].hostname, DN: [1].DN, CA_DN: [1].CA_DN}') }}" @@ -41,6 +47,6 @@ "{{ item.name }}" "{{ item.hostname}}" "{{ item.port }}" "{{ item.DN }}" "{{ item.name }}" loop: - "{{ vo_voms | json_query('data[*]') | subelements('voms') | to_json | + "{{ vo_voms | json_query(voms_data_query) | subelements('voms') | to_json | from_json | json_query('[*].{name: [0].name, hostname: [1].hostname, DN: [1].DN, port: [1].port}') }}"