MySQL 8 的 Ansible 安装 - 在没有 mysql-apt-config 的情况下安装存储库

joh*_*ken 3 ansible ansible-2.x mysql-8.0

我正在尝试使用 ansible 自动安装 MySQL 8。

但是,此安装需要获取mysql-apt-config。安装后,打开一个配置窗口

mysql-apt-config-安装

我想绕过这个配置,而是使用apt_repository.

正确的地址是什么?我在哪里可以找到这个存储库地址,以便我可以使用 下载和安装 MySQL apt

这给 ansible 带来了一个问题——我不知道如何在这个窗口中放置一个选项。我试过expect模块

- name: install mysql repo
  expect:
    command: "dpkg -i /tmp/mysql-apt-config.deb"
    responses: 
      Question:
        - response4
  become: yes
  become_method: sudo
Run Code Online (Sandbox Code Playgroud)

然而,这引发了以下错误

TASK [mysql : install mysql repo] ******************************************************************************
fatal: [testserver]: FAILED! => {"changed": false, "msg": "The pexpect python module is required"}
Run Code Online (Sandbox Code Playgroud)

我查了一下,pexpect 模块可用。

是否有可能在没有此提示的情况下手动添加 MySQL 存储库?

gam*_*eld 5

选择版本的另一种方法:

- name: Try to specify preference for mysql
  shell: echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | debconf-set-selections
  become: yes

# Download mysql debian package
- name: Add mysql apt-config debian
  apt: deb=http://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb update-cache=yes
  become: yes
Run Code Online (Sandbox Code Playgroud)