Closed gh2k closed 5 years ago
Hi, thanks for this. The Travis build failed though, there were some chefspec errors. Have you maybe had a look into the reason for this? We haven't tested this cookbook against the newest Ubuntu, so your PR is a great reminder and I'll try to modify the existing kitchen tests more or less soon-ish, so I can have a better understanding of what caused your problems.
Apols. I'm used to seeing projects where the travis build is broken anyway. :-) I'll check it out.
I updated the tests to allow the usage of ether hostname or hostnamectl. The fix for 14.04 prefers the use of hostnamectl over hostname, if it exists on the machine.
I've added a kitchen test for 14.04, and added a test recipe that writes the node's hostname and fqdn attributes out to a file after the default recipe runs, to test that the node attributes are being correctly propagated to the next recipe.
If I either remove the setting of automatic attributes from the recipe or the part that uses hostnamectl to set the hostname, the incorrect hostname is written to the test file and the serverspec test fails. So it seems like they're both necessary to get it to work.
There may be a more graceful way of getting ohai to pick up the changed values, but I couldn't find one. (I'm no expert, however.)
I found that on my Ubuntu 14.04 box node['hostname'] was not being correctly propagated to subsequent recipes, where node['fqdn'] was. (For example, running this recipe followed by the dynect recipe caused an entry to be created with the wrong hostname.)
After much trial and error, I discovered that in order to make this scenario work I had to do both of:
hostnamectl
to set the hostname, instead of thehostname
command