From 25b3c5db72ff7d2bafb7aa96dbec4e81e2030319 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:44:18 +0100 Subject: [PATCH] Squashed commit of the following: commit 1693be3f06719d711bb7a01510b6c9adb45eabfd Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Dec 8 09:13:47 2023 +0100 fix: remove url params commit 621f3d368489e099ff2bc487bd8538cf727faae3 Merge: ef2a465 cd0edb3 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Dec 8 09:10:32 2023 +0100 Merge branch 'main' into feature/orga-users commit ef2a465e280b683aec19d3f49b2208014bee689b Merge: 5aa9131 5670fe4 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Nov 29 15:28:13 2023 +0100 Merge remote-tracking branch 'upstream/main' into feature/orga-users commit 5aa9131ff7d30314aea7d66408fc1db9907ba1eb Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Nov 29 15:18:40 2023 +0100 test(molecule): org users commit c5368b34750d5406162e3ffb533fa09eaa74887b Merge: acd3e96 a476181 Author: Moritz <15136847+Nemental@users.noreply.github.com> Date: Wed Nov 29 11:54:20 2023 +0100 Merge branch 'telekom-mms:main' into feature/orga-users commit acd3e96ca281deb47bfdefd231e8df23be06f397 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Nov 3 17:18:27 2023 +0100 refactor: removed org_name URI user mgmt in favour of community.grafana module enhancement commit b2ef53c7facb553bf9463430580f538923a84a49 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Nov 3 14:34:32 2023 +0100 docs: org_name or _id commit 420527bd6be7d137a06efe0fcaa26f4dfabacea5 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Nov 3 14:10:39 2023 +0100 feat: enable org users with org_id commit 8ae4004cfe96918a1d5499d58bb53e5391040fc9 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Nov 3 14:10:17 2023 +0100 docs: fix table commit 37f8440ecaec2dc7cde2d2765b9de35de541852c Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Fri Nov 3 14:05:24 2023 +0100 chore(deps): increase community.grafana version commit 28abbabf1355cfab2da769f468d3497fde3cc360 Merge: f6c7eff 0c2a846 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Nov 1 10:27:27 2023 +0100 Merge branch 'main' into feature/orga-users commit f6c7eff74b9a87faaa331e1ada3692fe9eeb9eef Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 13:04:02 2023 +0200 docs: org user mgmt params and notice commit 66371b2f21da09a682c668ef0c3336abb77e98cd Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 12:59:21 2023 +0200 fix: include tasks tag handling and conditonal commit a73376cb0f1615f12d4ac7cce192a0bcfed696c2 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 12:57:48 2023 +0200 fix: get orgs loop, get users loop, error handling org user mgmt commit 10df45088e880eec25e755cad2dca9a230e55119 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 12:56:27 2023 +0200 chore: org users default var commit 3e5d5f612672fded6a7f0132301cab421bc27403 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 10:21:39 2023 +0200 fix: list length conditional commit f03c6dc7dfb9f5c38132d8e5b339a5fb65d6c110 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 10:20:03 2023 +0200 fix: include task apply tags and file commit 85a74adbe5d4a2abec69678abd165b0803939112 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Wed Oct 18 10:15:47 2023 +0200 refactor: simplify vars and reorganize tags commit 41e687d8ebe593c810a41032471e6ac5d5c17af1 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Tue Oct 17 16:42:25 2023 +0200 docs: orga users commit 8bee405c5a5d02b74f55875dd605ca0b09d3172a Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Tue Oct 17 16:36:10 2023 +0200 refactor: split task files for orga user mgmt commit 9f36358712ebacd049ba25afd528f5fc7d731aba Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Tue Oct 17 15:48:11 2023 +0200 style: comments commit 390a85034bbe7a8ff7c2a5920d92f94b49bf3d67 Author: Nemental <15136847+Nemental@users.noreply.github.com> Date: Tue Oct 17 15:44:32 2023 +0200 feat: manage organization users --- molecule/default/converge.yml | 6 ++++++ roles/grafana/README.md | 18 +++++++++++------- roles/grafana/defaults/main.yml | 1 + roles/grafana/tasks/main.yml | 11 +++++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index fdde17c8..d1a8aa40 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -34,6 +34,12 @@ password: supersecure!123 email: testuser@example.de + grafana_organization_users: + - login: testuser + org_id: 1 + - login: testuser + org_name: my_org + grafana_dashboards: - folder: my_service path: test_dashboard.json diff --git a/roles/grafana/README.md b/roles/grafana/README.md index d39c16e4..fb46493f 100644 --- a/roles/grafana/README.md +++ b/roles/grafana/README.md @@ -18,25 +18,24 @@ Configure Grafana organizations, dashboards, folders, datasources, teams and use | grafana_url | yes | | grafana_username | yes | | grafana_password | yes | - -| [**grafana_users**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_user_module.html) +| [**grafana_users**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_user_module.html) | | name | yes | | email | no | | login | yes | | password | no | | is_admin | no | | state | no | -| [**grafana_organizations**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_organization_module.html) +| [**grafana_organizations**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_organization_module.html) | | name | yes | | state | no | -| [**grafana_teams**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_team_module.html) +| [**grafana_teams**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_team_module.html) | | name | yes | | email | no | | members | no | | state | no | | enforce_members | no | | skip_version_check | no | -| [**grafana_datasources**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_datasource_module.html) +| [**grafana_datasources**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_datasource_module.html) | | tls_skip_verify | no | | org_id | no | | name | yes | @@ -50,11 +49,11 @@ Configure Grafana organizations, dashboards, folders, datasources, teams and use | password | no | | additional_json_data | no | | additional_secure_json_data | no | -| [**grafana_folders**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_folder_module.html) +| [**grafana_folders**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_folder_module.html) | | name | yes | | state | no | | skip_version_check | no | -| [**grafana_dashboards**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_dashboard_module.html) +| [**grafana_dashboards**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_dashboard_module.html) | | org_id | no | | folder | no | | state | no | @@ -65,6 +64,11 @@ Configure Grafana organizations, dashboards, folders, datasources, teams and use | dashboard_id | no | | dashboard_revision | no | | commit_message | no | +| [**grafana_organization_users**](https://docs.ansible.com/ansible/latest/collections/community/grafana/grafana_organization_user_module.html) | +| login | yes | +| role | no | +| state | no | +| org_id / org_name | no | ## Example Playbook diff --git a/roles/grafana/defaults/main.yml b/roles/grafana/defaults/main.yml index 5ee7817e..d23719c5 100644 --- a/roles/grafana/defaults/main.yml +++ b/roles/grafana/defaults/main.yml @@ -1,5 +1,6 @@ --- grafana_organizations: [] +grafana_organization_users: [] grafana_users: [] grafana_teams: [] grafana_datasources: [] diff --git a/roles/grafana/tasks/main.yml b/roles/grafana/tasks/main.yml index 67257f80..37967001 100644 --- a/roles/grafana/tasks/main.yml +++ b/roles/grafana/tasks/main.yml @@ -66,6 +66,17 @@ loop_control: {loop_var: user} tags: user + - name: Manage organization users + community.grafana.grafana_organization_user: + login: "{{ organization_user.login }}" + role: "{{ organization_user.role | default(omit) }}" + state: "{{ organization_user.state | default(omit) }}" + org_id: "{{ organization_user.org_id | default(omit) }}" + org_name: "{{ organization_user.org_name | default(omit) }}" + loop: "{{ grafana_organization_users }}" + loop_control: {loop_var: organization_user} + tags: organization_user + - name: Manage dashboard community.grafana.grafana_dashboard: org_id: "{{ dashboard.org_id | default(omit) }}"