mysqlvagrantpuphpet

Vagrant & Puppet - error when using puphpet to import sql into mysql database


==> payments: Notice: /Stage[main]/Puphpet::Mysql::Install/Puphpet::Mysql::Databases[from puphpet::mysql::install]/Exec[users-import]/returns: sh: 1: cannot open db/dump.sql: No such file
==> payments: Error: mysql users < db/dump.sql && touch /opt/puphpet-state/db-import-users returned 2 instead of one of [0]
==> payments: Error: /Stage[main]/Puphpet::Mysql::Install/Puphpet::Mysql::Databases[from puphpet::mysql::install]/Exec[users-import]/returns: change from notrun to 0 failed: mysql users < db/dump.sql && touch /opt/puphpet-state/db-import-users returned 2 instead of one of [0]

On vagrant up I am getting the above error.

The sql import file is located within the db directory (see screenshot). I am thinking that perhaps the SQL file isn't getting copied to the VM in time? It is worth noting that I create three databases in the puphpet file and then import the sql when the last one is created. The sql file creates the tables and inserts some data.

Puphpet config for MySQL databases

databases:
    mysqlnd_b349iw3pewx1:
        name: sites
        sql: ''
    mysqlnd_b349iw3pewx2:
        name: ia
        sql: ''
    mysqlnd_b349iw3pewx3:
        name: users
        sql: '../db/dump.sql'

Directory structure

enter image description here

I am using puppet via puphpet.


Solution

  • If you're not sure about the path, as I mentioned in the comments just indicate the full path of the files

    databases:
        mysqlnd_b349iw3pewx1:
            name: sites
            sql: ''
        mysqlnd_b349iw3pewx2:
            name: ia
            sql: ''
        mysqlnd_b349iw3pewx3:
            name: users
            sql: '/home/vagrant/db/dump.sql'