Vagrant / Puppet newbie: trying to set up DBMS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Vagrant / Puppet newbie: trying to set up DBMS

monosij.forums

My question may already have been answered and I think it has a simple answer but unable to find it. So your help is appreciated.

I am trying to set up a couple of DEV VMs for SQL and NoSQL DBMS. 
For the SQL I am setting up MySQL and PostgreSQL.

I have the configuration broken up by modules for SQL and NoSQL machines.
For the SQL module my init.pp in the 'manifests' directory calls out to 2 classes one for Postgres and one for MySQL.

The script runs fine and no errors (lots of messages as I have puppet options: verbose, debug), however when I log in MySQL or Postgres are not.
They only get installed if I run another script that creates a user in the DBMS which is an exec that creates a database and user and requires the class MySQL or PostgreSQL.

If I do not run that script the MySQL/PostgreSQL does not get installed.

The class for MySQL is included below for your reference.

------------------------------------------------
class instanceMySQL {           
    package {"mysql-server":
        ensure => installed,                                                                                                                                                                                   
    }                   
                    
    file {"/etc/mysql/conf.d/allow_external.cnf": #comes from local filesystem
        owner   => mysql,
        group   => mysql,
        mode    => 0644,
        content => template("dbmsSQL/etc/mysql/conf.d/allow_external.cnf"),
        require => Package["mysql-server"],
        notify => Service["mysql"]
    }                   
                    
    service {"mysql":
        ensure => running,
        enable => true,
        hasstatus => true,
        hasrestart => true,
        require => Package["mysql-server"]
        #subscribe => File["cfgfile"]
    }                   
}
------------------------------------------------

And it does not get installed unless I run this.
------------------------------------------------
include instanceMySQL
                    
define schemaMySQL ($database, $username, $password) {
                    
    exec {"create-dbmsSQL-$database":
        command => "mysqladmin -uroot create $database",
        unless => "mysqlshow -uroot $database",
        path => "/usr/bin/",
        require => Class["instanceMySQL"],
    }               
                    
    exec {"create-dbmsSQL-user-$database-$username":
        unless => "mysqlshow -u$username -p$password $database",
        command => "mysql -uroot -e \"grant all on $database.* to '$username'@'%' identified by '$password'; grant all on $database.* to '$username'@'localhost' identified by '$password';\"",
        path => "/usr/bin",
        require => Exec["create-dbmsSQL-$database"],
    }               
}                   
------------------------------------------------

I was essentially also wondering where I could find examples of classes that set up different DBMS.
I found for MongoDB but not for Cassandra or Neo4j and so on.
Also for these DBMS are there examples how to set up for external access, security, port configuration that are usually standard aspects for setting up securely but for access from external hosts.

In several example scripts I found they were doing things differently - so just wondering if there is a standard way of setting up these DBMS machines regardless of OS.
I am running on Ubuntu.

Thanks for your help.

Monosij

--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.