I am trying to set a fully qualified domain name on EC2 instance. I have set CNAME entry in Route53, so when I go to sync1.staging1.mycompany.net, it resolves to the correct instance.
What I have done so far without success, I have edited /etc/hostname (so it stays the same after restarting):
sync1.staging1.mycompany.netI have then used hostname command to set the hostname:
sudo hostname sync1.staging1.mycompany.netI have then edited /etc/hosts and made sure this line is there:
127.0.0.1 localhost sync1.staging1.mycompany.net sync1The problem is, when I run hostname -f, I get:
localhostWhen I run hostname -s, I get correctly:
sync1When I run just hostname without parameters, I get:
sync1.staging1.mycompany.net sync1The problem is I am trying to run a Puppet manifests which needs the fully qualified domain name to be set, otherwise I am getting an error when I run puppet apply manifests/site.pp:
Error: Could not find default node or by name with 'sync1.eu-west-1.compute.internal, sync1.eu-west-1.compute, sync1.eu-west-1, sync1' on node sync1.eu-west-1.compute.internal
Error: Could not find default node or by name with 'sync1.eu-west-1.compute.internal, sync1.eu-west-1.compute, sync1.eu-west-1, sync1' on node sync1.eu-west-1.compute.internalThis is EC2 instance running on Ubuntu 12.04 LTS.
Any ideas? Do I need to set and elastic IP address for the instance in order for it to have the fully qualified domain name?
1 Answer
hostname -f will return the first name after 127.0.0.1
So simply switching localhost and your fqdn will give you a correct return address while the localhost alias will still work.
3