I want to launch a Job-Template via the AWX-API including some extra_vars, but every response I get has an empty extra_vars field. I already checked the documentation about it:
https://docs.ansible.com/ansible-tower/latest/html/userguide/job_templates.html#extra-variables
which states, that you have to set ask_variables_on_launch: true and/or have corresponding variables in a survey. My Request checks both of these conditions:
Request
POST: https://my.awx.host/api/v2/job_templates/7/launch/
Body
{
"can_start_without_user_input": false,
"passwords_needed_to_start": [],
"ask_scm_branch_on_launch": false,
"ask_variables_on_launch": true,
"ask_tags_on_launch": false,
"ask_diff_mode_on_launch": false,
"ask_skip_tags_on_launch": false,
"ask_job_type_on_launch": false,
"ask_limit_on_launch": false,
"ask_verbosity_on_launch": false,
"ask_inventory_on_launch": false,
"ask_credential_on_launch": false,
"survey_enabled": true,
"variables_needed_to_start": [
"application_server_name",
"server_location",
"application_server_type",
"ssh_keys"
],
"credential_needed_to_start": false,
"inventory_needed_to_start": false,
"job_template_data": {
"name": "template name ",
"id": 7,
"description": ""
},
"defaults": {
"extra_vars": {
"application_server_name": "some name",
"server_location": "some location",
"application_server_type": "some type",
"ssh_keys": [
{
"name": "key1"
},
{
"name": "key2"
},
{
"name": "key3"
}
]
},
"diff_mode": false,
"limit": "",
"job_tags": "",
"skip_tags": "",
"job_type": "run",
"verbosity": 2,
"inventory": {
"name": "AWX Tower (Localhost) my.awx.host",
"id": 1
},
"credentials": [
{
...
}
],
"scm_branch": ""
}}
Response
{
"variables_needed_to_start": [
"'application_server_name' value missing",
"'server_location' value missing",
"'application_server_type' value missing",
"'ssh_keys' value missing"
]}
I'm kinda confused, since I did everything according to the documentation. The values needed by the survey are even in the same Request Body. Could someone help with this problem?
I'm using AWX 16.0.0
Ansible Version 2.9.15
Thanks
So actually, you have to send just the extra vars, not the whole response + vars you get from the AWX. I don't know, if I didn't see this in the docs, or if it's just plain obvious and I did't get it.
ask_variables_on_launch still has to be true!
Related
When attempting to use the method PublicClientApplication.acquireTokenSilently() I am getting the error "Token not found in cache". It looks like it is failing to be stored. Our AuthenticationResult looks like this:
{
"accessToken": "...",
"expiresOn": 1671035322,
"extExpiresOn": 0,
"refreshOn": 0,
"idToken": "...",
"idTokenObject": {},
"accountCacheEntity": {
"homeAccountId": "...",
"environment": "URL",
"name": "username",
"authorityType": "ADFS"
},
"account": {
"value": {
"homeAccountId": "...",
"environment": "URL"
}
},
"tenantProfile": {},
"environment": "env",
"expiresOnDate": {
"value": "Dec 14, 2022 11:28:42 AM"
},
"scopes": "openid"
}
I see that the account is missing the "name" field and I am wondering if that is part of it. I'm not quite sure how to work around this issue.
I've looked at the source and it appears that result.account().username() is returning null. I'm not sure if there is a way to use the value in accountCacheEntity.
I have a page in contentful which I retrieve content to my react app with graphql.
In this page, a link a content model called Person which is like that:
{
"name": "Person",
"description": "",
"displayField": "name",
"fields": [
{
"id": "name",
"name": "Name",
"type": "Symbol",
"localized": false,
"required": true,
"validations": [],
"disabled": false,
"omitted": false
},
{
"id": "profilePic",
"name": "profile pic",
"type": "Link",
"localized": false,
"required": true,
"validations": [],
"disabled": false,
"omitted": false,
"linkType": "Asset"
},
{
"id": "socialLinks",
"name": "social links",
"type": "Array",
"localized": false,
"required": false,
"validations": [],
"disabled": false,
"omitted": false,
"items": {
"type": "Link",
"validations": [
{
"linkContentType": [
"socialLink"
]
}
],
"linkType": "Entry"
}
}
ProfilePic is another content model which include name and picUrl.
SocialLinks is an array of socialLink content model which contain name and link
I can retrieve without problem my profilePic name or picUrl but I cannot get the socialLinks.
I have read the contentful documentation about one-to-many but is not clear to me how to apply to my case: https://www.contentful.com/developers/docs/references/graphql/#/reference/schema-generation/one-to-many-multi-type-relationships
My query:
...rest of the query..
founder{
name,
profilePic{
url,
title
},
socialLinksCollection {
items {
name,
link
}
}
},
... rest of the query...
Can somoene help me understand why it doesn't work as a normal collection?
Should I maybe use this concept of linkedFrom? But how exactly?
I had to add (limit: 1) to my socialLinksCollections otehrwise there were too many calls and wasn't possible to get the data back.
Thanks to #stefan judis for the suggestion where to look out for the errors.
I have decoded a response using beanshell script and saved it in a XML file.
Beanshell Post Processor script
import org.apache.commons.io.FileUtils;
import org.apache.commons.codec.binary.Base64;
String response= vars.get("data");
vars.put("response",new String(Base64.decodeBase64(response)));
Output = vars.get("response");
f = new FileOutputStream("E:/JMeter/apache-jmeter-3.1/bin/response.xml");
p = new PrintStream(f);
this.interpreter.setOut(p);
print(Output);
f.close();
Response
{
"Username": "raghuram.k#cafyne.com",
"UserCreateDate": "2017-02-23T04:02:59.123Z",
"UserLastModifiedDate": "2017-02-23T04:04:50.695Z",
"Enabled": true,
"UserStatus": "CONFIRMED",
"sub": "50e0dff7-0342-40f1-b793-68de404d95c4",
"_app": "586cc7cc851dc874ac59f001",
"email_verified": "true",
"_org": "58adbaf2ffc4de735f1fbe28",
"name": "Raghu Ram kota",
"_groups": [
{
"_id": "58adbaf2ffc4de735f1fbe29",
"name": "default",
"slug": "default",
"description": "Default Group",
"id": "58adbaf2ffc4de735f1fbe29"
}
],
"_roles": [
{
"_id": "58adbaf2ffc4de735f1fbe2a",
"name": "ADMIN",
"slug": "admin",
"description": "ADMIN Role",
"id": "58adbaf2ffc4de735f1fbe2a"
}
],
"permissions": {
"listen": {
"DELETE": false,
"READ": true,
"UPDATE": false,
"CREATE": false
},
"profile": {
"STOPLISTEN": true,
"STARTLISTEN": true,
"AUTHORIZE": true,
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"post": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"group": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
},
"user": {
"DELETE": true,
"READ": true,
"UPDATE": true,
"CREATE": true
}
},
"email": "raghuram.k#cafyne.com",
"meta": {},
"isAdmin": "false",
"iat": 1487919175,
"exp": 1487926375
}
Now I need to send only the _org value, Which is highlighted, as input to another http request. Any suggestions?
I would recommend switching to JSR223 PostProcessor and Groovy language as:
Groovy has built-in Base64 encoding/decoding support
Groovy has built-in JSON support
Groovy is more Java-compliant
Groovy performs much better than Beanshell
So you can get your _org value as simple as:
def response = vars.get("data")
def decodedResponse = new String(response.decodeBase64())
def json = new groovy.json.JsonSlurper().parseText(decodedResponse)
log.info(json._org)
See Groovy Is the New Black article for more comprehensive information.
I want to change via the XCode Bots API the scheme name of a bot. A request like curl -XPATCH -H 'Content-Type: application/json' -H 'x-xcsclientversion: 8' https://localhost:20343/api/bots/botid123 -d '{"name": "myawesomebot2"}' to change the bot name works. But if I try to change the configuration object with a request body like '{"configuration": {"schemeName": "scheme2"}}' it fails.
How can the scheme name be modified?
I finally got this solved and want to note the pieces necessary to make this work and how I found it.
First, as you already noticed, is the need for -H "x-xcsclientversion: #" (note, 6 worked for me, as discovered through a check of Apple's Javascript that receives the PATCH request)
Second, after watching Xcode Server update a bot through Charles, it was seen that the URL needs the following parameter added, ?overwriteBlueprint=true
Third, it seems that the JSON data, at the topmost level as name:, also requires requiresUpgrade=false and type=1 (I found the tool jq to be invaluable)
Fourth, changes to the sourceBlueprint requires configuration.sourceControlBlueprint.DVTSourceControlWorkspaceBlueprintIdentifierKey to receive a new UUID. Easily generated in bash by uuidgen command.
Fifth, a mostly-full bot description must be sent. I grabbed the bot's JSON definition through Apple's API, then modified it using jq (see above), deleting out unnecessary key/value pairs so as to match Xcode Server's own API calls. The necessary key/value pairs appear to be:
name
type
requiresUpgrade
configuration (modify as necessary, but a full configuration must be sent)
group (leave as-is, but send it back through)
Sixth, backslash-escape all forward-slashes in the JSON payload. I've done this in bash with ESCAPED_JSON=${BOT_CONFIG_JSON//\//\\\/} and I send -d "$ESCAPED_JSON" in the curl command.
As such, the full curl command I'm using becomes:
curl -k --request PATCH -H "Content-Type: application/json" -H "x-xcsclientversion: 6" -d "$ESCAPED_JSON" https://<username>:<password>#<your_server_address>:20343/api/bots/<your_bot_id>?overwriteBlueprint=true
And a full JSON definition (remember, it must have forward slashes escaped before sending) looks like this
<!-- language: lang-json -->
"requiresUpgrade": false,
"configuration": {
"triggers": [
{
"phase": 1,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github Pending",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": true,
"onWarnings": true,
"onFailingTests": true
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Upload to Beta",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
},
{
"phase": 2,
"scriptBody": "<REDACTED>",
"type": 1,
"name": "Update github status",
"conditions": {
"status": 2,
"onSuccess": true,
"onAnalyzerWarnings": true,
"onBuildErrors": false,
"onWarnings": true,
"onFailingTests": false
}
}
],
"performsUpgradeIntegration": true,
"disableAppThinning": true,
"deviceSpecification": {
"filters": [
{
"platform": {
"_id": "3c884e2499df662057e8c64580003419",
"displayName": "iOS",
"_rev": "8-51c114fcfc83ea5f36df66f119b34ec8",
"simulatorIdentifier": "com.apple.platform.iphonesimulator",
"identifier": "com.apple.platform.iphoneos",
"buildNumber": "14C89",
"version": "10.2"
},
"filterType": 3,
"architectureType": 0
}
],
"deviceIdentifiers": [
"6d928bd891b83b4b8592aedb42001a97",
"6d928bd891b83b4b8592aedb4200776c",
"fa737f03db7b6c04d4c7f9507100700f"
]
},
"periodicScheduleInterval": 0,
"schemeName": "<REDACTED>",
"codeCoveragePreference": 2,
"performsTestAction": true,
"scheduleType": 3,
"performsArchiveAction": true,
"builtFromClean": 2,
"buildConfiguration": "Release",
"performsAnalyzeAction": true,
"sourceControlBlueprint": {
"DVTSourceControlWorkspaceBlueprintLocationsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlLockedRevisionLocation",
"DVTSourceControlLocationRevisionKey": "9d38dc7507f0f6ac17072d721893f0021c5282ed"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlBranchIdentifierKey": "<THE BRANCH TO WATCH>",
"DVTSourceControlBranchOptionsKey": 4,
"DVTSourceControlWorkspaceBlueprintLocationTypeKey": "DVTSourceControlBranch"
}
},
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey": {},
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationStrategiesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
},
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": {
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryAuthenticationTypeKey": "DVTSourceControlAuthenticationStrategy"
}
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": 0,
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey": "<GENERATE A NEW UUID FOR THIS!!!>",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey": {
"A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1": "<REDACTED PATH 1>",
"51DBFAD1848AC646B864BBBEDC625B8BAB305A76": "<REDACTED PATH 2>"
},
"DVTSourceControlWorkspaceBlueprintNameKey": "Cool Blueprint",
"DVTSourceControlWorkspaceBlueprintVersion": 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey": "<REDACTED>.xcworkspace",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey": [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "git#github.com:<REDACTED REPO 1>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "A2739AD29C3BCDF8619D0305ACFDD0C22AEBDDB1"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey": "git#github.com:<REDACTED REPO 2>",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey": "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey": "51DBFAD1848AC646B864BBBEDC625B8BAB305A76"
}
]
},
"exportsProductFromArchive": true,
"weeklyScheduleDay": 0,
"minutesAfterHourToIntegrate": 0,
"testingDestinationType": 0,
"hourOfIntegration": 0,
"testingDeviceIDs": []
},
"group": {
"name": "41A62776-A72E-44C0-BFF0-D91F699BBA6A"
},
"type": 1,
"name": "My Cool Integration Bot"
I hope this helps.
I'm getting a JSON response back from an API, however the response has several key parameters all called 'jacket' with different values. I am able to parse out the first key but I don't get the rest of the values. Here is some of the code, I might be approaching this the wrong way:
parsed_list = JSON.parse(get_response.body)
orig = parsed_list["_links"]["stuff"]["orig"]
serv = parsed_list["_links"]["stuff"]["serv"]
puts orig.first["jacket"]
puts serv.first["jacket"]
=> 123456789
=> 987654321
This is what the JSON response looks like before I parse it out and set it "parsed_list"
"_links": {
"self": {
"href": "url"
},
"stuff": {
"href": "url",
"orig": [
{
"jacket": "123456789",
"Id": "x",
"selected": true,
}
],
"serv": [
{
"jacket": "987654321",
"Id": "xx",
"selected": false,
},
{
"jacket": "0000000001",
"Id": "xx",
"selected": false,
},
{
"jacket": "1111111110",
"Id": "xx",
"selected": false,
}
]
}
}
}
I need to be able to extract all of the "jacket" values.
The data's right there, you just need to get it:
serv.collect do |entry|
entry['jacket']
end