Is it possible to use environment variables or similar to automatically set an Elasticsearch node name to the hostname of the machine?
i.e. if a machine is called ES1, the ES node name would also be ES1 without having to configure it in elasticsearch.yml manually?
             
            
               
               
              1 Like 
            
                
            
           
          
            
              
                dakrone  
                (Lee Hinman)
               
              
                  
                    May 19, 2015,  2:41pm
                   
                   
              2 
               
             
            
              Yes, you can substitute any environment variable in elasticsearch.yml by using ${...} notation, such as:
node.name: ${HOSTNAME} 
             
            
               
               
              1 Like 
            
            
           
          
            
            
              Perfect - thank you. I tried to find something about this in the documentation but clearly wasn't looking in the right place!
             
            
               
               
               
            
            
           
          
            
            
              I found that I had to add the following line to /etc/init.d/elasticsearch script (on Ubuntu):
export NODENAME=`hostname`
 
N.B. Important that you use back ticks for this 
and then update elasticsearch.yml to:
node.name: ${NODENAME} 
             
            
               
               
               
            
            
           
          
            
              
                warkolm  
                (Mark Walkom)
               
              
                  
                    May 20, 2015,  8:29am
                   
                   
              6 
               
             
            
              I wouldn't edit the init script, this can change between versions and you might find an upgrade will break it.
             
            
               
               
               
            
            
           
          
            
            
              Thanks for the advice @warkolm  - I'll look into alternative ways of setting the env variable!