On developing ansible role to install SQL Server, I need to develope playbook to uninstall SQL Server.
See below the way to uninstall SQL Server on Windows Server.
- name: Stop SQL Server Agent
win_service:
name: SQLSERVERAGENT
state: stopped
- name: Stop SQL Server
win_service:
name: MSSQLSERVER
state: stopped
- name: Uninstall SQL 2014 (this is not version specific task)
win_shell: |
chcp 949
.\setup.exe /action=uninstall /features=SQLENGINE /instancename=MSSQLSERVER /q
args:
chdir: D:\SQL2K14-SP2-STD-x64-KR\ # directory which setup.exe is placed.
executable: cmd
- name: Remove SQL related files
win_shell: |
rd /s /q "C:\\Program Files\\Microsoft SQL Server"
rd /s /q "D:\\MSSQL"
args:
executable: cmd
- name: Delete x86 Reg Key
win_regedit:
path: HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server
delete_key: yes
state: absent
- name: Delete x64 Reg Key
win_regedit:
path: HKLM:\SOFTWARE\Microsoft\Wow6432Node\Microsoft SQL Server
delete_key: yes
state: absent
At 3rd task If you use locale specific SQL Install file, you should use chcp command before run setup.exe command.
if don't you might see below error.
This SQL Server setup media does not support the language of the OS, or does not hyave the SQL Server English-language version installation files. Use the matching language media; or install both the language specific MUI and change the format and system locales through the regional setting in the control panel.
The SQL installed on Windows 2012. The OS set locale ko-kr and Setup file as well.
I solve this problem within chcp 949 command. this chcp command option 949 would depends on your locale setting.
'Devops > Ansible' 카테고리의 다른 글
병렬 백업과 복원을 위한 async 작업 (0) | 2022.08.30 |
---|---|
MSSQL 별칭 관리 (0) | 2022.08.30 |
Windows에서 Ansible 사용하기 (0) | 2019.06.25 |
Ansible : Public Key 자동 배포 (0) | 2019.04.12 |
Ansible Roles (0) | 2019.04.12 |