Terrapins-MacBook-Pro:.chef Terrapin$ knife ssl fetch
ERROR: CONFIGURATION ERROR:Unable to parse Credentials file: /Users/Terrapin/.chef/credentials
parse error on value “] || ENV[” (STRING_LITERAL)
This is my credential file:
[default]
client_name = ‘user = ENV[‘OPSCODE_USER’] || ENV[‘USER’]’
client_key = ‘/Users/Terrapin/.chef/user = ENV[‘OPSCODE_USER’] || ENV[‘USER’].pem’
chef_server_url = ‘knife configure current_dir = File.dirname(FILE)’
Can anyone help figure out why it does this?
Hi,
For better readability please use the Forums code formatting tools. This will make life for those trying to help you a lot easier.
client_name = ‘user = ENV[‘OPSCODE_USER’] || ENV[‘USER’]’
client_key = ‘/Users/Terrapin/.chef/user = ENV[‘OPSCODE_USER’] || ENV[‘USER’].pem’
chef_server_url = ‘knife configure current_dir = File.dirname(FILE)’
In your case good syntax highlighting could’ve actually saved the day. You are using single quotes everywhere. So if you need to have quotes in quotes and have some strange syntax going on. Something like this should be correct:
client_name = ENV['OPSCODE_USER'] || ENV['USER']
client_key = '/Users/Terrapin/.chef/user' + (ENV[‘OPSCODE_USER’] || ENV[‘USER’]) + '.pem'
chef_server_url = File.dirname(FILE)
Although I am pretty sure that the chef_server_url will not be correct.
1 Like
The credentials file is not ruby code and is not interpolated.
The point is that you can have many different credentials blocks, and select them with the CHEF_PROFILE environment variable:
[user_a]
client_name = "user_a"
client_key = "/Users/Terrapin/.chef/user_a.pem"
chef_server_url = "https...."
[user_b]
...
then your CHEF_PROFILE
would be set to either user_a
or user_b
.
1 Like
Is there documentation available that articulates the use of this ‘credentials’ feature with knife?
In my case, I have a “paid.pem” to connect to the node (generated by amazon) and a “chefadmin.pem” that I generated when I installed chef server directly on the (chef-server)ec2 instance (after connecting to it). I am going to use a second (currently blank) ec2 instance as the node i’m bootstrapping.
So I’m assuming the paid.pem would be the client_key, but what would user a be?
New Config file:
client_name = "ubuntu"
client_key = "/Users/Terrapin/learn-chef/.chef/paid.pem"
chef_server_url = "ec2-18-191-14-213.us-east-2.compute.amazonaws.com"
Returned:
> Terrapins-MacBook-Pro:.chef Terrapin$ knife ssl fetch
> ERROR: CONFIGURATION ERROR:Unable to parse Credentials file:
/Users/Terrapin/.chef/credentials
> undefined method `key?' for nil:NilClass
I also tried it with "https://ec2-18-191-14-213.us-east-2.compute.amazonaws.com. Same story.
What do you mean about "? There are only ’ in mine. Do you mean ‘_’ within ‘__’?
I am not sure why I am getting ENV errors. I was unable to locate anything called CHEF_PROFILE
I think the problem may have been caused when i SCP’ed the files or when I ran the script with everything as sudo on the server.
Whatever I did also ran up a $5 tab on EC2 in one hour.
Problem (in addition to the one you helped me with) turned out to be my instance was too small and didn’t have enough space to install the files. Started paying for EC2 and it worked.