如何删除[和]字符在正则表达式的字符串?
我正在使用Puppet DSL功能regsubst:
regsubst($::env, '\[\]', '', 'G')
Run Code Online (Sandbox Code Playgroud)
谢谢
我可以在puppet Enterprise Console中看到以下错误::
Could not retrieve facts from inventory service: SSL_connect returned=1 errno=0 state=SSLv3 read server session ticket A: sslv3 alert certificate revoked
我也按照以下步骤::
我在Windows puppet Enterprise客户端上运行了puppet agent -t.
我运行了puppet证书列表并从master签署了客户证书.
我再次运行puppet agent -t但是我在控制台上遇到以下错误::
Warning: Unable to fetch my node definition, but the agent run will continue: Warning: SSLconnect returned=1 errno=0 state=SSLv3 read server certificate B: c ertificate verify failed: [certificate revoked for /CN=learn.localdomain] Info: Retrieving plugin Error: /File[C:/ProgramData/PuppetLabs/puppet/var/lib]: Failed to generate addit ional resources using 'evalgenerate': SSLconnect returned=1 errno=0 state=SSLv …
我正在使用puppet在云基础架构上自动配置服务器.我将我的清单分成几个.pp's.
我有以下错误:
找不到依赖项Mehc_module :: Filestructure :: File [/ someFolder/someSubFolder]
相关部分:
filestructure.pp
class mehc_module::filestructure{
file {
"/someFolder/someSubFolder":
ensure => link,
owner => $mehc_module::users::WEBLOGIC_UID,
group => $mehc_module::users::WEBLOGIC_GID,
target => "/opt/user_projects",
require => UserDefinedFolder["/someFolder"];
}
Run Code Online (Sandbox Code Playgroud)
packages.pp
class mehc_module::packages{
require mehc_module::filestructure
...
mehc_repo::package { "${common11rpm}" :
ensure => present,
require => [
Mehc_module::Filestructure::File["/someFolder/someSubFolder"]
];
}
}
Run Code Online (Sandbox Code Playgroud)
为什么它会给我错误?
这是一个非常简单的问题,我已经阅读了一些建议的解决方案,但我仍然无法获得puppet申请导入git :: config类.这是我的文件设置:
我通过nodes.pp导入git模块:
#/etc/puppet/manifests/nodes.pp
node default {
}
include git
Run Code Online (Sandbox Code Playgroud)
site.pp导入nodes.pp:
#/etc/puppet/manifests/site.pp
import 'nodes.pp'
Run Code Online (Sandbox Code Playgroud)
git模块定义如下:
#/etc/puppet/modules/git/manifests/init.pp
class git {
include git::install
include git::config
}
class git::install{
package {'git': => present }
}
Run Code Online (Sandbox Code Playgroud)
和配置文件:
#/etc/puppet/modules/git/manifests/config.pp
define git::config{
[some code here]
}
Run Code Online (Sandbox Code Playgroud)
当我运行puppet apply时,puppet找不到git :: config类:
sudo puppet apply --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp
Error: Could not find class git::config for xxxx on node xxxx.
Run Code Online (Sandbox Code Playgroud)
原始模块是puppetlabs-git(相同的文件夹结构),但我使用简化的文件结构(上面)重新创建了错误.
更新1
上面的错字,git config.pp和init.pp在文件夹/ modules/git/manifests中,config.pp文件读取'define git :: config'
有没有办法在rubocop中使用配置文件禁用puppet-lint中的检查?配置文件应该是txt文件,json文件还是其他格式?
我开始使用puppet管理许多服务器,问题是每当我尝试使用类时,新的遗物例如:
node 'mynode' {
class {'newrelic::server::linux':
newrelic_license_key => '***',
}
}
Run Code Online (Sandbox Code Playgroud)
它失败,并返回以下错误:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class newrelic::server::linux at /etc/puppet/manifests/site.pp:3 on node mynode
Run Code Online (Sandbox Code Playgroud)
我已经安装fsalum-newrelic在主服务器上,使用文件,软件包,服务等时一切正常.我做错了什么?
我正试图在puppet中移植一个Ruby脚本.据我所知,实现这一目标的唯一方法是在模块中创建自定义函数.如果有另一种方式,请随时告诉我.我尝试了我的第一个测试,如https://docs.puppetlabs.com/guides/custom_functions.html所示,我宣布了一个新模块:
/etc/puppet/modules/custom_module
Run Code Online (Sandbox Code Playgroud)
并编辑了一个/etc/puppet/modules/custom_module/lib/puppet/parser/functions/newfunction使用以下代码调用的新函数文件:
module Puppet::Parser::Functions
newfunction(:write_line_to_file) do |args|
filename = args[0]
str = args[1]
File.open(filename, 'a') {|fd| fd.puts str }
end
end
Run Code Online (Sandbox Code Playgroud)
然后我在这个清单中/etc/puppet/environments/desarrollo/manifests/des.pp使用了这个内容:
node "develserver" {
write_line_to_file('/tmp/some_file', "Hello world!")
}
Run Code Online (Sandbox Code Playgroud)
最后,当我运行puppet agent -tod它时,它显示以下错误:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Unknown function write_line_to_file at /etc/puppet/environments/desarrollo/manifests/des.pp:5 on node develserver
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我在Linux上具有特定版本的软件,并且正在以rpm格式打包.jar文件(旨在升级现有软件),然后尝试重新创建符号链接以指向jar的最新版本。我尝试使用%post和%postun创建和删除符号链接(如果它已经存在),但是这不起作用。我在互联网上看到了一些帖子,但是它们没有用。
解决方法是,我尝试在puppet中创建符号链接。为此,我使用了以下内容:
if $version == ‘1.1' {
file { '/usr/share/prog/software.jar':
ensure => 'symlink',
target => '/usr/share/prog/java/software-1.1-bin.jar',
}
Run Code Online (Sandbox Code Playgroud)
但是即使在这里,也将创建新版本的jar,但不会创建符号链接。
请让我知道之前是否有人解决过此问题。
以下是我使用的规格文件:
%define base_install_dir %{_datadir}/prog
Name:cdplayer
Version:1.1
Epoch:1
Release:2el6
Source:cdplayer-1.1-bin.jar
BuildArch:noarch
%description
%prep
%install
%{__mkdir} -p %{buildroot}%{base_install_dir}
%{__install} -D -m 755 %{SOURCE0} %{buildroot}%{base_install_dir}
%post
ln -s -f /usr/share/prog/cdplayer-1.1-bin.jar /usr/share/prog/cdplayer.jar
%postun
%{__rm} -f /usr/share/prog/cdplayer.jar
%files
%defattr(-,root,root,-)
%dir %{base_install_dir}
%{base_install_dir}/*
%changelog
Run Code Online (Sandbox Code Playgroud) 我在yaml hiera文件中有这个.
reg_connection:
toronto:
- host: apple.net
- port: 701
- user: george
- ssl: true
- allowed: banana,orange
texas:
- host: pink.net
- port: 702
- user: joel
- ssl: false
- allowed: blue,gree,red
Run Code Online (Sandbox Code Playgroud)
我想访问主机,端口,用户,ssl的值,并允许多伦多和德州.
我的清单中有这个:
$reg_connection= hiera_hash('reg_connection')
Run Code Online (Sandbox Code Playgroud)
我在我的模板中有这个:
<% reg_connection.keys().sort.each do |location| -%>
<%= location %>host=<%= location[host] %>
<%= location %>port=<%= location[port] %>
<%= location %>username=<%= location[user] %>
<%= location %>ssl.enable=<%= location[ssl] %>
<%= location %>allowed.list=<%= location[allowed] %>
<% end -%>
Run Code Online (Sandbox Code Playgroud)
我想在我的模板中输出两个配置块:一个用于多伦多,一个用于德州.
我的puppet输出显示它没有host的值.我怎样才能获得这个价值?
我想在puppet中包含一个erb文件.但该文件包含以下行:
<%@ taglib prefix="ww" uri="webwork" %>
<%@ taglib prefix="ui" uri="webwork" %>
<%@ taglib prefix="aui" uri="webwork" %>
<%@ taglib prefix="page" uri="sitemesh-page" %>
Run Code Online (Sandbox Code Playgroud)
当我运行puppet时,这会显示一个语法错误,表示
'@ '不允许将其作为实例变量名称.
我怎么能逃脱这个角色@?