From 3bdd743ac524739e935d73c429233fdb7b7e94ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gourv=C3=A9nec?= Date: Wed, 5 Jul 2023 12:21:13 +0200 Subject: [PATCH] Add tasks to create only 1 client Rational: adding a client seems inoffensive. Updating a client on the other hand is not (removing then adding a client). --- tasks/hydra-create-client.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tasks/hydra-create-client.yml diff --git a/tasks/hydra-create-client.yml b/tasks/hydra-create-client.yml new file mode 100644 index 0000000..af49d21 --- /dev/null +++ b/tasks/hydra-create-client.yml @@ -0,0 +1,17 @@ +--- +# Simple task to create 1 client for hydra. Fails if the client already exists. +# Parameter: client_id + +- fail: msg='Error, client does not exist. Please define the client first' + when: hydra_clients|selectattr("client_id", "equalto", client_id)|list|length == 0 + +- name: Create hydra-client + template: + src: hydra-client.json.j2 + dest: "/etc/hydra/clients.d/{{ item.client_id }}.json" + with_items: "{{ hydra_clients }}" + when: item.client_id == client_id + +- name: Import client + command: podman exec -t cadoles-pod-hydra-v1 /bin/sh -c "hydra clients import /etc/hydra/clients.d/{{ client_id }}.json --endpoint http://127.0.0.1:4445" + become: true