--- - name: Send notification message via Slack delegate_to: localhost community.general.slack: token: "{{ slack_token }}" msg: Starting IFSBO on {{ inventory_hostname }} - name: IFSBO-Start ansible.windows.win_powershell: script: |- # start agent service Get-Service -DisplayName 'IFS HouseKeeping Agent' | Start-Service # connect to agent $proxy = New-WebServiceProxy -Uri 'http://localhost:9080/HouseKeepingAgentService/' $proxy.Startup() # start retry loop :retry for($retry = 0; $retry -lt 60; $retry++) { Start-Sleep -Seconds 5 # get component status $components = $proxy.ComponentsInfo() # if any component is not running, restart retry loop foreach($component in $components) { if($component.Status -eq 'Error') { throw "Component $($component.Name) has failed to start" } if($component.Status -ne 'Running') { continue retry } } # break retry loop break retry }