I'm new to Chef and Test-kitchen and I'm trying to use random JSON file as attribute or environment (preferably attribute), but unfortunately I can't access the JSON values from the recipes.
I'm using the following directory structure:
uat
├── attributes
│ ├── dev.json
│ ├── .kitchen
│ │ └── logs
│ │ └── kitchen.log
│ └── prod.json
├── Berksfile
├── Berksfile.lock
├── chefignore
├── environments
│ ├── dev.json
│ └── prod.json
├── Gemfile
├── Gemfile.lock
├── .kitchen
│ ├── default-windows.yml
│ └── logs
│ ├── default-windows.log
│ └── kitchen.log
├── .kitchen.yml
├── metadata.rb
└── recipes
├── default.rb
├── prep.rb
└── service_install.rb
This is the .kitchen.yml:
---
driver:
name: machine
username: sample_user
password: sample_pass
hostname: 192.168.1.102
port: 5985
provisioner:
name: chef_zero
json_attributes: true
environments_path: 'environments/dev'
platforms:
- name: windows
suites:
- name: default
run_list:
- recipe[uat::default]
This is the dev.json:
{
"groupID": "Project-name",
"directoryName": "sample_folder",
"environmentType": "UAT",
}
This is the recipe prep.rb :
directory "C:/Users/test/#{node['directoryName']}" do
recursive true
action :create
end
If I create something.rb in attributes folder and with content: default['directoryName'] = 'sample_folder', it works like a charm, but I need to use a JSON file which to store parameters company wide.
Could you please help me find what I'm doing wrong.