Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing chef data bags

Tags:

chef-infra

I need to test chef recipe. This is using a data bag.

kitchen is using chef_zero in order to provision the machine. So, it's not able to get my data bag hosted on server. Then it's telling me that my data bag is not available.

How could I get a data bag available on test kitchen?

I've created a aws.json file on test\integration\data_bags:

{
  "id": "dev",
  "aws_access_key_id": "----",
  "aws_secret_access_key": "----"
}

When I perform my converge I'm getting this message:

INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/data/aws/dev

ERROR: Failed to load data bag item: "aws" "dev"

.kitchen.yml file content:

---
driver:
  name: vagrant

provisioner:
  name: chef_zero
  always_update_cookbooks: true

verifier:
  name: inspec

platforms:
  - name: ubuntu-16.04
  - name: centos-7.2

suites:
  - name: default
    data_bags_path: "test/integration/data_bags"
    run_list:
      - recipe[living-development::default]
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes:

Versions:

$ vagrant -v
1.9.2

$ chef -v
Chef Development Kit Version: 1.2.22
chef-client version: 12.18.31
delivery version: master (0b746cafed65a9ea1a79de3cc546e7922de9187c)
berks version: 2017-03-08T11:19:04.643719 5824] 2017-03-08T11:19:04.643719 5824] 2017-03-08T11:19:04.643719 5824] 2017-03-08T11:19:04.643719 5824] 2017-03-08T11:19:04.700789 5824] 2017-03-08T11:19:04.700789 5824] 5.6.0
kitchen version: 1.15.0
like image 381
Jordi Avatar asked Mar 10 '23 16:03

Jordi


1 Answers

The server error indicates that is searching something called aws/dev (where aws is the data bag's name and dev is the name of the item within that data bag).

So you would have to place your JSON file under test/integration/data_bags/aws/dev.json.

Btw. you don't have to manually specify the data_bags_path, as test-kitchen will search for items at exactly this path.

like image 95
StephenKing Avatar answered Mar 15 '23 07:03

StephenKing