我的目标

我的目标

我在用安西布尔提供微软 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 之外进行了更改。这是否意味着 Microsoft 以自己的方式专门修改了此 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

上面的播放将更新我当前安装的所有软件包并安装微软 SQL Server 2017很好,但是在尝试安装时它会挂起mssql工具包,我假设是因为它正在等待用户接受许可证。

我的问题

如果我的剧本挂起,等待用户接受许可证,我如何“ansible-ize”此安装?

为了获得奖励积分,有一个步骤我必须运行sudo /opt/mssql/bin/mssql-conf setup并按照屏幕上的提示进行操作,这再次阻碍了我的配置。我正在检查它一次,找到它的输出文件,看看我是否不能在重新配置新盒子时将其复制进去。或者,我正在阅读预计

答案1

- 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'

用于安装和配置 SQL Server(以及创建 Pacemaker 管理的可用性组)的示例手册可在https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/high%20availability/Linux/Ansible%20Playbook

答案2

这应该适用于工具的 EULA

sudo ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev

就无人值守安装而言,您可以在安装过程中为大多数事情指定环境变量或命令行选项。看一眼示例:适用于 Red Hat Enterprise Linux 的无人值守 SQL Server 安装脚本

笔记:我注意到链接中的存储库仍然指向旧的 RTM 之前的存储库。请用这些回购协议当我们纠正它们时。

答案3

如果您使用 rpm -ivh 并希望以非交互方式运行安装程序。请按照提到的步骤操作。

在 Ubuntu 和 redat/ubi8-init 上测试

  • 导出 ACCEPT_EULA='y'
  • rpm -ivh <软件包名称>

如果您尝试在 Dockerfile 中实现相同的目标,请使用以下命令:

RUN 导出 ACCEPT_EULA='y' && rpm -ivh msodbcsql****.rpm

笔记:确保导出和 rpm 命令是针对单个运行的问题。

相关内容