Sql server 运行SQL Server powershell脚本时Ansible失败
我正在尝试通过Ansible运行SQL Server部署PowerShell脚本,但SQL Server部署日志指出以下错误: 生成XML文档时出错 我可以登录到windows服务器并手动运行,安装没有问题,但通过Ansible运行时失败 我怀疑有一些特权升级需要,我已经使用成为_用户,但这并没有什么区别。我明白,设置“变成”不适用于Windows PowerShell外壳系列与sudo Been插件不兼容 所以我也有点困惑 我同时管理windows和linux服务器,Ansible通过docker容器中的gitlab管道运行 脚本将为部署生成一个ini文件: 任务:Sql server 运行SQL Server powershell脚本时Ansible失败,sql-server,powershell,ansible,Sql Server,Powershell,Ansible,我正在尝试通过Ansible运行SQL Server部署PowerShell脚本,但SQL Server部署日志指出以下错误: 生成XML文档时出错 我可以登录到windows服务器并手动运行,安装没有问题,但通过Ansible运行时失败 我怀疑有一些特权升级需要,我已经使用成为_用户,但这并没有什么区别。我明白,设置“变成”不适用于Windows PowerShell外壳系列与sudo Been插件不兼容 所以我也有点困惑 我同时管理windows和linux服务器,Ansible通过dock
---
- name: Download SQL media directory
ansible.windows.win_get_url:
url: "{{ package_registry }}/{{ package_name }}/{{ artifact_version }}/{{ sql_media_artifact_name }}"
dest: C:\Temp
force: no
headers:
PRIVATE-TOKEN: "{{ gitlab_pac }}"
- name: Extract sqlmedia zip package
community.windows.win_unzip:
src: C:\Temp\{{ sql_media_artifact_name }}
dest: C:\
creates: C:\SQLMedia
- name: Download the SQL ISO package
ansible.windows.win_get_url:
url: "{{ package_registry }}/{{ package_name }}/{{ artifact_version }}/{{ sqliso_artifact_name }}"
dest: C:\SQLMedia
force: no
headers:
PRIVATE-TOKEN: "{{ gitlab_pac }}"
- name: Download the cumulative update package
ansible.windows.win_get_url:
url: "{{ package_registry }}/{{ package_name }}/{{ artifact_version }}/{{ sqlcu_artifact_name }}"
dest: C:\SQLMedia
force: no
headers:
PRIVATE-TOKEN: "{{ gitlab_pac }}"
- name: Extract cumulative update zip package
community.windows.win_unzip:
src: C:\SQLMedia\{{ sqlcu_artifact_name }}
dest: C:\SQLMedia\Updates\2017
creates: C:\SQLMedia\Updates\2017\{{ sqlcu_artifact_name }}
- name: Download the SSMS package
ansible.windows.win_get_url:
url: "{{ package_registry }}/{{ package_name }}/{{ artifact_version }}/{{ ssms_artifact_name }}"
dest: C:\SQLMedia\Updates\SSMS
force: no
headers:
PRIVATE-TOKEN: "{{ gitlab_pac }}"
- name: Mount the ISO
community.windows.win_disk_image:
image_path: C:\SQLMedia\{{ sqliso_artifact_name }}
state: present
- name: Create the conf file
ansible.windows.win_template:
src: ConfInput.txt.j2
dest: C:\SQLMedia\SQLServerSilentInstall\Conf\ConfInput.txt
- name: Run the deployment install script
ansible.windows.win_shell: powershell.exe -ExecutionPolicy Bypass .\MSSQL-SilentInstall.ps1 -Install
become_user: Administrator
args:
chdir: C:\SQLMedia\SQLServerSilentInstall
剧本:
---
- hosts: app_db
gather_facts: yes
become: no
roles:
- roles/app_db
- roles/win_locale
可能的错误:
TASK [app_db : Run the deployment install script] ************************************************************************************************************************************************************
fatal: [host-name]: FAILED! => {"changed": true, "cmd": "powershell.exe -ExecutionPolicy Bypass .\\MSSQL-SilentInstall.ps1 -Install", "delta": "0:00:23.091338", "end": "2021-06-01 03:51:50.476653", "msg": "non-zero return code", "rc": 1, "start": "2021-06-01 03:51:27.385314", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
PowerShell shell系列与sudo Been插件不兼容
=>您是否尝试过设置Been_方法:runas
@谢谢你。这就解决了问题。