1

I am trying to install mysql server on centos using ansible playbook. My yml file looks like above.

---
- name: Install MySQL database server
  hosts: test
  become: yes
  become_method: sudo
  gather_facts: true
  tags: [database]
  tasks:
        - name: Update the software package repository
          yum:
                update_cache: yes

        - name: Install MySQL
          package:
                name: "{{ item }}"
                state: latest

          with_items:
              - mysql-server
              - mysql-client
              - python-mysqldb

But it getting error.

failed: [192.168.94.151] (item=mysql-server) => {"changed": false, "item": "mysql-server", "msg": "No package matching 'mysql-server' found available, installed or updated", "rc": 126, "results": ["No package matching 'mysql-server' found available, installed or updated"]}

How can i fix this issue?

4
  • 2
    Use the correct package names. – Michael Hampton Dec 21 '18 at 4:08
  • Is this wrong? - mysql-server - mysql-client – Janith Dec 21 '18 at 4:39
  • 1
    Yes, they are wrong. – Michael Hampton Dec 21 '18 at 14:58
  • 2
    To obtain valid package names, SSH into your server and do yum search mysql. – adgud Dec 22 '18 at 12:30
1

I had to download and add the repository and then update.

   - name: Download sources
      get_url:
        url: http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
        dest: /opt/mysql

   - name: Install package
     yum:
       name: /opt/mysql/mysql-community-release-el7-5.noarch.rpm
       state: present


   - name: Install MySQL
     yum: name=mysql-server state=installed
1
  • 1
    You don't have to get_url first. You can just provide the URL directly to yum. – Michael Hampton Apr 25 '19 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.