|
1 | 1 | --- |
2 | | -- name: Verify OpenStack Rating Module are correctly enabled, disabled |
3 | | - hosts: localhost |
4 | | - connection: local |
5 | | - gather_facts: false |
| 2 | +- name: Get status of all CloudKitty rating modules |
| 3 | + ansible.builtin.command: |
| 4 | + cmd: "openstack rating module list" |
| 5 | + changed_when: false |
| 6 | + register: module_list |
6 | 7 |
|
7 | | - tasks: |
8 | | - - name: Verify that exactly 2 rating modules are enabled |
9 | | - become: true |
10 | | - ansible.builtin.shell: |
11 | | - cmd: "[[ $(openstack rating module list | grep True | wc -l) -eq 2 ]]" |
12 | | - changed_when: false |
| 8 | +- name: TEST Validate CloudKitty module states |
| 9 | + ansible.builtin.assert: |
| 10 | + that: |
| 11 | + - "'noop' in module_list.stdout and 'True' in (module_list.stdout_lines | select('search', 'noop') | first)" |
| 12 | + - "'hashmap' in module_list.stdout and 'True' in (module_list.stdout_lines | select('search', 'hashmap') | first)" |
| 13 | + - "'pyscripts' in module_list.stdout and 'False' in (module_list.stdout_lines | select('search', 'pyscripts') | first)" |
| 14 | + fail_msg: "CloudKitty module validation FAILED. Module states are not as expected." |
| 15 | + success_msg: "SUCCESS: CloudKitty modules (noop=True, hashmap=True, pyscripts=False) are configured correctly." |
13 | 16 |
|
14 | | - - name: Verify that exactly 1 'pyscripts' module is disabled |
15 | | - become: true |
16 | | - ansible.builtin.shell: |
17 | | - cmd: "[[ $(openstack rating module list | grep pyscripts | grep False | wc -l) -eq 1 ]]" |
18 | | - changed_when: false |
| 17 | +- name: Find the current value of hashmap |
| 18 | + ansible.builtin.shell: |
| 19 | + cmd: | |
| 20 | + "openstack rating module get hashmap -c Priority -f csv | tail -n +2" |
| 21 | + register: start_hashmap_priority |
| 22 | + changed_when: start_hashmap_priority.stdout | trim != '100' |
19 | 23 |
|
| 24 | +- name: TEST Set priority for CloudKitty hashmap module |
| 25 | + ansible.builtin.command: |
| 26 | + cmd: "openstack rating module set priority hashmap 100" |
| 27 | + register: set_hashmap_priority |
| 28 | + when: start_hashmap_priority.stdout | trim != '100' |
| 29 | + failed_when: set_hashmap_priority.rc >= 1 or set_hashmap_priority.stdout == "" |
| 30 | + changed_when: set_hashmap_priority.rc == 0 |
| 31 | + |
| 32 | +- name: Print result of hashmap priority value change |
| 33 | + ansible.builtin.debug: |
| 34 | + msg: "The hashmap priority is set to 100" |
| 35 | + when: (start_hashmap_priority.stdout | trim == '100') or (set_hashmap_priority.rc is defined and set_hashmap_priority.rc == 0) |
0 commit comments