Knife not communicating with Chef Server


#1

I am very new to Chef even though we use it where I am employed. I have decided to teach my self Chef and I installed a server and a workstation then I configured knife on the workstation built my first cookbook and recipe, uploaded cookbook to chef server. So when I tried to Bootstrap a node it wouldn't communicate with the server kept giving me the following error:
[2019-01-31T18:38:45+00:00] ERROR: Error connecting to https://cfchef12.cfs.loc/organizations/coopfire/nodes/cfPEXP, retry 1/5

So I look at the .pem files they were fine then I looked at the cert and it was fine so then I ssh'd to the server and checked the ssh keys and they were fine.

So I saw a post in passing and it was just two words in an inconspicuous line, /etc/host and then I remember in my setup the virtual hosts actually write the configs for the containers and vms and it only adds this (127.0.0.1) to the /etc/hosts, /etc/hostname (is only the host not the fqdn), resolve.conf only had nameserver 127.0.0.1........

1st do this
vim /etc/hostname
change server to server.example.dom

next do the following.

in /etc/hosts
put your ip in here with your fqdn ex server.example.com server
copy and paste the following in it.
127.0.1.1 sever.example.dom server
127.0.0.1. server.exmple.dom server
1xX.xXX.xxx.xxx server.example.dom <- Change this to your actual ip

/etc/resolv.conf
I have 2 local DNS servers in my network so I had to check the resolv.conf
so in it it had just a single line:
nameserver 127.0.0.1 <- remove this

I had to add this to the file and remove the above
nameserver 1XX.xXX.xxx.xx1
nameserver 1XX.xXX.xxx.xx2
nameserver 8.8.8.8

So after I did those changes and by the way no reboots are necessary at all.
Then I went to the workstation and ran the knife bootstrap and everything work fine the client ran on the node I needed it and it did what I asked it to.

Hopefully, This will help other noobs if you new guys need any help I would be happy to do so just contact my at my email attached to my profile or reply to this note.

This is not the only resolution for this error, however it was the resolution for me.

Thanks,
Michael