I want to use this os version and vcenter variables and append it to the task's short description field while task is generated.
I need to know where to code, while catalog task generation for this requirement.
Any help is appreciated........
Sounds like you guys should hire a ServiceNow developer. :-P
I assume your catalog task is generated via a workflow? If so, you'll have to go into the workflow using the workflow editor, check it out using the hamburger menu at the top-left, double-click the activity (box) that generates the task, and there will be a script field.
In the script field, enter the following at the bottom of the script:
task.short_description = task.short_description + ' - VAR1: ' + current.variables.FIRST_VARIABLE_NAME + ' - VAR2: ' + current.variables.SECOND_VARIABLE_NAME;
Replace "VAR1" and "VAR2" with whatever you want them to say (like if the variable is "printer", enter "printer:" instead of "VAR1:").
Also, replace "FIRST_VARIABLE_NAME" and "SECOND_VARIABLE_NAME" with the two variable names you wanted to use.
This will result in the following format for the short description:
ORIGINAL SHORT DESCRIPTION - VAR1: VAR1_VALUE - VAR2: VAR2_VALUE
Related
Long story short -
Task 1:
Through URI module I am querying Website to obtain json data. Output is saved to variable.
Task 2:
Json_search is used to filter data.
But result value comes with square brackets which I need to get rid off as it needs to be inserted into url address.
I am using not elegant replace module twice to solve this problem. This works but I more than sure you can engage regex_replace (or json_query in more intelligent way) to achieve same result.
Expected output: https://site1/api/host/1
Received output before using replace 2x:
https://site1/api/host/[1]
Snippet from playbook:
…
- name: display url
debug:
msg: {{ json_output_var.json|json_search('result[].id')|replace('[','')|replace(']','')
I need to collect some information during run of ansible and print this information in the end.
I've tried to define empty list variable in role. I added in playbook handler which add new value to list ant print value of this variable in the end of playbook.
set_fact:
manual_tasks: "{{ manual_tasks + ['restart apache'] }}"
I miss that set_fact host related. So this solution stop working as soon as I start using different hosts. Delegate_to is not solve problem as well. Is there way to make this list global? Or any other solution exist?
Q: Add new value to list and print it at the end of the playbook. Is there way to make this list global?
A: No. It is not. "Global scope is set by config, environment variables and the command line." A host can't set_fact in the play or global scope.
You might want to take a look at ansible-runner. See Sending Runner Status and Events to External Systems.
On Ansible you can use register: some_var in order to save information about executed task but it seems that somehow I am not able to find the list of attributes documented anywhere.
I know about some of them, but I do want a full list as I is really annoying not to have documentation.
changed – set to boolean true if something happened (useful to tell when a task has done something on a remote machine).
stderr – contains stringy output from stderr
stdout – contains stringy output from stdout
stdout_lines – contains a list of lines (i.e. stdout split on \n).
Example, how do I know if the previous task failed?
There is no comprehensive list as each module returns its own list of variables.
There are common return values, which describe what a module (should) return as a minimum.
Some modules such as shell, are kind enough to list out the return values they provide in the docs.
I agree it would be quite nice to have a comprehensive cheatsheet listing the modules and return values. As it is, we're stuck with trolling through the python code for each module.
As an example, in the case of shell (which uses command under the covers), the return values are:
module.exit_json(
cmd = args,
stdout = out.rstrip("\r\n"),
stderr = err.rstrip("\r\n"),
rc = rc,
start = str(startd),
end = str(endd),
delta = str(delta),
changed = True,
warnings = warnings
)
I can't find an official list of the attribute of a register variable either. But I noticed a fact.
Refer to the explanation of register variable in chapter Loop. Do you notice what I noticed?
Do you see the "results" part in the Json output in this page? Each key that is present in the "results" part should be the whole attributes of a register variable.
And actually you can show the list of attributes of a register variable by yourself.
See the registered variable section in chapter Variable. There is a statement saying: Use of -v when executing playbooks will show possible values for the results.
Refer below url for register module:
http://docs.ansible.com/ansible/playbooks_variables.html#registered-variables
Also if a any task fails, it will fail the whole ansible playbook and exit. to ignore that and continue we need to use below step under that task
ignore_errors: True
To debug the playbook we are executing, we should pass "-v" to debug.
I'm trying to add some logic to one of our TFS build definition's build label field.
Currently the settings look like this:
Note the custom fields Major Version Number and Previous Major Release Date. I want to modify the Build Number Format field so that the end result will be something like:
<BuildDefinitionName> <Major Version Number>.<# Days since Previous Major Release Date [4 Digits]>.<Revision Number>
so an example output would be:
DebugBuild 6.0.0012.1
Where 0012 would mean 12 days.
How can I accomplish this? I'm having trouble understanding where these $(Var) fields are declared as they seem to be separate from the Build process template variables and arguments while the Major Version Number and Previous Major Release Date arguments I've declared do exist in the build process template and are assigned to arguments MajorVersionNumber and PreviousMajorReleaseDate.
What I have done is customise the TFS build workflow and add a custom Code Activity before the "Update Build Number" step.
This code activity takes in the BuildNumberFormat variable, replaces any of my custom tokens and passes out a result to my own localBuildNumberFormat variable. I then pass my localBuildNumberFormat to the "Update Build Number" activity.
So the process is something like:
BuildNumberFormat = $(CustomToken)_$(BuildDefinitionName)_$(Rev:.r)
Input to Custom Activity = $(CustomToken)_$(BuildDefinitionName)_$(Rev:.r)
Output from Custom Activity = DavesBuild_$(BuildDefinitionName)_$(Rev:.r)
Input to TFS Build Activity = DavesBuild_$(BuildDefinitionName)_$(Rev:.r)
You are essentially replacing all the tokens TFS cannot understand before passing it to TFS.
How you get the values for your Custom Token is up to you, you can pass them as arguments from the build definition/request, or look them up in the Code Activity (I do both in mine).
I am building a report which shows a list of users that are out of compliance due to not meeting a training deadline.
The queries that show and filter the data have been built and I have verified the correct information is showing in my list.
I now want to add some "action items" to the grid. The first item I am working on is a "Hyperlink Button" that will launch an email to the out-of-compliance user. The email should be addressed to this user, have a hard coded subject, and contain a body that has hard coded text with some data points from the query.
The "List Column Body" for the button column has its "Source Type" property set to "Report Expression"
Expression:
'mailto:'+ [ExceptionsByOrgQuery].[Email] + '?subject=Compliance%20Exception&body=Hello%20' + [ExceptionsByOrgQuery].[Full Name - First Last] + '%2C%0D%0A%0D%0AYou%20are%20overdue%20for%20training.%20%20Please%20complete%20the%20following%20training%20as%20soon%20as%20possible.%0D%0ATraining%20course%3A%20' + [ExceptionsByOrgQuery].[Activity Name] + '%0D%0ADue%20Date%3A%20' + [ExceptionsByOrgQuery].[Date]
All the variables that are used to build the link are in the query and should be matching up to the items for that row, correct?
For some reason I am getting an error when trying to validate this report.
The error I receive is:
RSV-VAL-0032 The following expression is not valid:...expression here... If the item exists in a query but is not referenced in the layout, add it to a property list. CRX-API-0005 An error ocurred at or near the position '11'. The variable named 'ExceptionsByOrgQuery].[Email]' is invalid.
I'm more unsure what the first part of the error means. The email variable is not shown in the grid, but it is part of the query. I can add it to the grid and verify that it is in the query, but I do not want that value to display in the report (nor do I want the variable [Full Name - First Last] to be displayed; it's just for the greeting in the email).
ADDITIONAL INFORMATION:
The List is populating from a query called [ReportQuery]
It contains the following data items.
[Name] <- [Compliance].[Employee].[Last Name] + ', ' +[Compliance].[Employee].[First Name]
[Organization] <- set([Dimensional View].[Organization].[Organizations] -> ?org?)
[Registration Status] <- [Compliance].[Fact Organization Due Exception].[Registration Status]
[Title] <- [Compliance].[Employee].[Title]
[Activity Name] <- [Compliance].[Activity].[Activity Name]
[Due Date] <- [Compliance].[Time].[Date_US]
[Email] <- [Compliance].[Employee].[Email]
[Name - First Last] <- [Compliance].[Employee].[First Name] + ' ' +[Compliance].[Employee].[Last Name]
(the first item is the label and the second portion is expression that is used to make the data item)
EDIT 1 (from melee's suggestions):
I've attempted the method you describe, but am now seeing this error: RSV-VAL-0032 The following expression is not valid: ''. If the item exists in a query but is not referenced in the layout, add it to a property list. CRX-API-0005 An error ocurred at or near the position '21'. The variable named '[ReportQuery].[Email]' is invalid.
I did a query regarding this error and saw that that the List object needed to have the properties that I used in the mailto in a "Properties" property. Defining this property allowed me to select items from the query. I did this with mailto, but it appears to be not matching up values to the correct row; ie. I've set the subject argument on the mailto to be the user's name ([ReportQuery].[Name]) and it doesn't match up with what is shown on the row in the table.
Ok, so you're going to need to follow these steps to get this to work properly - your syntax, concatenation, and everything else looks great - just a little tweaking of the process and you'll be good to go.
Drag an HTML item into a list report.
Select it - under the properties pane, change "Source Type" to "Report Expression" (defaults to Text, which is of no use to us right now)
Double click the HTML item and create the mailto anchor You can use your code sample, but make sure it is validating correctly before closing. it should, at its simplest, look something like: '<a href="mailto' + [Data Item] + '">' - important; do not close the anchor tag at this point.
Unlock the report (padlock on the top)
Add another HTML item to the cell (it will look like there's two HTML items in the same column) and set it to "Report Expression"
Double click the HTML item and add static text/close the tag. For example: Email Me</a>
Run the report and you should have links that you can click (tested as working on 8.4.1)