I wrote some control test for Mysql cookbook and i'd like to run some queries using mysql cli, but, for that, i need to insert root password first. I have this pass stored in a attribute but and don't know how use in my inspec profile. Any idea?
In worst of the worst of the worst case, you can load inside inspec /tmp/kitchen/nodes/node-name.json with node attrs. But its ugly and contradicts idea of InSpec itself and integration testing specifically.
Sorry for the late reply When testing existing servers for compliance, I get attribute values using the knife command on the server being tested:
require 'json'
attr_json = JSON.parse(command("knife node show -c /etc/chef/client.rb #{sys_info.hostname('full')} -a 'my.attrib.name' -Fjson").stdout)
Now, we can access the attribute value using attr_json.values[0]['my.attrib.name'] or attr_json[sys_info.hostname('full')]['my.attrib.name']
As you can see, nodes are named after the server's full hostname, but in case you use a different naming convention, you can get the node name from node_name in /etc/chef/client.rb