Ask Your Question
1

puppetlabs-mysql simple manifest fails with `Syntax error at '=>'; expected '}'`

asked 2015-05-04 19:58:03 -0500

updated 2015-05-06 16:53:39 -0500

I am attempting to set up some MySQL servers using the Puppetlabs/MySQL module. I am still running into syntax issues with a very simple manifest and I do not understand why.

For simplicity, I borrowed these few classes from the puppetlabs-mysql readme.

This basic manifest still fails a syntax check. It seems to be choking on the 'hash within a hash' for users => { on line 16, which looks like valid syntax to me. This error is not covered at Puppet Docs / Troubleshooting. Why is this failing?

$ puppet --version
3.7.5
puppet $ puppet parser validate init.pp
Error: Could not parse for environment production: Syntax error at '=>'; expected '}' at ..../tmp/init.pp:16
puppet $ 

puppet $ cat init.pp
class my_database {

  class { '::mysql::server':
    root_password           => 'strongpassword',
    remove_default_accounts => true,
    service_enabled         => true,
  }

  mysql::db { 'mydb':
    user     => 'myuser',
    password => 'mypass',
    host     => 'localhost',
    grant    => ['SELECT', 'UPDATE'],
  }

  users => {
    'someuser@localhost' => {
      ensure        => 'present',
      password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF',
    },
  }
}

puppet $
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-05-04 20:22:56 -0500

GregLarkin gravatar image

users is an attribute of the ::mysql::server class, so you would set it like so when declaring the class:

class my_database {

  class { '::mysql::server':
    root_password           => 'strongpassword',
    remove_default_accounts => true,
    service_enabled         => true,
    users => {
      'someuser@localhost' => {
        ensure        => 'present',
        password_hash => '*F3A2A51A9B0F2BE2468926B4132313728C250DBF',
      },
    }
  }

  mysql::db { 'mydb':
    user     => 'myuser',
    password => 'mypass',
    host     => 'localhost',
    grant    => ['SELECT', 'UPDATE'],
  }
}

All of the other attributes for that class are configured similarly, and the full list can be found here: https://forge.puppetlabs.com/puppetlabs/mysql#mysqlserver

edit flag offensive delete link more

Comments

Thanks Greg, I understand now. We're still struggling trying to figure out how to use modules from the Puppet Forge, and this wasn't immediately apparent. I couldn't find any examples that made use of `users`, `grants` and `databases` hashes.

stefanlasiewski gravatar imagestefanlasiewski ( 2015-05-06 16:22:16 -0500 )edit

FYI, a correct link to the full list of attributes for the `::mysql::server` class is https://forge.puppetlabs.com/puppetlabs/mysql/readme#mysqlserver

stefanlasiewski gravatar imagestefanlasiewski ( 2015-05-06 16:22:49 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-04 19:58:03 -0500

Seen: 432 times

Last updated: May 06 '15