First, where is $servername
being set? That's not a standard fact, so for it to have content you'd need to have either a custom fact or manifest variable. Do you want to be using $clientcert
or $fqdn
instead?
On your file
resource.. I would think that should be erroring out, but maybe not, since /etc/
exists.. the problem there is that the resource as declared is trying to manage /etc/
instead of /etc/my.cnf
. Either declare the full path to the file in the resource name and omit the path
parameter:
file { '/etc/my.cnf':
Or, have the path
parameter be the full path to the file (then the name is irrelevant):
file { 'MySQL Config':
path => '/etc/my.cnf',
But.. I'd really recommend against having the logic of "which config file does this server get" hardcoded in your manifest. Use Hiera or node definitions with parameterized classes instead.