API call using Ansible uri module
I am trying to use the Ansible uri module to communicate with DeployHQ's API.
Here is the example DeployHQ's documentation that I am trying to use from Ansible:
curl -H "Content-type: application/json"
-H "Accept: application/json"
--user adam@atechmedia.com:my-api-key
-d '{"deployment":{ "parent_identifier":"7563d091-ca73-588e-cfe2- e4936f190145",
"start_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"end_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"mode" : "queue",
"copy_config_files" : 1,
"email_notify" : 1
}}' http://test.deployhq.com/projects/project/deployments/
This is how I am sending it via Ansible:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org:secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
The issue is that I am getting a 403 response back (access denied), so it is something to do with passing them the --user parameters. I have no issue at all sending the cURL request from the cli, so the user creds passed in --user are correct. DeployHQ can see from their logs that the json request looks correct but it not authenticated (obviously they cannot view the headers for security reasons).
It must be simple but I have spent all afternoon and tried many combinations of user: (including and user: and password: for the api key) - in the body: and out of the body: (as above). DeployHQ support say they use basic http_auth and so I have tried these combinations with the parameter:
force_basic_auth: yes
I have also tried passing the --user in the url. No luck at all.
Has anyone else done this?!
SOLVED...
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
force_basic_auth: yes
....
All on the same level.. Many thanks for comments making me go back to to password field.
curl ansible credentials
add a comment |
I am trying to use the Ansible uri module to communicate with DeployHQ's API.
Here is the example DeployHQ's documentation that I am trying to use from Ansible:
curl -H "Content-type: application/json"
-H "Accept: application/json"
--user adam@atechmedia.com:my-api-key
-d '{"deployment":{ "parent_identifier":"7563d091-ca73-588e-cfe2- e4936f190145",
"start_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"end_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"mode" : "queue",
"copy_config_files" : 1,
"email_notify" : 1
}}' http://test.deployhq.com/projects/project/deployments/
This is how I am sending it via Ansible:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org:secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
The issue is that I am getting a 403 response back (access denied), so it is something to do with passing them the --user parameters. I have no issue at all sending the cURL request from the cli, so the user creds passed in --user are correct. DeployHQ can see from their logs that the json request looks correct but it not authenticated (obviously they cannot view the headers for security reasons).
It must be simple but I have spent all afternoon and tried many combinations of user: (including and user: and password: for the api key) - in the body: and out of the body: (as above). DeployHQ support say they use basic http_auth and so I have tried these combinations with the parameter:
force_basic_auth: yes
I have also tried passing the --user in the url. No luck at all.
Has anyone else done this?!
SOLVED...
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
force_basic_auth: yes
....
All on the same level.. Many thanks for comments making me go back to to password field.
curl ansible credentials
Did you try withuserandpasswordoptions, instead of appending the secret key inuser? The documentation for ansible uri plugin listsuseras only the username, so I assume you need both.
– user
Jul 6 '18 at 16:56
1
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23
add a comment |
I am trying to use the Ansible uri module to communicate with DeployHQ's API.
Here is the example DeployHQ's documentation that I am trying to use from Ansible:
curl -H "Content-type: application/json"
-H "Accept: application/json"
--user adam@atechmedia.com:my-api-key
-d '{"deployment":{ "parent_identifier":"7563d091-ca73-588e-cfe2- e4936f190145",
"start_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"end_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"mode" : "queue",
"copy_config_files" : 1,
"email_notify" : 1
}}' http://test.deployhq.com/projects/project/deployments/
This is how I am sending it via Ansible:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org:secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
The issue is that I am getting a 403 response back (access denied), so it is something to do with passing them the --user parameters. I have no issue at all sending the cURL request from the cli, so the user creds passed in --user are correct. DeployHQ can see from their logs that the json request looks correct but it not authenticated (obviously they cannot view the headers for security reasons).
It must be simple but I have spent all afternoon and tried many combinations of user: (including and user: and password: for the api key) - in the body: and out of the body: (as above). DeployHQ support say they use basic http_auth and so I have tried these combinations with the parameter:
force_basic_auth: yes
I have also tried passing the --user in the url. No luck at all.
Has anyone else done this?!
SOLVED...
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
force_basic_auth: yes
....
All on the same level.. Many thanks for comments making me go back to to password field.
curl ansible credentials
I am trying to use the Ansible uri module to communicate with DeployHQ's API.
Here is the example DeployHQ's documentation that I am trying to use from Ansible:
curl -H "Content-type: application/json"
-H "Accept: application/json"
--user adam@atechmedia.com:my-api-key
-d '{"deployment":{ "parent_identifier":"7563d091-ca73-588e-cfe2- e4936f190145",
"start_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"end_revision" : "e84b5937f1132932dd56026db26a76f406555c19",
"mode" : "queue",
"copy_config_files" : 1,
"email_notify" : 1
}}' http://test.deployhq.com/projects/project/deployments/
This is how I am sending it via Ansible:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org:secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
The issue is that I am getting a 403 response back (access denied), so it is something to do with passing them the --user parameters. I have no issue at all sending the cURL request from the cli, so the user creds passed in --user are correct. DeployHQ can see from their logs that the json request looks correct but it not authenticated (obviously they cannot view the headers for security reasons).
It must be simple but I have spent all afternoon and tried many combinations of user: (including and user: and password: for the api key) - in the body: and out of the body: (as above). DeployHQ support say they use basic http_auth and so I have tried these combinations with the parameter:
force_basic_auth: yes
I have also tried passing the --user in the url. No luck at all.
Has anyone else done this?!
SOLVED...
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
force_basic_auth: yes
....
All on the same level.. Many thanks for comments making me go back to to password field.
curl ansible credentials
curl ansible credentials
edited Jul 6 '18 at 18:33
user4850288
asked Jul 6 '18 at 16:53
user4850288user4850288
265
265
Did you try withuserandpasswordoptions, instead of appending the secret key inuser? The documentation for ansible uri plugin listsuseras only the username, so I assume you need both.
– user
Jul 6 '18 at 16:56
1
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23
add a comment |
Did you try withuserandpasswordoptions, instead of appending the secret key inuser? The documentation for ansible uri plugin listsuseras only the username, so I assume you need both.
– user
Jul 6 '18 at 16:56
1
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23
Did you try with
user and password options, instead of appending the secret key in user? The documentation for ansible uri plugin lists user as only the username, so I assume you need both.– user
Jul 6 '18 at 16:56
Did you try with
user and password options, instead of appending the secret key in user? The documentation for ansible uri plugin lists user as only the username, so I assume you need both.– user
Jul 6 '18 at 16:56
1
1
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23
add a comment |
1 Answer
1
active
oldest
votes
According to the ansible uri documentation, there is also a password field. It also looks like user is supposed to be only the username. Did you try something like:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51214785%2fapi-call-using-ansible-uri-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the ansible uri documentation, there is also a password field. It also looks like user is supposed to be only the username. Did you try something like:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
add a comment |
According to the ansible uri documentation, there is also a password field. It also looks like user is supposed to be only the username. Did you try something like:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
add a comment |
According to the ansible uri documentation, there is also a password field. It also looks like user is supposed to be only the username. Did you try something like:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
According to the ansible uri documentation, there is also a password field. It also looks like user is supposed to be only the username. Did you try something like:
- uri:
url: https://cepr.deployhq.com/projects/cepr-live/servers
user: me@myemail.org
password: secret_api_key
body_format: json
method: GET
headers:
Content-Type: application/json
Accept: application/json
deployment:
parent_identifier: id
start_revision: my_start_rev
end_revision: my_end_rev
mode: queue
copy_config_files: 1
email_notify: 1
return_content: yes
answered Jul 6 '18 at 16:58
useruser
2,44422246
2,44422246
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
add a comment |
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
Yes - I have tried just about every combination of user: and user with password. It must be something about the basic http auth and passing in the user@myemail.com and the api key
– user4850288
Jul 6 '18 at 17:57
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51214785%2fapi-call-using-ansible-uri-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you try with
userandpasswordoptions, instead of appending the secret key inuser? The documentation for ansible uri plugin listsuseras only the username, so I assume you need both.– user
Jul 6 '18 at 16:56
1
Done it - and it was so simple in the end, it must have been one of the combinations I did not try, You do need the user: and password: elements, but you also need the the 'force_basic_auth: yes' straight afterwards....
– user4850288
Jul 6 '18 at 18:23