Coder Social home page Coder Social logo

How to create multiple users? about psick HOT 5 CLOSED

example42 avatar example42 commented on August 14, 2024
How to create multiple users?

from psick.

Comments (5)

alvagante avatar alvagante commented on August 14, 2024

Yes, you can use the mysql::user define to create users and mysql::grant define to manage permissions.

from psick.

wgregorian avatar wgregorian commented on August 14, 2024

Sorry, I was not very descriptive. I need to be able to setup multiple users so, I used this:

    mysql::user { "db1":
            mysql_password_hash => "db1",
            mysql_user => "db1",
            mysql_host => "host"
    }
    mysql::grant { "db1":
            mysql_privileges => "ALL",
            mysql_password => "pwd",
            mysql_db => "db1",
            mysql_user => "db1",
            mysql_host => "host"
    }

But, if I use the same for db2, it won't work since mysql::user would be repeated twice. I guess, I'm looking for a way to handle multiple users for multiple databases more gracefully.

from psick.

alvagante avatar alvagante commented on August 14, 2024

Uhm, not so sure I've understood well, but you should be able to create 2 different users for the same db with just 2 different mysql::grant :

mysql::grant { "db1":
        mysql_privileges => "ALL",
        mysql_password => "pwd",
        mysql_db => "db1",
        mysql_user => "db1",
        mysql_host => "host"
}
mysql::grant { "db2":
        mysql_privileges => "ALL",
        mysql_password => "pwd",
        mysql_db => "db1",
        mysql_user => "db2",
        mysql_host => "host"
}

or maybe I still haven't understood what you need :-)
Anyway, take a look at the templates user by these defines:
mysql::grant uses this:

<% if mysql_db != "" then %>
CREATE DATABASE IF NOT EXISTS <%= mysql_db %> ;
<% end %>
GRANT <%= mysql_privileges %> ON <%= mysql_db %>.
TO '<%= mysql_user %>'@'<%= mysql_host %>' IDENTIFIED BY '<%= mysql_password %>';
FLUSH PRIVILEGES ;

mysql::user uses this:

GRANT USAGE ON .
TO '<%= mysql_user %>'@'<%= mysql_host %>'
IDENTIFIED BY
<% if has_variable?('mysql_password_hash') && mysql_password_hash then %>
PASSWORD '<%= mysql_password_hash %>'
<% else %>
'<%= mysql_password %>';
<% end %>
;
FLUSH PRIVILEGES ;

So actually mysql::user is somehow a subset of mysql::grant

from psick.

welly avatar welly commented on August 14, 2024

Hi guys,

I'm very new to puppet and have just been trying to change the configuration that I got from puphpet.com to automatically add a new user. In my default.pp manifest, I've added:

mysql::grant { "db1":
mysql_privileges => "ALL",
mysql_password => "password",
mysql_user => "root",
mysql_host => "%",
}

however, vagrant fails to build reporting:

Must pass mysql_db to Mysql::Grant[db1] at /tmp/vagrant-puppet/modules-0/mysql/manifests/grant.pp:1 on node precise32

Any help would be appreciated!

Thanks

from psick.

alvagante avatar alvagante commented on August 14, 2024

Try to explicitely pass the parameter mysql_db => 'db1'

from psick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.