以下是我正在运行的简化清单:
package {'ruby2.4':
ensure => installed
}
exec { "gem2.4_install_bundler":
command => "/usr/bin/gem2.4 install bundler",
require => Package['ruby2.4']
}
Puppet apply正确运行此清单,即
安装ruby2.4软件包(包括gem2.4)
使用gem2.4
然而,puppet应用--noop FAILS因为puppet找不到可执行文件'/usr/bin/gem2.4'因为ruby2.4没有安装--noop。
我的问题是,是否有一种标准方法可以用puppet apply --noop测试这样的场景?验证我的木偶清单是否正确执行?
我可能需要解析输出并验证执行的顺序。如果是这种情况,是否有标准的方法/工具?
最后的手段是一个非常基本的检查,即木偶至少可以运行,可以使用--detailed-exitcodes选项来确定。 (代码与1不同)。
提前谢谢
答案 0 :(得分:2)
rspec-puppet是该级别验证的标准工具。它可以从清单(例如,类,定义类型或主机)构建目录,然后您可以编写测试来验证内容。
在您的情况下,您可以验证user@pc1:~/workspace/project$ docker-compose run -u 1000 --rm --no-deps composer update
Cannot create cache directory /composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Cannot create cache directory /composer/cache/repo/github.com/delphiki/BazingaJsTranslationBundle/, or directory is not writable. Proceeding without cache
Could not fetch https://api.github.com/repos/delphiki/BazingaJsTranslationBundle, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+ff31a67c2b28+2017-04-06+0645
to retrieve a token. It will be stored in "/composer/auth.json" for future use by Composer.
Token (hidden):
Token stored successfully.
[RuntimeException]
/composer/cache/vcs does not exist and could not be created.
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...
资源是否存在,prev_version=$(sed -n '\%.*// calcmarks, version %!d;s///;s/ .*//p' "$file")
new_version=$((prev_version+1))
curr_date=$(date "+%a %b %d %H:%M:%S %Z %Y")
sed -i -e "s#\(// calcmarks, version \)${prev_version}.*#\1${new_version}, released ${curr_date}#g" "$file"
资源是否存在,并验证它们之间的顺序。这与使用package
模式运行代理并解析输出一样有效 - 但运行起来更简单,更便宜。
rspec-puppet最适合模块,因此假设您从网站上按照模块的设置进行操作(将exec
添加到--noop
,运行rspec-puppet
),让我们说这个在一个名为Gemfile
的类中,rspec-puppet-init
中的一个简单规范是:
ruby24