0

Here is my kitchen.yml

---
driver:
  name: vagrant
  network:
    - ["private_network", {ip: "192.168.35.35"}]

provisioner:
  name: chef_zero
  # You may wish to disable always updating cookbooks in CI or other testing environments.
  # For example:
  #   always_update_cookbooks: <%= !ENV['CI'] %>
  always_update_cookbooks: true
  roles_path: test/integration/roles/

verifier:
  name: inspec

platforms:
  - name: ubuntu-14.04

suites:
  - name: default
    run_list:
      - role[tomcat_role]
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes:

and I keep getting the following error

    [2017-04-24T10:39:02+00:00] ERROR: Role tomcat_role (included by 'top lev
el') is in the runlist but does not exist. Skipping expand.

       =========================================================================
=======
       Error expanding the run_list:
       =========================================================================
=======

       Missing Role(s) in Run List:
       ----------------------------
       * tomcat_role included by 'top level'

role is definitely there on chef server but still I am getting this error. Are we not allowed to use role in kitchen.yml's run list attribute?

codec
  • 7,978
  • 26
  • 71
  • 127
  • Chef Server doesn't matter since you're using a local provisioner, but what path did you put the test role in? – coderanger Apr 24 '17 at 11:22
  • The json file (tomcat.json) is in test/integration/roles folder `roles_path: test/integration/roles/` updating the post. – codec Apr 24 '17 at 12:12
  • Is there any specific location I should keep my json file in? – codec Apr 24 '17 at 12:35
  • If you call the role file `tomcat.json`, then you shouldn't refer to it as `tomcat_role` in test-kitchen. IIRC the file name matters. – StephenKing Apr 24 '17 at 14:28
  • I tried. My json file name is `tomcatrole` , the name field in the json is also `tomcatrole` and in kitchen.yml also I have `tomcatrole` run_list: - "role[tomcatrole]" – codec Apr 25 '17 at 05:11

2 Answers2

2

As mentioned in the comments, the filename of the role must match its name field and that must match the role[name] string in the run list. Make sure all three of those align and you should be all set.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • I tried. My json file name is `tomcatrole` , the name field in the json is also `tomcatrole` and in kitchen.yml also I have `tomcatrole` run_list: - "role[tomcatrole]" – codec Apr 25 '17 at 05:11
1

Ok so the issue was with roles_paths . I changed it to role_path and everything worked.

codec
  • 7,978
  • 26
  • 71
  • 127