3

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

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

mysql-apt-config-安装

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

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

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

- name: install mysql repo
  expect:
    command: "dpkg -i /tmp/mysql-apt-config.deb"
    responses: 
      Question:
        - response4
  become: yes
  become_method: sudo

然而,这会引发以下错误

TASK [mysql : install mysql repo] ******************************************************************************
fatal: [testserver]: FAILED! => {"changed": false, "msg": "The pexpect python module is required"}

我检查了,并且 pexpect 模块可用。

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

4

2 回答 2

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
于 2018-08-16T01:00:46.280 回答
3

以防万一有人会寻找类似的答案:

要使用 ansible 安装 MySQL 8,您应该添加以下存储库:

- name: Add MySQL 8 ubuntu xenial repository
  apt_repository: 
    repo: "deb http://repo.mysql.com/apt/ubuntu xenial mysql-8.0"
    state: present

编辑地址以匹配您的分配。该过程的其余部分是自动的,更重要的是 - 无声。

我在这里找到了存储库地址

于 2018-08-09T11:35:07.150 回答