LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2015, 12:50 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
How to flush MySQL privileges using ansible


Hello all,

I am new to ansible and I am attempting build my server stack using it. I am at the point where I am trying to change the root password for mysql and flush the privileges but am having a hard time getting this to work.

I have seen cases where people have copied over a my.cnf file into the users directory to change the root password while others have changed it by logging into mysql. I don't know the benefits / difference to doing one or the other. I simply prefer to not have to transfer a file if I can get away with it.

My code seems to execute without any errors but the mysql server password is not changed. I am wondering what I am overlooking.

Here is currently what my code looks like (code is to provision the latest version Ubuntu version) :
Code:
---
  - hosts: web
    remote_user: deploy
    sudo: yes

    vars:
      rails_env: "{{RAILS_ENV | default(development)}}"
      root_db_password: "{{ROOT_DB_PASS}}"

    tasks:
      - name: update system cache
        apt: update_cache=yes
      
      - name: Install MySQL
        apt: 
          pkg: mysql-server
          state: present
        tags:
          -mysql
          
      - name: Install MySQL Dev Headers
        apt: 
          pkg: libmysqld-dev
          state: installed
        tags:
          - mysql
        
      - name: Ensure Mysql is started
        service:
          name: mysql
          state: started
          enabled: true
        tags:
          - mysql
          
      - name: Install Python MySQL module
        apt:
          pkg: python-mysqldb
          state: installed
        tags:
          - mysql

      - name: update mysql root password for all root accounts
        mysql_user: name=root host=$item password=$root_db_password
        with_items:
          - $ansible_hostname
          - 127.0.0.1
          - ::1
          - localhost
        tags:
          - mysql

      - name: ensure anonymous users are not in the database
        mysql_user: name='' host=$item state=absent
        with_items:
          - localhost
          - $inventory_hostname
        tags:
          - mysql

      - name: remove the test database
        mysql_db: name=test state=absent
        notify:
          - restart mysql
        tags:
          - mysql
    
    handlers:
      - name: restart mysql
        action: service name=mysql state=restarted enabled=yes
 
Old 11-04-2015, 10:19 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
"The . . . r-o-o-t(!!!) ... ... password?!?!?!"
 
Old 11-05-2015, 06:28 AM   #3
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Original Poster
Rep: Reputation: 31
I'm sorry. I don't follow.
 
  


Reply

Tags
ansible, mysql 5.6, ubuntu 14.04


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
99% cpu usage due to flush-8:0 & flush-8:16 propofol Debian 4 09-09-2011 03:03 PM
mysql "flush logs" or "flush tables with read lock", ... hangs deadeyes Linux - Server 4 01-19-2010 03:24 AM
Lost privileges in mysql, after changes kenpeter Programming 0 01-07-2008 05:09 AM
MySQL Flush Logs rwhite7890 Linux - Software 1 11-27-2007 11:56 AM
Mysql privileges question everythingand2 Linux - General 0 12-14-2003 02:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration