You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/win_chocolatey_config/tasks/tests.yml

142 lines
3.4 KiB
YAML

---
- name: fail if value is not set and state=present
win_chocolatey_config:
name: cacheLocation
state: present
register: fail_no_value
failed_when: 'fail_no_value.msg != "Get-AnsibleParam: Missing required argument: value"'
- name: fail to set invalid config name
win_chocolatey_config:
name: fake
state: present
value: value
register: fail_invalid_name
failed_when: '"The Chocolatey config ''fake'' is not an existing config value, check the spelling. Valid config names: " not in fail_invalid_name.msg'
- name: set config setting (check mode)
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\temp
check_mode: yes
register: set_check
- name: get actual config setting (check mode)
win_command: choco.exe config get -r --name cacheLocation
register: set_actual_check
- name: assert set config setting (check mode)
assert:
that:
- set_check is changed
- set_actual_check.stdout_lines == [""]
- name: set config setting
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\temp
register: set
- name: get actual config setting
win_command: choco.exe config get -r --name cacheLocation
register: set_actual
- name: assert set config setting
assert:
that:
- set is changed
- set_actual.stdout_lines == ["C:\\temp"]
- name: change config value (check mode)
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\temp2
check_mode: yes
register: change_check
- name: get actual config setting (check mode)
win_command: choco.exe config get -r --name cacheLocation
register: change_actual_check
- name: assert change config value (check mode)
assert:
that:
- change_check is changed
- change_actual_check.stdout_lines == ["C:\\temp"]
- name: change config value
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\temp2
register: change
- name: get actual config setting
win_command: choco.exe config get -r --name cacheLocation
register: change_actual
- name: assert change config value
assert:
that:
- change is changed
- change_actual.stdout_lines == ["C:\\temp2"]
- name: change config value (idempotent)
win_chocolatey_config:
name: cacheLocation
state: present
value: C:\temp2
register: change_again
- name: assert change config value (idempotent)
assert:
that:
- not change_again is changed
- name: unset config value (check mode)
win_chocolatey_config:
name: cacheLocation
state: absent
check_mode: yes
register: unset_check
- name: get actual config setting (check mode)
win_command: choco.exe config get -r --name cacheLocation
register: unset_actual_check
- name: assert unset config value (check mode)
assert:
that:
- unset_check is changed
- unset_actual_check.stdout_lines == ["C:\\temp2"]
- name: unset config value
win_chocolatey_config:
name: cacheLocation
state: absent
register: unset
- name: get actual config setting
win_command: choco.exe config get -r --name cacheLocation
register: unset_actual
- name: assert unset config value
assert:
that:
- unset is changed
- unset_actual.stdout_lines == [""]
- name: unset config value (idempotent)
win_chocolatey_config:
name: cacheLocation
state: absent
register: unset_again
- name: assert unset config value (idempotent)
assert:
that:
- not unset_again is changed