【问题标题】:Ansible installation of MySQL 8 - installing repository without mysql-apt-configMySQL 8 的 Ansible 安装 - 在没有 mysql-apt-config 的情况下安装存储库
【发布时间】:2019-01-15 20:30:36
【问题描述】:

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

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

我想绕过这个配置,而是使用 apt_repository 获取 ansible 中的存储库。

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

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

- 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 存储库,而无需此提示?

【问题讨论】:

  • 您确定 python 模块安装在正确的服务器(执行器或目标)上吗?
  • 我是。我检查了他们两个。
  • 除此之外,我还在上面添加了 pip install pexpect 的 ansible 等效项。
  • 这是XY Problem。搜索“mysql-apt-config 静默安装”。
  • 谢谢。这是我要找的关键字

标签: ansible ansible-2.x mysql-8.0


【解决方案1】:

另一种选择版本的方法:

- 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

【讨论】:

    【解决方案2】:

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

    要使用 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
    

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

    我找到了仓库地址here.

    【讨论】:

    • 您可以在 https://dev.mysql.com/downloads/repo/apt/ 找到最新的 apt 发行版(在密钥环安装程序下载下方的括号中)。
    猜你喜欢
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多