0
votes

I am new to Chef, I went through the tutorial for managing nodes using Vagrant, but now I am trying to setup my production environment. I am having problems Bootstrapping a node.

The chef-server is setup and functional. When I check my ssl, its succeeds:

Connecting to host $CHEF_SERVER_HOSTNAME$:443
Successfully verified certificates from `$CHEF_SERVER_HOSTNAME$'

I can upload cookbooks and roles. So I am assuming that my chef server is setup properly.

The problem is when I am bootstraping a node I get an authentication error, saying that the node cannot communicate with the chef server (getting a 401 error)

Example command for bootstraping a node:

knife bootstrap $NODE_IP$ --ssh-port 22 --ssh-user $NODE_USER$  --ssh-password $NODE_USER_PASS$ --sudo --use-sudo-password  --node-name node-1 --run-list 'role[some-role]'

I am getting the following stack trace

[sudo] password for manager: -----> Existing Chef installation detected
Starting the first Chef Client run...
[2017-04-02T21:35:19+02:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.19.36
[2017-04-02T21:35:19+02:00] INFO: *** Chef 12.19.36 ***
[2017-04-02T21:35:19+02:00] INFO: Platform: x86_64-linux
[2017-04-02T21:35:19+02:00] INFO: Chef-client pid: 5271
Creating a new client identity for node-1 using the validator key.
[2017-04-02T21:35:21+02:00] INFO: Client key /etc/chef/client.pem is not present - registering
[2017-04-02T21:35:22+02:00] INFO: HTTP Request Returned 401 Unauthorized: error

================================================================================
Chef encountered an error attempting to create the client "node-1"
================================================================================

Authentication Error:
---------------------
Failed to authenticate to the chef server (http 401).

Server Response:
----------------
Failed to authenticate as 'chef-validator'. Ensure that your node_name and client key are correct.

Relevant Config Settings:
-------------------------
chef_server_url         "https://$CHEF_SERVER$/organizations/pds"
validation_client_name  "chef-validator"
validation_key          "/etc/chef/validation.pem"

If these settings are correct, your validation_key may be invalid.

Platform:
---------
x86_64-linux


Running handlers:
[2017-04-02T21:35:22+02:00] ERROR: Running exception handlers
Running handlers complete
[2017-04-02T21:35:22+02:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 03 seconds
[2017-04-02T21:35:22+02:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-04-02T21:35:22+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-04-02T21:35:22+02:00] ERROR: 401 "Unauthorized"
[2017-04-02T21:35:22+02:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I tried deleting the validation.pem file and re-running the command, but i get the same result.

I'm pretty lost here, what can I do?

1
Are you sure your organization key is valid? From 12.2.0 chef can bootstrap validatorless. It's just required to pass node name which are you doing, is your user in admin group? Also IRC, validator_client_name by default is <org_name>-validator, so in your case pds-validator. - Szymon Szypulski
401 is the HTTP return code for an authentication failure. @Szymon is correct that you'll need to check your credentials - Mark O'Connor

1 Answers

0
votes

As part chef workstation setup, you should copy .pem files from chef server to workstation. did you did that step?