diff --git a/tasks/main.yml b/tasks/main.yml index ce6dd01..67257f8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,95 +1,83 @@ --- -- name: Manage organization - community.grafana.grafana_organization: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "{{ organization.name }}" - state: "{{ organization.state | default(omit) }}" - loop: "{{ grafana_organizations }}" - loop_control: {loop_var: organization} - tags: organization +- name: Group tasks for authentication parameters + module_defaults: + group/community.grafana.grafana: + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + block: + - name: Manage organization + community.grafana.grafana_organization: + name: "{{ organization.name }}" + state: "{{ organization.state | default(omit) }}" + loop: "{{ grafana_organizations }}" + loop_control: {loop_var: organization} + tags: organization -# datasource.0 = grafana_datasource attribute -- name: Manage datasource - community.grafana.grafana_datasource: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - tls_skip_verify: "{{ datasource.tls_skip_verify | default(omit) }}" - org_id: "{{ datasource.org_id | default(omit) }}" - name: "{{ datasource.name }}" - ds_type: "{{ datasource.ds_type | default(omit) }}" - access: "{{ datasource.access | default(omit) }}" - ds_url: "{{ datasource.ds_url | default(omit) }}" - database: "{{ datasource.database | default(omit) }}" - with_credentials: "{{ datasource.with_credentials | default(omit) }}" - is_default: "{{ datasource.is_default | default(omit) }}" - user: "{{ datasource.user | default(omit) }}" - password: "{{ datasource.password | default(omit) }}" - additional_json_data: "{{ datasource.additional_json_data | default(omit) }}" - additional_secure_json_data: "{{ datasource.additional_secure_json_data | default(omit) }}" - loop: "{{ grafana_datasources }}" - loop_control: {loop_var: datasource} - tags: datasource + - name: Manage datasource + community.grafana.grafana_datasource: + tls_skip_verify: "{{ datasource.tls_skip_verify | default(omit) }}" + org_id: "{{ datasource.org_id | default(omit) }}" + name: "{{ datasource.name }}" + ds_type: "{{ datasource.ds_type | default(omit) }}" + access: "{{ datasource.access | default(omit) }}" + ds_url: "{{ datasource.ds_url | default(omit) }}" + database: "{{ datasource.database | default(omit) }}" + with_credentials: "{{ datasource.with_credentials | default(omit) }}" + is_default: "{{ datasource.is_default | default(omit) }}" + user: "{{ datasource.user | default(omit) }}" + password: "{{ datasource.password | default(omit) }}" + additional_json_data: "{{ datasource.additional_json_data | default(omit) }}" + additional_secure_json_data: "{{ datasource.additional_secure_json_data | default(omit) }}" + loop: "{{ grafana_datasources }}" + loop_control: {loop_var: datasource} + tags: datasource -- name: Manage folder - community.grafana.grafana_folder: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "{{ folder.name }}" - state: "{{ folder.state | default(omit) }}" - skip_version_check: "{{ folder.skip_version_check | default(omit) }}" - loop: "{{ grafana_folders }}" - loop_control: {loop_var: folder} - tags: folder + - name: Manage folder + community.grafana.grafana_folder: + name: "{{ folder.name }}" + state: "{{ folder.state | default(omit) }}" + skip_version_check: "{{ folder.skip_version_check | default(omit) }}" + loop: "{{ grafana_folders }}" + loop_control: {loop_var: folder} + tags: folder -- name: Manage team - community.grafana.grafana_team: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "{{ team.name }}" - email: "{{ team.email }}" - members: "{{ team.members | default(omit) }}" - state: "{{ team.state | default(omit) }}" - enforce_members: "{{ team.enforce_members | default(omit) }}" - skip_version_check: "{{ team.skip_version_check | default(omit) }}" - loop: "{{ grafana_teams }}" - loop_control: {loop_var: team} - tags: team + - name: Manage team + community.grafana.grafana_team: + name: "{{ team.name }}" + email: "{{ team.email }}" + members: "{{ team.members | default(omit) }}" + state: "{{ team.state | default(omit) }}" + enforce_members: "{{ team.enforce_members | default(omit) }}" + skip_version_check: "{{ team.skip_version_check | default(omit) }}" + loop: "{{ grafana_teams }}" + loop_control: {loop_var: team} + tags: team -- name: Manage user - community.grafana.grafana_user: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - name: "{{ user.name }}" - email: "{{ user.email | default(omit) }}" - login: "{{ user.login }}" - password: "{{ user.password | default(omit) }}" - is_admin: "{{ user.is_admin | default(omit) }}" - state: "{{ user.state | default(omit) }}" - loop: "{{ grafana_users }}" - loop_control: {loop_var: user} - tags: user + - name: Manage user + community.grafana.grafana_user: + name: "{{ user.name }}" + email: "{{ user.email | default(omit) }}" + login: "{{ user.login }}" + password: "{{ user.password | default(omit) }}" + is_admin: "{{ user.is_admin | default(omit) }}" + state: "{{ user.state | default(omit) }}" + loop: "{{ grafana_users }}" + loop_control: {loop_var: user} + tags: user -- name: Manage dashboard - community.grafana.grafana_dashboard: - url: "{{ grafana_url }}" - url_username: "{{ grafana_username }}" - url_password: "{{ grafana_password }}" - org_id: "{{ dashboard.org_id | default(omit) }}" - folder: "{{ dashboard.folder | default(omit) }}" - state: "{{ dashboard.state | default(omit) }}" - slug: "{{ dashboard.slug | default(omit) }}" - uid: "{{ dashboard.uid | default(omit) }}" - path: "{{ dashboard.path | default(omit) }}" - overwrite: "{{ dashboard.overwrite | default(omit) }}" - dashboard_id: "{{ dashboard.dashboard_id | default(omit) }}" - dashboard_revision: "{{ dashboard.dashboard_revision | default(omit) }}" - commit_message: "{{ dashboard.commit_message | default(omit) }}" - loop: "{{ grafana_dashboards }}" - loop_control: {loop_var: dashboard} - tags: [dashboard, molecule-idempotence-notest] + - name: Manage dashboard + community.grafana.grafana_dashboard: + org_id: "{{ dashboard.org_id | default(omit) }}" + folder: "{{ dashboard.folder | default(omit) }}" + state: "{{ dashboard.state | default(omit) }}" + slug: "{{ dashboard.slug | default(omit) }}" + uid: "{{ dashboard.uid | default(omit) }}" + path: "{{ dashboard.path | default(omit) }}" + overwrite: "{{ dashboard.overwrite | default(omit) }}" + dashboard_id: "{{ dashboard.dashboard_id | default(omit) }}" + dashboard_revision: "{{ dashboard.dashboard_revision | default(omit) }}" + commit_message: "{{ dashboard.commit_message | default(omit) }}" + loop: "{{ grafana_dashboards }}" + loop_control: {loop_var: dashboard} + tags: [dashboard, molecule-idempotence-notest]