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) }}"