在Ansible + Test Kitchen中包含依赖项

时间:2016-05-21 14:06:29

标签: ansible test-kitchen

我正在努力让Ansible + Test Kitchen工作,我的代码可以在Github获得。

运行kitchen test时出错:

   ERROR! the role 'geerlingguy.java' was not found in /tmp/kitchen/roles:/tmp/kitchen:/tmp/kitchen/roles:/tmp/kitchen/roles

   The error appears to have been in '/tmp/kitchen/roles/ansible-nexus/meta/main.yml': line 3, column 5, but may
   be elsewhere in the file depending on the exact syntax problem.

   The offending line appears to be:

   dependencies:
     - { role: geerlingguy.java }

有没有办法告诉Test Kitchen首先从Ansible Galaxy中获取依赖项?

2 个答案:

答案 0 :(得分:2)

您应该包含以下更改: .kitchen.yml

provisioner:
  hosts: test-kitchen
  name: ansible_playbook
  #require_chef_for_busser: false
  #require_ruby_for_busser: true
  ansible_verbosity: 2
  ansible_verbose: true
  require_ansible_repo: false
  require_ansible_omnibus: true
  requirements_path: requirements-test.txt
  #
  # When testing with Test Kitchen, run the Docker client with
  # "--insecure-registry registry.yourdomain.local" so that we can test pushing
  # to our test private registry.
  #
  #extra_vars:
  #  docker_opts: "--insecure-registry registry.yourdomain.local"

要求-test.txt的

geerlingguy.java

答案 1 :(得分:0)

我还找到了另一种方法:根据doco here创建Ansiblefile,将gem 'librarian-ansible'添加到Gemfile,并在{{1}中指定角色}}。然而,我怀疑@Valeriy Solovyov的答案更为正确。