Thank you Aaron you solved my problem.

But also thanks to Nathan and Jacob for pointing me in the right direction.

Thanks again :D

On Wed, Oct 12, 2011 at 6:16 PM, Aaron Grewell <[email protected]>wrote:

> IIRC the mysql user gets created by the mysql rpm, so your file will have
> to require Package['mysql-server']  and possibly mysql-client as well.
>
>
> On Wed, Oct 12, 2011 at 3:09 PM, olympus stance 
> <[email protected]>wrote:
>
>> Hello Nathan,
>>
>> I tried that:
>> here is mysql-server.pp
>> -----------------------------------
>>
>> class mysql-server {
>>
>>   package { "mysql-server": ensure => installed }
>>   package { "mysql-client": ensure => installed }
>>   service { "mysql":
>>              enable => true,
>>
>>              require => Package["mysql-server"],
>>           }
>>
>>   file { "/etc/mysql":
>>      ensure => directory,
>>      mode => 0755,
>>      owner => root,
>>      group => root,
>>   }
>>
>>   file { "/etc/mysql/my.cnf":
>>     source => "puppet:///modules/mysql-server/my.cnf",
>>     owner => "mysql", group => "mysql",
>>     mode  => 644,
>>     notify => Service["mysql"],
>>     require => File["/etc/mysql"]
>>   }
>>
>>
>>   exec { "set-mysql-password":
>>     path => ["/bin", "/usr/bin"],
>>     command => "mysqladmin -uroot password secret",
>>   }
>>
>>
>>   exec { "set-nagios-password":
>>     path => ["/bin", "/usr/bin"],
>>     command => "/usr/bin/mysql -u root  -e \"CREATE USER 'nagios'@'%'
>> IDENTIFIED BY 'secret';\"",
>>   }
>>
>>
>> }
>> ------------------------------------
>>
>>
>>
>> Here is is the output on the client:
>> -------------------------------------------
>> root@pclient:~# puppetd --no-daemonize --verbose
>> notice: Starting Puppet client version 2.7.5
>> info: Caching catalog for pclient.local.net
>> info: Applying configuration version '1318457031'
>> notice: /Stage[main]/Mysql-server/File[/etc/mysql]/ensure: created
>> err: /Stage[main]/Mysql-server/File[/etc/mysql/my.cnf]/ensure: change from
>> absent to file failed: Could not set 'file on ensure: Could not find user
>> mysql at /etc/puppet/modules/mysql-server/manifests/init.pp:23
>> notice: /Stage[main]/Mysql-server/Package[mysql-client]/ensure: ensure
>> changed 'purged' to 'present'
>> notice: /Stage[main]/Mysql-server/Package[mysql-server]/ensure: ensure
>> changed 'purged' to 'present'
>> notice: /Stage[main]/Mysql-server/Exec[set-nagios-password]/returns:
>> executed successfully
>> info: FileBucket adding {md5}1090e28a70ebaae872c2ec78894f49eb
>> info: /Stage[main]/Sudo/File[/etc/sudoers]: Filebucketed /etc/sudoers to
>> main with sum 1090e28a70ebaae872c2ec78894f49eb
>> notice: /Stage[main]/Sudo/File[/etc/sudoers]/content: content changed
>> '{md5}1090e28a70ebaae872c2ec78894f49eb' to
>> '{md5}36bd2385741a3f03c08b7b6729ae8df5'
>> notice: /Stage[main]/Mysql-server/Exec[set-mysql-password]/returns:
>> executed successfully
>> notice: /Stage[main]/Mysql-server/Service[mysql]: Dependency
>> File[/etc/mysql/my.cnf] has failures: true
>> warning: /Stage[main]/Mysql-server/Service[mysql]: Skipping because of
>> failed dependencies
>> info: Creating state file /var/lib/puppet/state/state.yaml
>> notice: Finished catalog run in 28.63 seconds
>> ------------
>>
>>
>> Note that mysql does run and i am able to log into it, but my.cnf does not
>> get imported....
>>
>>
>>
>>
>>
>> On Wed, Oct 12, 2011 at 5:55 PM, Nathan Clemons <[email protected]>wrote:
>>
>>> Try:
>>>
>>>   file { "/etc/mysql":
>>>      ensure => directory,
>>>      mode => 0755,
>>>      owner => root,
>>>      group => root,
>>>   }
>>>
>>>   file { "/etc/mysql/my.cnf":
>>>     source => "puppet:///modules/mysql-server/my.cnf",
>>>     owner => "mysql", group => "mysql",
>>>     mode  => 644,
>>>     notify => Service["mysql"],
>>>     require => File["/etc/mysql"]
>>>   }
>>>
>>> --
>>> Nathan Clemons
>>> http://www.livemocha.com
>>> The worlds largest online language learning community
>>>
>>>
>>>
>>> On Wed, Oct 12, 2011 at 2:49 PM, olympus stance <
>>> [email protected]> wrote:
>>>
>>>> Hi Jacob,
>>>>
>>>> My init.pp file is a symbolic link to the mysql-server.pp in the classes
>>>> directory. It looks like this:
>>>>
>>>> -------
>>>> class mysql-server {
>>>>
>>>>   package { "mysql-server": ensure => installed }
>>>>   package { "mysql-client": ensure => installed }
>>>>   service { "mysql":
>>>>              enable => false,
>>>>              require => Package["mysql-server"],
>>>>
>>>>           }
>>>>
>>>>   file { "/etc/mysql/my.cnf":
>>>>     source => "puppet:///modules/mysql-server/my.cnf",
>>>>     owner => "mysql", group => "mysql",
>>>>     mode  => 644,
>>>>     notify => Service["mysql"],
>>>>   }
>>>>
>>>>
>>>>
>>>>   exec { "run-mysqld":
>>>>     path => ["/bin", "/usr/sbin"],
>>>>     command => "/usr/sbin/mysqld &",
>>>>   }
>>>>
>>>>   exec { "set-mysql-password":
>>>>     path => ["/bin", "/usr/bin"],
>>>>     command => "mysqladmin -uroot password secret",
>>>>   }
>>>>
>>>>
>>>>   exec { "set-nagios-password":
>>>>     path => ["/bin", "/usr/bin"],
>>>>     command => "/usr/bin/mysql -u root  -e \"CREATE USER 'nagios'@'%'
>>>> IDENTIFIED BY 'secret';\"",
>>>>   }
>>>>
>>>>
>>>> }
>>>> ---------------------------
>>>>
>>>>
>>>> It looks like it does indeed try to create the my.cnf file before mysql
>>>> gets installed. How can i rectify that
>>>>
>>>> Thanks!!
>>>>
>>>>
>>>> On Wed, Oct 12, 2011 at 5:37 PM, Jacob Helwig <[email protected]>wrote:
>>>>
>>>>> On Wed, 12 Oct 2011 14:33:47 -0700, John Bower wrote:
>>>>> >
>>>>> > Hello,
>>>>> >
>>>>> > I'm trying to share a file between the client and the server.
>>>>> >
>>>>> > On the server the file is located at:
>>>>> /etc/puppet/modules/mysql-server/
>>>>> > files/my.cnf
>>>>> >
>>>>> > the code that references to this file is as follows:
>>>>> >
>>>>> >   file { "/etc/mysql/my.cnf":
>>>>> >     source => "puppet:///modules/mysql-server/my.cnf",
>>>>> >     owner => "mysql", group => "mysql",
>>>>> >     mode  => 644,
>>>>> >     notify => Service["mysql"],
>>>>> >   }
>>>>> >
>>>>> > Essentially, I want the client to store the my.cnf file to /etc/mysq/
>>>>> > my.cnf
>>>>> >
>>>>> > However i keep getting this error:
>>>>> > err: /Stage[main]/Mysql-server/File[/etc/mysql/my.cnf]/ensure: change
>>>>> > from absent to file failed: Could not set 'file on ensure: No such
>>>>> > file or directory - /etc/mysql/my.cnf.puppettmp_9888 at /etc/puppet/
>>>>> > modules/mysql-server/manifests/init.pp:15
>>>>> >
>>>>> >
>>>>> >
>>>>> > i tried setting  source => "puppet:///modules/mysql-server/files/
>>>>> > my.cnf",
>>>>> >
>>>>> >
>>>>> > But that did not make a difference. Please help.
>>>>> >
>>>>>
>>>>> Does /etc/mysql exist on the client machine?
>>>>>
>>>>> --
>>>>> Jacob Helwig
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Puppet Users" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/puppet-users?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Puppet Users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/puppet-users?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to