Support Questions
Find answers, ask questions, and share your expertise

How can I change a config during the setup of a new service?

Highlighted

How can I change a config during the setup of a new service?

I am trying to setup a new custom service, and I would like to be able to update Ambari's view of the configuration from the python script. However, when I try to set a value (e.g. Script.get_config()['configurations']['my-config-file']['my-property'] = "some data"), I see an error telling me I cannot update the immutable config dict.

I see some methods in the Ambari python resource_management.core source such as "update_config", "set_params", etc. that seem like they might be what I need, but they are not well documented.

The Ambari REST API is not an option either, unless I can determine the Ambari username/password from inside the script.

Is there a good way for me to set a property from within the python script?

4 REPLIES 4
Highlighted

Re: How can I change a config during the setup of a new service?

Rising Star

It can be done via Stack Advisor. Does that option work for you ?

Highlighted

Re: How can I change a config during the setup of a new service?

Yes, I think that'll work. Can you point me to the relevant documentation?

Re: How can I change a config during the setup of a new service?

Rising Star

@Ben Weintraub Thanks for confirming.

- In order to go the Stack Advisor route, check the stack and version on which you are trying to support/add this service.

Lets take example of HDP stack 2.5 and service as HIVE.

File path : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...

Lets say you are adding service named 'myService' in HDP 2.5 stack. You may name you recommendation fn. as "recommendMyServiceConfigurations". You will add this fn. to the dictionary here :

https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...

- After that you will write definition for your function "recommendMyServiceConfigurations()", reference fn.:

https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...

The way to deposit value for the config can be referred here as :

https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...

I assume that you will have relevant config file (.xml) associated with your service, of which configuration that you intend to set/modify is part of. Lets say its name is 'myService-site.xml'.

After that, if this config change is made dependent on any other config change, you need to add depends-on tag. Eg: if you intend to change configs 'A' based on change in config 'B', you may do like this:

<property>
  <name>A</name>
  <value>some_value</value>
  <description></description>
  <depends-on>
    <property>
      <type>B-config_site-name</type>
      <name>B</name>
    </property>
  </depends-on>
</property>

For reference, see : https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.5/services...

- In case there is no explicit dependency possible, you may need to do the forced-configuration use, as otherwise Stack Advisor will filter the recommendation made. You will add the config 'A' in to 'forced-configuration', so that Stack Advisor doesn't filter it out while sending recommendations. Reference:

https://github.com/apache/ambari/blob/trunk/ambari-server/src/main/resources/stacks/HDP/2.0.6/servic...

and then the same way you will deposit value, as mentioned earlier.

For testing while while development, you may put debugs to see we are hitting the code and eventually depositing value to config. Finally, whether the recommendation actually made way to UI, you can do it by doing inspect element on browser. Example browser on Chrome, and we are have set the value for config 'hive.llap.daemon.yarn.container.mb' on same lines as mentioned above.

screen-shot-2016-07-23-at-20146-pm.png

Let me know if you run into any issues and the stage you are at while developing/testing.

Highlighted

Re: How can I change a config during the setup of a new service?