Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Use cURL to make an API call to change base URL repository for Ambari Blueprints deployment?

avatar
Rising Star

I have successfully uploaded a blueprint to an Ambari server. I am trying now to configure default repositories for HDP installation in our classroom lab environment, as per instructions here:

https://cwiki.apache.org/confluence/display/AMBARI/Blueprints#Blueprints-Step4:SetupStackRepositorie...

I have created the a file, named HDPRepo.test, per the instructions.

446-hdprepo.png

The command I am using is based on what worked for the blueprint upload, but pointed at the repo URI per the instructions:
curl -u admin:admin -i -H 
"X-Requested-By: jedentest1" -X POST -d @HDPRepo.test 
http://node1:8080/api/v1/stacks/HDP/versions/2.3/operating_systems/redhat6/repositories/HDP-2.3/
I can't find this demo'd anywhere on the web, so I'm flying a bit blind. The error being returned is: { "status" : 500, "message" : "Cannot create repositories."} My suspicion is that the documentation is missing some minor piece (possibly a cURL add-on, or perhaps the API URI isn't quite right) that makes this update of the base_url value work. Has anyone actually done this that can point out what I need to modify in my command? Thanks!
1 ACCEPTED SOLUTION

avatar

You are using a POST-request, I think that is the reason why its not working, try PUT. I usually follow these steps when I install my cluster with blueprints

1.Upload blueprint

2.Update repositories

3.Create cluster (upload host mapping)

To update the repositories you can use the following commands.

HDP Utils:

curl -H "X-Requested-By: ambari" -X PUT -u admin:<PASSWORD> http://c6601.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.2/operating_systems/redhat6/reposit... -d @repo_payload

Payload

{
	"Repositories": {
		"base_url": "http://c6601.ambari.apache.org/HDP-UTILS-1.1.0.20/repos/centos6",
		"verify_base_url": true
	}
}

HDP:

curl -H "X-Requested-By: ambari" -X PUT -u admin:<PASSWORD> http://c6601.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.2/operating_systems/redhat6/reposit... -d @repo_payload

Payload

{
	"Repositories": {
		"base_url": "http://c6601.ambari.apache.org/HDP/centos6/2.x/updates/2.2.4.2",
		"verify_base_url": true
	}
}

View solution in original post

4 REPLIES 4

avatar
Rising Star

UPDATE: I finally ran across this issue, which at least explains why the process is not working:

https://issues.apache.org/jira/browse/AMBARI-12811

The question now, then, becomes "How do I update the repo_version table prior to a blueprint-based installation?"

avatar
Rising Star

And remember, I am writing a publicly available training course, so please, no answers that require hacking that you would not suggest the average administrator to attempt. 🙂

avatar

You are using a POST-request, I think that is the reason why its not working, try PUT. I usually follow these steps when I install my cluster with blueprints

1.Upload blueprint

2.Update repositories

3.Create cluster (upload host mapping)

To update the repositories you can use the following commands.

HDP Utils:

curl -H "X-Requested-By: ambari" -X PUT -u admin:<PASSWORD> http://c6601.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.2/operating_systems/redhat6/reposit... -d @repo_payload

Payload

{
	"Repositories": {
		"base_url": "http://c6601.ambari.apache.org/HDP-UTILS-1.1.0.20/repos/centos6",
		"verify_base_url": true
	}
}

HDP:

curl -H "X-Requested-By: ambari" -X PUT -u admin:<PASSWORD> http://c6601.ambari.apache.org:8080/api/v1/stacks/HDP/versions/2.2/operating_systems/redhat6/reposit... -d @repo_payload

Payload

{
	"Repositories": {
		"base_url": "http://c6601.ambari.apache.org/HDP/centos6/2.x/updates/2.2.4.2",
		"verify_base_url": true
	}
}

avatar
Rising Star

That was it! Thanks Jonas!