# Using 2 config files - InternalSettingsPerparer issue

**URL:** <https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750>\
**Category:** Elasticsearch\
**Created:** [November 2, 2011, 5:39pm UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750 "2011-11-02T17:39:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlagorce](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vlagorce/32/2764_2.png) [@vlagorce](https://discuss.elastic.co/u/vlagorce)\
**Post date:** [November 2, 2011, 5:39pm UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/1 "2011-11-02T17:39:27Z")

</div>

Hi Folks,

I need to have 2 configuration files.

The first (first-elasticsearch.yml) will be package in my jar\* file,  
and the second will be externalized. [https://gist.github.com/1334242](https://gist.github.com/1334242)

It almost works but something looks strange in the  
InternalSettingsPerparer.

- builder.settings().loadFromClasspath load the first file and the  
path.config is resolved.
- builder.build() instantiate a new InternalNode() which run  
InternalSettingsPerparer.prepareSettings(pSettings,  
loadConfigSettings).
- prepareSettings load the file by using  
settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"));  
settingsBuilder no contains the new value  
~But in the end prepareSettings(..) execute  
settingsBuilder.put(pSettings). This will restore the previous values :  
(.

Is it a feature to override last loaded properties with the initial  
settings ? I can't understand the need of calling the  
settingsBuilder.put(pSettings) two times.

@Shay In the same time I think there's a typo in the class name 😉  
Perparer instead of Preparer.

====  
\*My ES is embeded.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 2, 2011, 11:03pm UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/2 "2011-11-02T23:03:11Z")

</div>

I am not sure I follow... . Do you mean that you expect the  
first-elasticsearch.yml setting to override the ones loaded by  
elasticsearch automatically from the classpath?

On Wed, Nov 2, 2011 at 7:39 PM, vlag [vlagorce@gmail.com](mailto:vlagorce@gmail.com) wrote:

> Hi Folks,
> 
> I need to have 2 configuration files.
> 
> The first (first-elasticsearch.yml) will be package in my jar\* file,  
> and the second will be externalized. [https://gist.github.com/1334242](https://gist.github.com/1334242)
> 
> It almost works but something looks strange in the  
> InternalSettingsPerparer.
> 
> - builder.settings().loadFromClasspath load the first file and the  
> path.config is resolved.
> - builder.build() instantiate a new InternalNode() which run  
> InternalSettingsPerparer.prepareSettings(pSettings,  
> loadConfigSettings).
> - prepareSettings load the file by using
> 
> settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"));  
> settingsBuilder no contains the new value  
> ~But in the end prepareSettings(..) execute  
> settingsBuilder.put(pSettings). This will restore the previous values :  
> (.
> 
> Is it a feature to override last loaded properties with the initial  
> settings ? I can't understand the need of calling the  
> settingsBuilder.put(pSettings) two times.
> 
> @Shay In the same time I think there's a typo in the class name 😉  
> Perparer instead of Preparer.
> 
> ====  
> \*My ES is embeded.

---

<div class="post-metadata">

**Author:** ![vlagorce](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vlagorce/32/2764_2.png) [@vlagorce](https://discuss.elastic.co/u/vlagorce)\
**Post date:** [November 3, 2011, 8:29am UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/3 "2011-11-03T08:29:55Z")

</div>

What you describe it's not what I expect, it's what's happened !

The "firts-elasticsearch.yml" is load from classpath (coded in my  
methode) and define the location of the second. The second is loaded  
when the node is create but even if the properties are loaded the  
second call of settingsBuilder.put(pSettings) restore the properties  
comming from the first file.

I just want to define configuration in my jar and be able to override  
some properties when needed by server administrator.( like cluster-  
name, allowed ip,.. )

On Nov 3, 12:03 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> I am not sure I follow... . Do you mean that you expect the  
> first-elasticsearch.yml setting to override the ones loaded by  
> elasticsearch automatically from the classpath?
> 
> On Wed, Nov 2, 2011 at 7:39 PM, vlag [vlago...@gmail.com](mailto:vlago...@gmail.com) wrote:
> 
> > Hi Folks,
> 
> > I need to have 2 configuration files.
> 
> > The first (first-elasticsearch.yml) will be package in my jar\* file,  
> > and the second will be externalized.[https://gist.github.com/1334242](https://gist.github.com/1334242)
> 
> > It almost works but something looks strange in the  
> > InternalSettingsPerparer.
> 
> > - builder.settings().loadFromClasspath load the first file and the  
> > path.config is resolved.
> > - builder.build() instantiate a new InternalNode() which run  
> > InternalSettingsPerparer.prepareSettings(pSettings,  
> > loadConfigSettings).
> > - prepareSettings load the file by using
> 
> > settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml")) ;  
> > settingsBuilder no contains the new value  
> > ~But in the end prepareSettings(..) execute  
> > settingsBuilder.put(pSettings). This will restore the previous values :  
> > (.
> 
> > Is it a feature to override last loaded properties with the initial  
> > settings ? I can't understand the need of calling the  
> > settingsBuilder.put(pSettings) two times.
> 
> > @Shay In the same time I think there's a typo in the class name 😉  
> > Perparer instead of Preparer.
> 
> > ====  
> > \*My ES is embeded.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 3, 2011, 5:37pm UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/4 "2011-11-03T17:37:50Z")

</div>

Thats the order that its executed... . There is no reason though that you  
can't simply construct your own settings object, load into the data from  
the two files (in the order that you want), and then pass the settings to  
the node builder. You can also configure it to not load the default  
settings.

On Thu, Nov 3, 2011 at 10:29 AM, vlag [vlagorce@gmail.com](mailto:vlagorce@gmail.com) wrote:

> What you describe it's not what I expect, it's what's happened !
> 
> The "firts-elasticsearch.yml" is load from classpath (coded in my  
> methode) and define the location of the second. The second is loaded  
> when the node is create but even if the properties are loaded the  
> second call of settingsBuilder.put(pSettings) restore the properties  
> comming from the first file.
> 
> I just want to define configuration in my jar and be able to override  
> some properties when needed by server administrator.( like cluster-  
> name, allowed ip,.. )
> 
> On Nov 3, 12:03 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > I am not sure I follow... . Do you mean that you expect the  
> > first-elasticsearch.yml setting to override the ones loaded by  
> > elasticsearch automatically from the classpath?
> > 
> > On Wed, Nov 2, 2011 at 7:39 PM, vlag [vlago...@gmail.com](mailto:vlago...@gmail.com) wrote:
> > 
> > > Hi Folks,
> > 
> > > I need to have 2 configuration files.
> > 
> > > The first (first-elasticsearch.yml) will be package in my jar\* file,  
> > > and the second will be externalized.[https://gist.github.com/1334242](https://gist.github.com/1334242)
> > 
> > > It almost works but something looks strange in the  
> > > InternalSettingsPerparer.
> > 
> > > - builder.settings().loadFromClasspath load the first file and the  
> > > path.config is resolved.
> > > - builder.build() instantiate a new InternalNode() which run  
> > > InternalSettingsPerparer.prepareSettings(pSettings,  
> > > loadConfigSettings).
> > > - prepareSettings load the file by using
> > 
> > >
> 
> settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"))  
> ;
> 
> > > settingsBuilder no contains the new value  
> > > ~But in the end prepareSettings(..) execute  
> > > settingsBuilder.put(pSettings). This will restore the previous values :  
> > > (.
> > 
> > > Is it a feature to override last loaded properties with the initial  
> > > settings ? I can't understand the need of calling the  
> > > settingsBuilder.put(pSettings) two times.
> > 
> > > @Shay In the same time I think there's a typo in the class name 😉  
> > > Perparer instead of Preparer.
> > 
> > > ====  
> > > \*My ES is embeded.

---

<div class="post-metadata">

**Author:** ![vlagorce](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vlagorce/32/2764_2.png) [@vlagorce](https://discuss.elastic.co/u/vlagorce)\
**Post date:** [November 4, 2011, 9:14am UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/5 "2011-11-04T09:14:58Z")

</div>

...I just realize that...I am ashamed !!

I easily won the first price for "The useless question of the week  
(.may be more ::)".

Thanks Shay.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 8, 2011, 3:01am UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/6 "2011-11-08T03:01:58Z")

</div>

No need for that :), I thought it was a good question 🙂

On Fri, Nov 4, 2011 at 11:14 AM, vlag [vlagorce@gmail.com](mailto:vlagorce@gmail.com) wrote:

> ...I just realize that...I am ashamed !!
> 
> I easily won the first price for "The useless question of the week  
> (.may be more ::)".
> 
> Thanks Shay.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:49am UTC](https://discuss.elastic.co/t/using-2-config-files-internalsettingsperparer-issue/5750/7 "2017-07-06T03:49:40Z")

</div>


