|
| 1 | +--- |
| 2 | +- name: Create dashboard from ID with custom name | check mode | dashboard does not exist |
| 3 | + community.grafana.grafana_dashboard: |
| 4 | + state: present |
| 5 | + commit_message: Updated by ansible |
| 6 | + dashboard_id: "7587" |
| 7 | + dashboard_revision: "1" |
| 8 | + overwrite: true |
| 9 | + uid: "dfi" |
| 10 | + name: "Different Name" |
| 11 | + check_mode: true |
| 12 | + register: dfi_result1 |
| 13 | +- ansible.builtin.assert: |
| 14 | + that: |
| 15 | + - dfi_result1.failed == false |
| 16 | + - dfi_result1.changed == true |
| 17 | + - dfi_result1.uid is not defined |
| 18 | + - dfi_result1.msg == 'Dashboard Different Name will be created' |
| 19 | + |
| 20 | +- name: Create dashboard from ID with custom name | run mode | dashboard does not exist |
| 21 | + community.grafana.grafana_dashboard: |
| 22 | + state: present |
| 23 | + commit_message: Updated by ansible |
| 24 | + dashboard_id: "7587" |
| 25 | + dashboard_revision: "1" |
| 26 | + overwrite: true |
| 27 | + uid: "dfi" |
| 28 | + name: "Different Name" |
| 29 | + check_mode: false |
| 30 | + register: dfi_result2 |
| 31 | +- ansible.builtin.assert: |
| 32 | + that: |
| 33 | + - dfi_result2.failed == false |
| 34 | + - dfi_result2.changed == true |
| 35 | + - dfi_result2.uid is truthy |
| 36 | + - dfi_result2.uid == 'dfi' |
| 37 | + - dfi_result2.msg == 'Dashboard Different Name created' |
| 38 | + |
| 39 | +- name: Create dashboard from ID with custom name | check mode | dashboard exists |
| 40 | + community.grafana.grafana_dashboard: |
| 41 | + state: present |
| 42 | + commit_message: Updated by ansible |
| 43 | + dashboard_id: "7587" |
| 44 | + dashboard_revision: "1" |
| 45 | + overwrite: true |
| 46 | + uid: "dfi" |
| 47 | + name: "Different Name" |
| 48 | + check_mode: true |
| 49 | + register: dfi_result3 |
| 50 | +- ansible.builtin.assert: |
| 51 | + that: |
| 52 | + - dfi_result3.failed == false |
| 53 | + - dfi_result3.changed == false |
| 54 | + - dfi_result3.uid is truthy |
| 55 | + - dfi_result3.uid == 'dfi' |
| 56 | + - dfi_result3.msg == 'Dashboard Different Name unchanged.' |
| 57 | + |
| 58 | +- name: Create dashboard from ID with custom name | run mode | dashboard exists |
| 59 | + community.grafana.grafana_dashboard: |
| 60 | + state: present |
| 61 | + commit_message: Updated by ansible |
| 62 | + dashboard_id: "7587" |
| 63 | + dashboard_revision: "1" |
| 64 | + overwrite: true |
| 65 | + uid: "dfi" |
| 66 | + name: "Different Name" |
| 67 | + check_mode: false |
| 68 | + register: dfi_result4 |
| 69 | +- ansible.builtin.assert: |
| 70 | + that: |
| 71 | + - dfi_result4.failed == false |
| 72 | + - dfi_result4.changed == false |
| 73 | + - dfi_result4.uid is truthy |
| 74 | + - dfi_result4.uid == 'dfi' |
| 75 | + - dfi_result4.msg == 'Dashboard Different Name unchanged.' |
| 76 | + |
| 77 | +- ansible.builtin.include_tasks: |
| 78 | + file: delete-dashboard.yml |
| 79 | + vars: |
| 80 | + uid_to_delete: "{{ dfi_result4.uid }}" |
| 81 | + |
| 82 | +- name: Create dashboard from ID with default name | run mode | dashboard does not exist |
| 83 | + community.grafana.grafana_dashboard: |
| 84 | + state: present |
| 85 | + commit_message: Updated by ansible |
| 86 | + dashboard_id: "9578" |
| 87 | + dashboard_revision: "1" |
| 88 | + overwrite: true |
| 89 | + uid: "dfi" |
| 90 | + check_mode: false |
| 91 | + register: dfi_result5 |
| 92 | +- ansible.builtin.assert: |
| 93 | + that: |
| 94 | + - dfi_result5.failed == false |
| 95 | + - dfi_result5.changed == true |
| 96 | + - dfi_result5.uid is truthy |
| 97 | + - dfi_result5.uid == 'dfi' |
| 98 | + - dfi_result5.msg == 'Dashboard Alertmanager created' |
| 99 | + |
| 100 | +- name: Rename existing dashboard | check mode | dashboard has original name |
| 101 | + community.grafana.grafana_dashboard: |
| 102 | + state: present |
| 103 | + commit_message: Updated by ansible |
| 104 | + dashboard_id: "9578" |
| 105 | + dashboard_revision: "1" |
| 106 | + overwrite: true |
| 107 | + uid: "dfi" |
| 108 | + name: "Renamed" |
| 109 | + check_mode: true |
| 110 | + register: dfi_result6 |
| 111 | +- ansible.builtin.assert: |
| 112 | + that: |
| 113 | + - dfi_result6.failed == false |
| 114 | + - dfi_result6.changed == true |
| 115 | + - dfi_result6.uid is truthy |
| 116 | + - dfi_result6.uid == 'dfi' |
| 117 | + - dfi_result6.msg == 'Dashboard Renamed will be updated' |
| 118 | + |
| 119 | +- name: Rename existing dashboard | run mode | dashboard has original name |
| 120 | + community.grafana.grafana_dashboard: |
| 121 | + state: present |
| 122 | + commit_message: Updated by ansible |
| 123 | + dashboard_id: "9578" |
| 124 | + dashboard_revision: "1" |
| 125 | + overwrite: true |
| 126 | + uid: "dfi" |
| 127 | + name: "Renamed" |
| 128 | + check_mode: false |
| 129 | + register: dfi_result7 |
| 130 | +- ansible.builtin.assert: |
| 131 | + that: |
| 132 | + - dfi_result7.failed == false |
| 133 | + - dfi_result7.changed == true |
| 134 | + - dfi_result7.uid is truthy |
| 135 | + - dfi_result7.uid == 'dfi' |
| 136 | + - dfi_result7.msg == 'Dashboard Renamed updated' |
| 137 | + |
| 138 | +- name: Rename existing dashboard | run mode | dashboard has been renamed |
| 139 | + community.grafana.grafana_dashboard: |
| 140 | + state: present |
| 141 | + commit_message: Updated by ansible |
| 142 | + dashboard_id: "9578" |
| 143 | + dashboard_revision: "1" |
| 144 | + overwrite: true |
| 145 | + uid: "dfi" |
| 146 | + name: "Renamed" |
| 147 | + check_mode: false |
| 148 | + register: dfi_result8 |
| 149 | +- ansible.builtin.assert: |
| 150 | + that: |
| 151 | + - dfi_result8.failed == false |
| 152 | + - dfi_result8.changed == false |
| 153 | + - dfi_result8.uid is truthy |
| 154 | + - dfi_result8.uid == 'dfi' |
| 155 | + - dfi_result8.msg == 'Dashboard Renamed unchanged.' |
| 156 | + |
| 157 | +- ansible.builtin.include_tasks: |
| 158 | + file: delete-dashboard.yml |
| 159 | + vars: |
| 160 | + uid_to_delete: "{{ dfi_result8.uid }}" |
0 commit comments