1

I want to search the hostname with

searchnode = search(:node, "zookeeper:true")

Want to get output Hostname.fqdn.com as node but i am not getting it. Maybe I don't know how to access the attribute.

---
driver:
  name: vagrant

provisioner:
  name: chef_zero
  environments_path: test/integration/default/environments
  client_rb:
    environment: stg

  always_update_cookbooks: true

verifier:
  name: inspec

platforms:
  - name: centos-7.2

suites:
  - name: Hostname.fqdn.com
    run_list:

          - recipe[test-cookbook::test]


    data_bags_path: "test/integration/default/data_bags"


attributes: {zookeeper: "true"}
StephenKing
  • 36,187
  • 11
  • 83
  • 112
Udhay
  • 7
  • 7

1 Answers1

3

Your .kitchen.yml is not valid, as the top-level attributes section is ignored. You should move this below the suite's elements (indentation matters with YAML!):

suites:
  - name: Hostname.fqdn.com
    run_list:
      - recipe[test-cookbook::test]
    data_bags_path: "test/integration/default/data_bags"
    attributes: {zookeeper: "true"}

Then, your search should find this node. You can use kitchen diagnose to see the resulting attributes.

If you want to mock other nodes in test-kitchen, you can place JSON files containing the node definitions in test/integration/nodes (as used in this cookbook; can be configured via node_path). You can then use search to "discover" other nodes based on their attributes or run lists.

StephenKing
  • 36,187
  • 11
  • 83
  • 112