微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用于mysql配置失败的Puppet中的Augeas

我正在开发一些基本的Puppet清单和模块,以便在部署服务器之后安装我的应用程序依赖项.这是一套基本的东西: –

> OS – > Ubuntu 14.04 LTS
> Nginx
> PHP5-FPM
> MysqL

简单吧?

在大多数情况下,一切都进展顺利;直到我偶然发现使用Augeas使用我的自定义配置项更新配置文件的能力.我已经设置了PHP配置项而没有任何问题,因此:

augeas { 'PHP.ini':
    require => [
        Package['PHP5-fpm'],
        Package['libaugeas-ruby'],
    ],
    notify => Service['PHP5-fpm'],
    context => '/files/etc/PHP5/fpm/PHP.ini',
    changes => [
        'set PHP/cgi.fix_pathinfo 0',
    ],
}

这很好用.没问题.

但是,现在我来到MysqL配置文件,我正在使用以下(这几乎是一个复制和粘贴工作)

augeas { 'my.cnf':
    require => [
        Package['MysqL-server'],
        Package['libaugeas-ruby'],
    ],
    notify => Service['MysqL'],
    context => '/files/etc/MysqL/my.cnf',
    changes => [
        'set MysqLd/bind-address 0.0.0.0',
    ],
}

不幸的是,这只是不起作用.我查看了augeas关于它随附的镜头的文档,没有任何问题.以下是Puppet apply命令的初始输出.

Error: /Stage[main]/MysqL/Augeas[my.cnf]: Could not evaluate: Save Failed with return code false, see debug

当然,下一个逻辑步骤是查看调试信息.其中包含以下信息.

Debug: Augeas[my.cnf](provider=augeas): sending command 'set' with params ["/files/etc/MysqL/my.cnf/MysqLd/bind-address", "0.0.0.0"]
Debug: Augeas[my.cnf](provider=augeas): Put Failed on one or more files, output from /augeas//error:
Debug: Augeas[my.cnf](provider=augeas): /augeas/files/etc/MysqL/my.cnf/error = put_Failed
Debug: Augeas[my.cnf](provider=augeas): /augeas/files/etc/MysqL/my.cnf/error/path = /files/etc/MysqL/my.cnf
Debug: Augeas[my.cnf](provider=augeas): /augeas/files/etc/MysqL/my.cnf/error/lens = /usr/share/augeas/lenses/dist/MysqL.aug:39.13-.60:
Debug: Augeas[my.cnf](provider=augeas): /augeas/files/etc/MysqL/my.cnf/error/message = Failed to match

解决方法:

好的,所以我设法让SOMETHING发生了;但是没有完全理解发生了什么.

在提出上述问题之前,我检查了可用的镜片,我在http://augeas.net/stock_lenses.html的列表中看到了PHPMysqL镜头

这两个链接都不能正常地引导你进入文档 – 所以,知道PHP镜头工作在’设置部分/设置值’类型的方式,我假设它与MysqL镜头相同.

事实并非如此.以下语法对我有用.

augeas { 'my.cnf':
    require => [
        Package['MysqL-server'],
        Package['libaugeas-ruby'],
    ],
    notify => Service['MysqL'],
    context => '/files/etc/MysqL/my.cnf',
    changes => [
        "set target[.='MysqLd']/bind-address 0.0.0.0",
    ],
}

以下两个资源是我找到信息的地方.如果有人有任何其他文件可以指出我,我会非常感激.

这让我了解了语法应该是什么: – https://www.adammalone.net/post/playing-augeas-fun-and-profit#.VXAEy1yqpBc

这个剧本的第62-65行重申了它: – https://github.com/example42/puppet-mysql/blob/master/manifests/augeas.pp

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐