简体   繁体   English

用puppet安装mysql-server

[英]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. 我在2个ubuntu vm上安装了一个主人和一个代理。 I've already installed apache with puppet. 我已经用puppet安装了apache。 It seems to work fine. 它似乎工作正常。 Now I've written my site.pp and my init.pp: 现在我写了我的site.pp和我的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: 我的mysql-server的init.pp:

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. 当我在我的经纪人puppet agent -t执行puppet agent -t代理时。

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 该错误意味着puppet无法启动名为mysql-server的服务

Could not find init script or upstart conf file for 'mysql-server' 无法找到'mysql-server'的init脚本或upstart conf文件

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. 虽然我不使用Ubuntu,但我确信该服务不会被称为mysql-server,因为这只是包的名称,实际服务称为mysql。

Try to use: 尝试使用:

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

As Michal T says, the service name is just mysql. 正如Michal T所说,服务名称只是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. 对于像mysql这样的东西,我建议使用先前的知识,例如支持的MySql模块 ,它涵盖了mysql的大多数用例,包括创建数据库。

Then you can just include the MySql class and it does most of the work for you. 然后你可以只包含MySql类,它可以为你完成大部分工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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