Files
ansible/oldstuff/tasks/stop-ifsbo.yaml
2024-09-12 09:27:25 +00:00

37 lines
1.1 KiB
YAML

---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Stopping IFSBO on {{ inventory_hostname }}
- name: IFSBO-Stop
ansible.windows.win_powershell:
script: |
$forceQuit = $false
# ensure agent is running
Get-Service -DisplayName 'IFS HouseKeeping Agent' | Start-Service -ErrorAction Stop
# connect to agent
$proxy = New-WebServiceProxy -Uri 'http://localhost:9080/HouseKeepingAgentService/'
# initiate shutdown
$proxy.Shutdown($forceQuit, $true)
# Start retry loop
:retry for($retry = 0; $retry -lt 60; $retry++) {
Start-Sleep -Seconds 5
# if any component is still running, restart retry loop
foreach($component in $components) {
if($component.Status -eq 'Running') {
continue retry
}
}
# no components running
if($retry -eq 59) {
$forceQuit = $true
}
# break retry loop
break retry
}
# Shutdown agent
$proxy.ShutdownAndQuit($forceQuit, $true)