Search code examples
mysqlmodulepuppetpuppetlabs-mysql

puppetlabs_mysql fails to import two sql scripts given as an array to the db class


This is so good but I would like to ask if the sql parameter to import sql scripts can receive an array as argument that is get two .sql file or more and still execute successfully, have tried to give it an array but it joins everything to one so that

      mysql::db{...
        sql => ["/tmp/1.sql","/tmp/2.sql",]
        ....
       }

it assumes the above to be

           /tmp/1.sql/tmp/2.sql

which is wrong is not possible .... is there a way for the puppetlabs mysql module to have two sql scripts imported at a go


Solution

  • No, you can't do it with mysql::db, either you concat the sql files yourself beforehand or run the exec that mysql::db runs

      exec{ "${dbname}-import":
        command     => "/usr/bin/mysql ${dbname} < ${sql}",
        logoutput   => true,
        environment => "HOME=${::root_home}",
        refreshonly => $refresh,
        require     => Mysql_grant["${user}@${host}/${table}"],
        subscribe   => Mysql_database[$dbname],
      }