【发布时间】:2019-11-17 16:44:05
【问题描述】:
参考:http://scienceofficersblog.blogspot.com/2016/02/testing-ansible-with-inspec.html
有很多帖子提到使用 Chef inspec 进行 Ansible 测试。但他们通常会给出这样的例子:
Ansible:
- hosts: all
user: root
tasks:
- debug: msg="debug {{inventory_hostname}}"
- apt: name=apache2 state=present
主厨检查:
impact 0.7
title "Test some simple resources"
describe package('apache2') do
it { should be_installed }
end
所以,如果我执行相同的 Ansible 块,它将确保安装了 apache2 包。同样有很多例子,比如应该打开 80 端口,因为如果我们在 chech 模式(试运行)下执行相同的剧本,那么我也会知道端口 80 是否正在监听。
那么,为什么我们不能使用 Ansible 本身呢?当我们几乎可以使用 Ansible 完成所有事情时,Chef inspec 的确切必要性是什么?
【问题讨论】:
-
我没有使用 chef inspec,但是 ansible 和 chef 用于所有基础设施相关的东西以及部署。根据我的理解,厨师的 inspec 被用作底层的测试框架。可以在 playbook 执行前后使用 Chef inspec 来比较结果。我同意配置管理工具是ansible的时候不需要特别说明
标签: testing ansible chef-infra roles inspec