geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 862 forks source link

Failed geerlingguy.mysql : Ensure MySQL users are present #452

Closed smilesrg closed 3 years ago

smilesrg commented 3 years ago
TASK [geerlingguy.mysql : Ensure MySQL users are present.] *********************
failed: [db] (item=None) => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
fatal: [db]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}
#provision-db.yml
---
- hosts: db
  become: true
  become_user: root
  gather_facts: "no"
  vars:
    host_name: db
    db_ip_address: 192.168.33.11
  pre_tasks:
    # We need python2.7 installed to make ansible work correctly.
    - name: 'install python'
      raw: sudo apt-get -y install python-simplejson

    - name: "Install ansible python mysql dependency"
      apt:
        name: python-mysqldb
        state: latest

    - name: "Gather facts"
      setup:

    - name: Update APT package cache
      apt:
        update_cache: "yes"
        cache_valid_time: 3600

    - name: Install aptitude
      apt:
        pkg: aptitude
        state: present

    - name: Update APT to the latest packages
      apt:
        upgrade: safe

    - name: Set host name to proxy
      hostname:
        name: "{{host_name}}"

    - name: Setup host file
      lineinfile:
        dest: /etc/hosts
        regexp: "^{{db_ip_address}} db"
        line: "{{db_ip_address}} db"
        state: present
  roles:
    - role: geerlingguy.mysql
      mysql_root_password: "vagrant"
      mysql_bind_address: "{{host_name}}"
      mysql_databases:
        - name: wireless
          encoding: latin1
          collation: latin1_general_ci
      mysql_users:
        - name: root
          host: "%"
          priv: "*.*:ALL"
          password: "vagrant"
          state: present
thorsteinbn commented 3 years ago

I do not believe you need (or should) define root under mysql_users. It should be handled by mysql_root_password. (?) , so unless you are creating additional users just remove your whole mysql_users block.

smilesrg commented 3 years ago

Thansk @thorsteinbn ! your solution works.

thorsteinbn commented 3 years ago

Thansk @thorsteinbn ! your solution works.

Great! :)