简体   繁体   中英

Install mysql-server with puppet

I'm new in puppet. It's my first experience with it. I've installed a master and an agent on 2 ubuntu vm's. I've already installed apache with puppet. It seems to work fine. Now I've written my site.pp and my init.pp:

ubuntu@puppet:/etc/puppet/manifests$ cat site.pp 
node 'puppetclient.example.com' {
   include apache2
   include mysql-server
}

tree:

ubuntu@puppet:/etc/puppet/modules$ tree
.
├── apache2
│   └── manifests
│       └── init.pp
└── mysql-server
    └── manifests
        └── init.pp

my init.pp for my mysql-server:

class mysql-server {
  package { 'mysql-server':
    ensure => installed,
  }

  service { 'mysql-server':
    ensure  => true,
    enable  => true,
    require => Package['mysql-server'],
  }
}

When i perform puppet agent -t on my agent.

ubuntu@puppetclient:~$ sudo puppet agent -t
[sudo] password for ubuntu: 
Info: Retrieving plugin
Info: Caching catalog for puppetclient.example.com
Info: Applying configuration version '1462308091'
Error: /Stage[main]/Mysql-server/Service[mysql-server]: Could not evaluate: Could not find init script or upstart conf file for 'mysql-server'
Notice: Finished catalog run in 0.10 seconds

What am I doing wrong? Thanks

The error means that puppet was not able to start service called mysql-server

Could not find init script or upstart conf file for 'mysql-server'

Although I don't use Ubuntu, I'm sure that the service is not called mysql-server as this is only the name for the package, actual service is called mysql.

Try to use:

service { 'mysql': ensure => true, enable => true, require => Package['mysql-server'], }

As Michal T says, the service name is just mysql.

Different Operating Systems often have different package names and config file locations.

For something like mysql, I'd recommend using prior knowledge like one the supported MySql module , which covers most use cases for mysql, including creating databases.

Then you can just include the MySql class and it does most of the work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM