本文介绍了up:如果字符数大于80,如何将命令包装成两行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在puppet中,如果define命令> 80个字符,我该如何包装成两行来实现?
In puppet, if define command is > 80 characters, how can I wrap into two line to do it?
exec { 'create_domain':
command => "some command exceed 80 character...........................................................how to do how to do?.......",
}
推荐答案
有点丑陋,但是如果字符串中的最后一个字符是 \
后跟换行符,然后字符串在下一行继续。我的 sample.pp
清单如下:
It's sort of ugly, but if the last character in a string is a \
followed by a newline, then the string is continued on the next line. My sample.pp
manifest is below:
exec { 'wrapped_string_example':
command => "/bin/echo 12345678901234567890123456789012345678901234567890\
wrapped > /var/tmp/test.txt";
}
使用 puppet运行此应用sample.pp
提供以下输出
$ puppet apply sample.pp
notice: /Stage[main]/Exec[wrapped_string_example]/returns: executed successfully
notice: Finished catalog run in 0.10 seconds
然后将创建的文件添加目录显示行已换行:
And catting the created file shows the lines have wrapped:
$ cat /var/tmp/test.txt
12345678901234567890123456789012345678901234567890wrapped
请参见(自Puppet v2.7.0起)
See https://github.com/puppetlabs/puppet/blob/9fbb36de/lib/puppet/parser/lexer.rb#L537 (as of Puppet v2.7.0)
这也是一个已知问题:
Also this is sort of a known issue: http://projects.puppetlabs.com/issues/5022
这篇关于up:如果字符数大于80,如何将命令包装成两行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!