Centos

我可以在安裝 yum 軟體包時自動接受 MS SQL 許可條款嗎?

  • October 17, 2017

我正在使用AnsibleMS SQL Server 2017配置到CentOS 7.4機器。我首先通過命令行瀏覽了本指南並且它有效,但我的最終目標是“Ansible-ize”它。但是,當我進入有關安裝命令行工具的步驟時,該-y開關不適用於接受許可證。

[user@host ~]$ sudo yum install -y mssql-tools unixODBC-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mssql-tools.x86_64 0:14.0.6.0-1 will be installed
--> Processing Dependency: msodbcsql < 13.2.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
--> Processing Dependency: msodbcsql >= 13.1.0.0 for package: mssql-tools-14.0.6.0-1.x86_64
---> Package unixODBC-devel.x86_64 0:2.3.1-11.el7 will be installed
--> Running transaction check
---> Package msodbcsql.x86_64 0:13.1.9.1-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package          Arch     Version          Repository                     Size
================================================================================
Installing:
mssql-tools      x86_64   14.0.6.0-1       packages-microsoft-com-prod   249 k
unixODBC-devel   x86_64   2.3.1-11.el7     pwbank_repo                    55 k
Installing for dependencies:
msodbcsql        x86_64   13.1.9.1-1       packages-microsoft-com-prod   4.0 M

Transaction Summary
================================================================================
Install  2 Packages (+1 Dependent package)

Total size: 4.2 M
Installed size: 4.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
The license terms for this product can be downloaded from
https://aka.ms/odbc131eula and found in
/usr/share/doc/msodbcsql/LICENSE.TXT . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
 Installing : msodbcsql-13.1.9.1-1.x86_64                                  1/3 
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.

Do you accept the license terms? (Enter YES or NO)
YES
 Installing : mssql-tools-14.0.6.0-1.x86_64                                2/3 
 Installing : unixODBC-devel-2.3.1-11.el7.x86_64                           3/3 
 Verifying  : msodbcsql-13.1.9.1-1.x86_64                                  1/3 
 Verifying  : unixODBC-devel-2.3.1-11.el7.x86_64                           2/3 
 Verifying  : mssql-tools-14.0.6.0-1.x86_64                                3/3 

Installed:
 mssql-tools.x86_64 0:14.0.6.0-1      unixODBC-devel.x86_64 0:2.3.1-11.el7     

Dependency Installed:
 msodbcsql.x86_64 0:13.1.9.1-1                                                 

Complete!

我注意到在提示我說*RPMDB 在 yum 之外更改之前有一個警告。*這是否意味著微軟以自己的方式專門修改了這個rpm,因此yum不知道如何處理它?

我的目標

儘管以上內容適用於“手動”安裝,但我正在嘗試“ansible-ize”以上內容。我的劇本一直有效,直到我得到這個劇本:

- name: Upgrade all installed packages, and install new ones
 package:
   name: '{{item}}'
   state: latest
 with_items:
   - '*'
   - mssql-server
   - mssql-tools
   - unixODBC-devel

上面的播放將更新我目前安裝的所有軟體包並安裝MS SQL Server 2017就好了,但是在嘗試安裝mssql-tools軟體包時它會掛起,我假設因為它正在等待使用者接受許可證。

我的問題

如果我的劇本掛起,等待使用者接受許可證,我該如何“ansible-ize”這個安裝?

對於獎勵積分,有一個步驟我必須執行sudo /opt/mssql/bin/mssql-conf setup並按照螢幕上的提示進行操作,這再次阻礙了我的配置。我正在檢查它一次,找到它的輸出文件,看看我是否不能在我重新提供一個新盒子時把它複製進去。或者,我正在閱讀Expect

- name: install mssql-server repo (CentOS, RedHat)
 get_url:
   url: "{{ centos_repo_url }}"
   dest: /etc/yum.repos.d/mssql-server.repo
 when: ansible_distribution in ['CentOS', 'RedHat']

- name: install mssql-server repo (Ubuntu)
 get_url:
   url: "{{ ubuntu_repo_url }}"
   dest: /etc/apt/sources.list.d/mssql-server.list
 when: ansible_distribution == 'Ubuntu'

- name: refresh apt-get cache for server repo (Ubuntu)
 command: apt-get update
 when: ansible_distribution == 'Ubuntu'

- name: install mssql-server package
 package:
   name: mssql-server
   state: latest

- name: install mssql-tools package
 package:
   name: mssql-tools
   state: latest
 environment:
   ACCEPT_EULA: 'y'

https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability提供了用於安裝和配置 SQL Server(以及創建 Pacemaker 管理的可用性組)的範例手冊/Linux/Ansible%20劇本

引用自:https://unix.stackexchange.com/questions/395694