使用 puppet 安装 mysql-server

Install mysql-server with puppet

我是木偶新手。这是我第一次体验它。我已经在 2 ubuntu 个虚拟机上安装了一个主机和一个代理。我已经用 puppet 安装了 apache。 它似乎工作正常。现在我写了我的 site.pp 和我的 init.pp:

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

树:

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

我的 init.pp 我的 mysql-服务器:

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

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

当我对代理执行 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

我做错了什么?谢谢

错误意味着 puppet 无法启动名为 mysql-server

的服务

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

虽然我不使用 Ubuntu,但我确定该服务不称为 mysql-server 因为这只是包的名称,实际服务称为 mysql.

尝试使用:

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

正如 Michal T 所说,服务名称只是 mysql。

不同的操作系统通常有不同的包名和配置文件位置。

对于 mysql 之类的内容,我建议使用先验知识,例如受支持的 MySql module,它涵盖了 mysql 的大多数用例,包括创建数据库。

然后您可以只包含 MySql class 它会为您完成大部分工作。