Book Image

Salt Cookbook

By : Anirban Saha
Book Image

Salt Cookbook

By: Anirban Saha

Overview of this book

Table of Contents (18 chapters)
Salt Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating MySQL database users


Setting up users and giving them proper permissions to access databases is one of the most critical tasks in database management. In this recipe, you will learn how to create database users and manage their access from different servers.

How to do it...

We will use the same minion as the previous recipe.

  1. Create and edit /opt/salt-cookbook/pillar/staging/mysql/init.sls to have the following entries:

    mysql:
      stg-passwd-hash: '*CAC560C0ED394C2D89B7A1F08422B200B2FFBC26'
  2. Edit /opt/salt-cookbook/pillar/staging/top.sls to have the following entries:

    staging:
      '*':
        - mysql
  3. Create and edit /opt/salt-cookbook/staging/mysql/users.sls to have the following entries:

    include:
      - mysql.database
    
    db_user:
      mysql_user.present:
        - name: stg-db
        - host: '*'
        - password_hash: '{{ pillar['mysql']['stg-passwd-hash'] }}'
        - connection_charset: utf8
        - saltenv:
          - LC_ALL: "en_US.utf8"
        - require:
          - mysql_database: stg_databases
  4. Edit /opt/salt-cookbook/staging...