win_nssm: add idempotence tests
This commit is contained in:
parent
aba0d48ba5
commit
46a5e4f3bf
1 changed files with 112 additions and 1 deletions
|
@ -36,6 +36,26 @@
|
||||||
- (install_service_actual.stdout|from_json).StartMode == 'Auto'
|
- (install_service_actual.stdout|from_json).StartMode == 'Auto'
|
||||||
- (install_service_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
- (install_service_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
|
|
||||||
|
- name: test install service (idempotent)
|
||||||
|
win_nssm:
|
||||||
|
name: '{{ test_service_name }}'
|
||||||
|
application: C:\Windows\System32\cmd.exe
|
||||||
|
state: present
|
||||||
|
register: install_service_again
|
||||||
|
|
||||||
|
- name: get result of install service (idempotent)
|
||||||
|
win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}'
|
||||||
|
register: install_service_again_actual
|
||||||
|
|
||||||
|
- name: assert results of install service (idempotent)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install_service_again.changed == false
|
||||||
|
- (install_service_again_actual.stdout|from_json).Exists == true
|
||||||
|
- (install_service_again_actual.stdout|from_json).State == 'Stopped'
|
||||||
|
- (install_service_again_actual.stdout|from_json).StartMode == 'Auto'
|
||||||
|
- (install_service_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
|
|
||||||
- name: install and start service
|
- name: install and start service
|
||||||
win_nssm:
|
win_nssm:
|
||||||
name: '{{ test_service_name }}'
|
name: '{{ test_service_name }}'
|
||||||
|
@ -88,6 +108,39 @@
|
||||||
- '"Tcpip" in (install_service_complex_actual.stdout|from_json).Dependencies'
|
- '"Tcpip" in (install_service_complex_actual.stdout|from_json).Dependencies'
|
||||||
- '"Dnscache" in (install_service_complex_actual.stdout|from_json).Dependencies'
|
- '"Dnscache" in (install_service_complex_actual.stdout|from_json).Dependencies'
|
||||||
|
|
||||||
|
- name: install and start service with more parameters (idempotent)
|
||||||
|
win_nssm:
|
||||||
|
name: '{{ test_service_name }}'
|
||||||
|
application: C:\Windows\System32\cmd.exe
|
||||||
|
start_mode: manual
|
||||||
|
# Dependencies order should not trigger a change
|
||||||
|
dependencies: 'dnscache tcpip'
|
||||||
|
user: '{{ test_win_nssm_username }}'
|
||||||
|
password: '{{ test_win_nssm_password }}'
|
||||||
|
stdout_file: '{{ test_win_nssm_path }}\log.txt'
|
||||||
|
stderr_file: '{{ test_win_nssm_path }}\error.txt'
|
||||||
|
state: started
|
||||||
|
register: install_service_complex_again
|
||||||
|
|
||||||
|
- name: get result of install and start service with more parameters (idempotent)
|
||||||
|
win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}'
|
||||||
|
register: install_service_complex_again_actual
|
||||||
|
|
||||||
|
- name: assert results of install and start service with more parameters (idempotent)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- install_service_complex_again.changed == false
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).Exists == true
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).State == 'Running'
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).StartMode == 'Manual'
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).StartName == '.\\' + test_win_nssm_username
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).Parameters.AppStdout == test_win_nssm_path + '\\log.txt'
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).Parameters.AppStderr == test_win_nssm_path + '\\error.txt'
|
||||||
|
- (install_service_complex_again_actual.stdout|from_json).Dependencies|length == 2
|
||||||
|
- '"Tcpip" in (install_service_complex_again_actual.stdout|from_json).Dependencies'
|
||||||
|
- '"Dnscache" in (install_service_complex_again_actual.stdout|from_json).Dependencies'
|
||||||
|
|
||||||
- name: install service with free form parameters
|
- name: install service with free form parameters
|
||||||
win_nssm:
|
win_nssm:
|
||||||
name: '{{ test_service_name }}'
|
name: '{{ test_service_name }}'
|
||||||
|
@ -108,6 +161,26 @@
|
||||||
- (free_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
- (free_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
- (free_params_actual.stdout|from_json).Parameters.AppParameters == "-v -Dcom.test.string=value test"
|
- (free_params_actual.stdout|from_json).Parameters.AppParameters == "-v -Dcom.test.string=value test"
|
||||||
|
|
||||||
|
- name: install service with free form parameters (idempotent)
|
||||||
|
win_nssm:
|
||||||
|
name: '{{ test_service_name }}'
|
||||||
|
application: C:\Windows\System32\cmd.exe
|
||||||
|
app_parameters_free_form: '-v -Dcom.test.string=value test'
|
||||||
|
state: present
|
||||||
|
register: free_params_again
|
||||||
|
|
||||||
|
- name: get result of install service with free form parameters (idempotent)
|
||||||
|
win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}'
|
||||||
|
register: free_params_again_actual
|
||||||
|
|
||||||
|
- name: assert results of install service with free form parameters (idempotent)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- free_params_again.changed == false
|
||||||
|
- (free_params_again_actual.stdout|from_json).Exists == true
|
||||||
|
- (free_params_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
|
- (free_params_again_actual.stdout|from_json).Parameters.AppParameters == "-v -Dcom.test.string=value test"
|
||||||
|
|
||||||
- name: install service with dict parameters
|
- name: install service with dict parameters
|
||||||
win_nssm:
|
win_nssm:
|
||||||
name: '{{ test_service_name }}'
|
name: '{{ test_service_name }}'
|
||||||
|
@ -130,6 +203,28 @@
|
||||||
- (mixed_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
- (mixed_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
- (mixed_params_actual.stdout|from_json).Parameters.AppParameters == "bar -file.out output.bat foo True"
|
- (mixed_params_actual.stdout|from_json).Parameters.AppParameters == "bar -file.out output.bat foo True"
|
||||||
|
|
||||||
|
- name: install service with dict parameters (idempotent)
|
||||||
|
win_nssm:
|
||||||
|
name: '{{ test_service_name }}'
|
||||||
|
application: C:\Windows\System32\cmd.exe
|
||||||
|
app_parameters:
|
||||||
|
foo: true
|
||||||
|
'-file.out': 'output.bat'
|
||||||
|
_: bar
|
||||||
|
register: mixed_params_again
|
||||||
|
|
||||||
|
- name: get result of install service with dict parameters (idempotent)
|
||||||
|
win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}'
|
||||||
|
register: mixed_params_again_actual
|
||||||
|
|
||||||
|
- name: assert results of install service with dict parameters (idempotent)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- mixed_params_again.changed == false
|
||||||
|
- (mixed_params_again_actual.stdout|from_json).Exists == true
|
||||||
|
- (mixed_params_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe"
|
||||||
|
- (mixed_params_again_actual.stdout|from_json).Parameters.AppParameters == "bar -file.out output.bat foo True"
|
||||||
|
|
||||||
- name: remove service
|
- name: remove service
|
||||||
win_nssm:
|
win_nssm:
|
||||||
name: '{{ test_service_name }}'
|
name: '{{ test_service_name }}'
|
||||||
|
@ -144,4 +239,20 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- remove_service.changed == true
|
- remove_service.changed == true
|
||||||
- (remove_service_actual.stdout|from_json).Exists == false
|
- (remove_service_actual.stdout|from_json).Exists == false
|
||||||
|
|
||||||
|
- name: remove service (idempotent)
|
||||||
|
win_nssm:
|
||||||
|
name: '{{ test_service_name }}'
|
||||||
|
state: absent
|
||||||
|
register: remove_service_again
|
||||||
|
|
||||||
|
- name: get result of remove service (idempotent)
|
||||||
|
win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}'
|
||||||
|
register: remove_service_again_actual
|
||||||
|
|
||||||
|
- name: assert results of remove service (idempotent)
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- remove_service_again.changed == false
|
||||||
|
- (remove_service_again_actual.stdout|from_json).Exists == false
|
Loading…
Reference in a new issue