Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Is it possible to modify Ambari "cluster-env.xml" value using Ambari Blueprint?

Highlighted

Is it possible to modify Ambari "cluster-env.xml" value using Ambari Blueprint?

Guru

Is it possible to set the values inside of Ambari's cluster-env.xml file using Ambari blueprints? I'm struggling to understand if this is something that would be under Ambari's jurisdiction since it is possible from the Ambari REST API or it would be a higher level tool (chef for example) that would be responsible for adjusting those values?

3 REPLIES 3

Re: Is it possible to modify Ambari "cluster-env.xml" value using Ambari Blueprint?

New Contributor

@Jeremy Dyer A good reference for modifying the configurations is here: https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/configuration.md

In my environment I wanted to modify the repo template so I pulled down my current configuration as a template.

GET http://hdphome.mscottsummers.com:8080/api/v1/clusters/HDPHome/configurations?type=cluster-env&tag=ve...

{
  "href" : "http://hdphome.mscottsummers.com:8080/api/v1/clusters/HDPHome/configurations?type=cluster-env&tag=version1",
  "items" : [
    {
      "href" : "http://hdphome.mscottsummers.com:8080/api/v1/clusters/HDPHome/configurations?type=cluster-env&tag=version1",
      "tag" : "version1",
      "type" : "cluster-env",
      "version" : 1,
      "Config" : {
        "cluster_name" : "HDPHome",
        "stack_id" : "HDP-2.4"
      },
      "properties" : {
        "fetch_nonlocal_groups" : "true",
        "ignore_groupsusers_create" : "false",
        "kerberos_domain" : "EXAMPLE.COM",
        "managed_hdfs_resource_property_names" : "",
        "override_uid" : "true",
        "repo_suse_rhel_template" : "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
        "repo_ubuntu_template" : "{{package_type}} {{base_url}} {{components}}",
        "security_enabled" : "false",
        "smokeuser" : "ambari-qa",
        "smokeuser_keytab" : "/etc/security/keytabs/smokeuser.headless.keytab",
        "user_group" : "hadoop"
      }
    }
  ]
}

Then modified the information in the Properties Field:

{
      "tag" : "version3",
      "type" : "cluster-env",
      "version" : 3,
      "properties" : {
		"fetch_nonlocal_groups" : "true",
        "ignore_groupsusers_create" : "false",
        "kerberos_domain" : "EXAMPLE.COM",
        "managed_hdfs_resource_property_names" : "",
        "override_uid" : "true",
        "repo_suse_rhel_template" : "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0\n#Changed by Scott",
        "repo_ubuntu_template" : "{{package_type}} {{base_url}} {{components}}",
        "security_enabled" : "false",
        "smokeuser" : "ambari-qa",
        "smokeuser_keytab" : "/etc/security/keytabs/smokeuser.headless.keytab",
        "user_group" : "hadoop"
      }
}

Now post the configuration change:

curl -X "POST" "http://hdphome.mscottsummers.com:8080/api/v1/clusters/HDPHome/configurations" \
	-H "X-Requested-By: ambari" \
	-H "Authorization: Basic YWRtaW46YWRtaW4=" \
	-H "Content-Type: text/plain; charset=utf-8" \
	-H "Cookie: AMBARISESSIONID=az7ol5dht98w1kg26mm0w5qci" \
	-d $'{
      "tag" : "version3",
      "type" : "cluster-env",
      "version" : 3,
      "properties" : {
		"fetch_nonlocal_groups" : "true",
        "ignore_groupsusers_create" : "false",
        "kerberos_domain" : "EXAMPLE.COM",
        "managed_hdfs_resource_property_names" : "",
        "override_uid" : "true",
        "repo_suse_rhel_template" : "[{{repo_id}}]\\nname={{repo_id}}\\n{% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\\n\\npath=/\\nenabled=1\\ngpgcheck=0\\n#Changed by Scott",
        "repo_ubuntu_template" : "{{package_type}} {{base_url}} {{components}}",
        "security_enabled" : "false",
        "smokeuser" : "ambari-qa",
        "smokeuser_keytab" : "/etc/security/keytabs/smokeuser.headless.keytab",
        "user_group" : "hadoop"
      }
}
'

Finally set the desired Configuration:

curl -X "PUT" "http://hdphome.mscottsummers.com:8080/api/v1/clusters/HDPHome" \
	-H "X-Requested-By: ambari" \
	-H "Authorization: Basic YWRtaW46YWRtaW4=" \
	-H "Content-Type: text/plain; charset=utf-8" \
	-H "Cookie: AMBARISESSIONID=az7ol5dht98w1kg26mm0w5qci" \
	-d $'{
  "Clusters": {
    "desired_config": {
      "type": "cluster-env",
      "tag": "version3"
    }
  }
}'

After restarting my services my /etc/yum.repos.d/HDP*.repo are now showing the new changes.

[root@hdphome ~]# cat /etc/yum.repos.d/HDP.repo 
[HDP-2.4]
name=HDP-2.4
baseurl=http://emule.mscottsummers.com/HDP/centos6/HDP-2.4.2.0

path=/
enabled=1
gpgcheck=0
#Changed by Scott

Hope that helps you out.

Re: Is it possible to modify Ambari "cluster-env.xml" value using Ambari Blueprint?

New Contributor

I am also having problem where I want to change repo template for my cluster.

When I tried to get configuration, I didn't get "properties" in reply. I Only got :

{ "href" : "http://xxx.net:8080/api/v1/clusters/MY_HDP/configurations?type=cluster-env", "items" :

[

{

"href" : "http://xxx.net:8080/api/v1/clusters/MY_HDP/configurations?type=cluster-env&tag=version1",

"tag" : "version1",

"type" : "cluster-env",

"version" : 1,

"Config" :

{ "cluster_name" : "MY_HDP", "stack_id" : "HDP-2.5" }

}

] }

Do I have to create cluster using REST BEFORE proceeding with AMBARI UI ??

Re: Is it possible to modify Ambari "cluster-env.xml" value using Ambari Blueprint?

Rising Star

Hi @Jeremy Dyer,

It is definitely possible to configure cluster-env.xml using Blueprints for a cluster install. You can just treat this as another configuration type specified in the Blueprint, with a configuration type of "cluster-env".

Hope this helps!

Don't have an account?
Coming from Hortonworks? Activate your account here