canonical / canonical/cloud-init
Setting node name in chef to hostname
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
This bug was originally filed in Launchpad as [LP: #1912437](https://bugs.launchpad.net/cloud-init/+bug/1912437)
Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2021-01-20T05:01:19.729344+00:00
date_fix_committed = None
date_fix_released = None
id = 1912437
importance = wishlist
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1912437
milestone = None
owner = scahartner
owner_name = Alex
private = False
status = triaged
submitter = scahartner
submitter_name = Alex
tags = ['chef']
duplicates = []
_Launchpad user **Alex(scahartner)** wrote on 2021-01-20T05:01:19.729344+00:00_
We are using auto-install to PXE boot a number of ubuntu 20.04 hosts. These hosts are physical servers. The hostname is set via DHCP, however in the auto-install configuration file we set the identity to "localhost".
We are also trying to boot strap these servers with chef. For this we are using the user-data section in auto-install to invoke the chef module of cloud-init on first boot. This kinda works, but all the hosts which register with our chef server in this way report with a name of : iid-datasource-none
The only way we have found so far around this problem was to not accept the license in the chef module and to invoke a chef-client run via the run-cmd module as follows.
runcmd:
- knife ssl fetch -c /etc/chef/client.rb
- knife ssl check -c /etc/chef/client.rb
- chef-client -N `hostname -f` --chef-license accept
- rm /etc/chef/validation.pem
This is not a very nice approach and it would be much better to have this option supported in the node_name attribute from the chef module or maybe add a separate flag to the module to use the systems hostname rather than the identity or the hostname (localhost) cloud-init thinks we are using.
Hopefully there is another way around this which I have missed so far.
Contributor guide
Assessment
This issue has not been assessed yet.