summaryrefslogtreecommitdiff
path: root/test/integration/targets/vmware_vcenter_statistics/tasks/main.yml
blob: 98afb59bd3ea90aff9fd03c2d0dc23150beef807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Test code for the vmware_vcenter_statistics module.
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- import_role:
    name: prepare_vmware_tests

- name: Disable all the statistics
  vmware_vcenter_statistics:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    interval_past_day:
      enabled: false
    interval_past_week:
      enabled: false
    interval_past_month:
      enabled: false
    interval_past_year:
      enabled: false
    validate_certs: no
  register: statistics_results_check_mode

- name: Configure statistics in check mode
  vmware_vcenter_statistics: &stats
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    interval_past_day:
      enabled: true
      interval_minutes: 5
      save_for_days: 3
      level: 2
    interval_past_week:
      enabled: true
      interval_minutes: 30
      save_for_weeks: 1
      level: 2
    interval_past_month:
      enabled: true
      interval_hours: 2
      save_for_months: 1
      level: 1
    interval_past_year:
      enabled: true
      interval_days: 1
      save_for_years: 1
      level: 1
    validate_certs: no
  register: statistics_results_check_mode
  check_mode: yes

- debug: var=statistics_results_check_mode

- name: ensure statistics were configured
  assert:
    that:
      # Doesn't really work with vcsim. No matter which settings are used; they are always shown as already configured!?
      - statistics_results_check_mode is changed
  when: vcsim is not defined

- name: Configure statistics
  vmware_vcenter_statistics:
    <<: *stats
  register: statistics_results

- debug: var=statistics_results

- name: ensure statistics were configured
  assert:
    that:
      - statistics_results is changed
  when: vcsim is not defined

- name: Configure statistics (again)
  vmware_vcenter_statistics:
    <<: *stats
  register: statistics_results

- debug: var=statistics_results

- name: ensure statistics were configured
  assert:
    that:
      - not (statistics_results is changed)
  when: vcsim is not defined