Search code examples
ansibleansible-2.xmysql-8.0

Ansible installation of MySQL 8 - installing repository without mysql-apt-config


I am trying to install MySQL 8 automatically with ansible.

However, this installation requires obtaining of mysql-apt-config. Which, when installed, opens a config window

mysql-apt-config-install

I would like to bypass this config and rather obtain the repository in the ansible using apt_repository.

What is the correct address? Where can I find this repository address so I could download and install MySQL using apt?

This makes a problem for ansible - I don't know how to put an option in this window. I tried expect module

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

however that raises following error

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

I checked, and pexpect module is available.

Is there any possibility to add MySQL repositories manually, without this prompt?


Solution

  • Just in case somebody would be looking for similar answer:

    To install MySQL 8 using ansible, this is the repository you should add:

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

    Edit the address to match your distribution. The rest of the process is automatic and whats more - silent.

    I found the repository address here.