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

82 lines
2.3 KiB
YAML

---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Copying {{BOInstall}} to {{ inventory_hostname }}
- name: Prepare install target
ansible.windows.win_file:
path: D:\BOInstall
state: directory
- name: Copy BOInstall
win_copy:
src: ~/ansible/install/{{BOInstall}}
dest: D:\BOInstall\{{BOInstall}}
- name: Copy Config
win_copy:
src: ~/ansible/install/config/{{ configVersion }}/{{ configName }}/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Installing {{BOInstall}} on {{ inventory_hostname }}
- name: Run {{BOInstall}}
ansible.windows.win_powershell:
script: |
iex "cmd /c D:\BOInstall\{{BOInstall}} /PlatFormFilesPath=D:\BOInstall\Config /ForceReboot=False /S"
Start-Sleep -Seconds 30
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Checking final errorstatus 0 on {{ inventory_hostname }}
- name: Final errorstatus
ansible.windows.win_powershell:
script: |
$newestLog = Get-Item D:\IFSBOSystem\InstallLog\BOInstall_*.log | Sort LastWriteTime -Descending | Select-Object -First 1
$result = $newestLog | Select-String -Pattern 'The final errorstatus is ([0-9]+)'
if($result.Matches[0].Groups[1].Value -ne 0) {
$Ansible.Failed = $true
}
#- name: Send notification message via Slack
# delegate_to: localhost
# community.general.slack:
# token: "{{ slack_token }}"
# msg: Running fixlog4net on {{ inventory_hostname }}
#- name: Copy fixlog4net
# win_copy:
# src: ~/ansible/install/fixlog4net.ps1
# dest: D:\BOInstall\fixlog4net.ps1
#- name: Run fixlog4net
# ansible.windows.win_powershell:
# script: |
# D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Rebooting {{ inventory_hostname }}
- name: Reboot
win_reboot:
- name: Clean up
ansible.windows.win_file:
path: D:\BOInstall
state: absent