Put elements vertically from string list Jinja2 template - ansible-template

I am new in Ansible and recently using Jinja2 template for modifying deciphering rate data. I have data as below:
"msg":
"msg": [
" 10/13 17:00 37955454 (99.35%)",
" 10/13 16:00 95109950 (99.37%)",
" 10/13 15:00 97574440 (99.36%)",
" 10/13 14:00 98193064 (99.36%)",
" 10/13 13:00 95558001 (99.35%)",
]
I am looking for help to convert this data into
"msg": [
10/13 10/13 10/13 10/13 10/13
17:00 16:00 15:00 14:00 13:00
37955454 95109950 97574440 98193064 95558001
(99.35%) (99.37%) (99.36%) (99.36%) (99.35%)
]

Related

Using variable in jenkins file for robocopy command

I am writing a Jenkins pipeline script to copy files from the source to the destination folder. The only difference from lots of articles I already visited is that my source and destination paths are not fixed but constructed using variables. I have a very strange issue that the variable names are used instead of their value, have been trying since the whole day. My Jenkins script is below
pipeline
{
agent any
parameters
{
string(name: 'SPRINT_NUMBER', defaultValue: '', description: 'Sprint Number')
}
environment
{
DESTINATION_PATH=""
SOURCE_PATH=""
}
stages
{
stage('Copy')
{
steps
{
script
{
/* APPROACH-1*/
DESTINATION_PATH="C:\\Release\\" + "${env.SPRINT_NUMBER}" + "\\" + "${env.BUILD_NUMBER}" +"\\Destination"
SOURCE_PATH="C:\\Source\\bin"
echo "DESTINATION_PATH: ${DESTINATION_PATH}"
echo "DESTINATION_PATH: ${SOURCE_PATH}"
/* the below doesnt work, echo prints correct DESTINATION_PATH and SOURCE_PATH though*/
bat '(robocopy ${SOURCE_PATH} ${DESTINATION_PATH}) ^& IF %ERRORLEVEL% LEQ 1 exit 0)'
/* APPROACH-2*/
bat label: '', script: '''Set src="C:\\Source\\bin"
Set dest="C:\\Release\\${params.SPRINT_NUMBER}\\${BUILD_NUMBER}\\Destination"
/* the below doesnt work, the variable name used instead of values*/
robocopy %src% %dest%'''
}
}
}
}
}
The Console out put from Jenkins is
For first approach
7:00:58 -------------------------------------------------------------------------------
17:00:58 ROBOCOPY :: Robust File Copy for Windows
17:00:58 -------------------------------------------------------------------------------
17:00:58
17:00:58 Started : Tuesday, July 28, 2020 5:00:58 PM
17:00:58 Source : C:\Program Files (x86)\Jenkins\workspace\CopyFilesJob\${SOURCE_PATH}\
17:00:58 Dest : C:\Program Files (x86)\Jenkins\workspace\CopyFilesJob\${DESTINATION_PATH}\
17:00:58
17:00:58 Files : .
17:00:58
17:00:58 Options : . /DCOPY:DA /COPY:DAT /R:1000000 /W:30
For second approach
17:00:58 -------------------------------------------------------------------------------
17:00:58 ROBOCOPY :: Robust File Copy for Windows
17:00:58 -------------------------------------------------------------------------------
17:00:58
17:00:58 Started : Tuesday, July 28, 2020 5:00:58 PM
17:00:58 Source : C:\Source\bin\
17:00:58 Dest : C:\Release\${params.SPRINT_NUMBER}\${BUILD_NUMBER}\Destination\
17:00:58
17:00:58 Files : .
17:00:58
17:00:58 Options : . /DCOPY:DA /COPY:DAT /R:1000000 /W:30

Unable to deploy app on firebase using Google Cloud build ! Getting error "exec user process caused "no such file or directory"

Hi I am trying to automate task of deployment using Google Cloud build to trigger the build & deploy whenever code is pushed into master branch .
But I am getting error , in the step 2 of the build ( Deploy step )
"exec user process caused "no such file or directory"
Here are my Files :
cloudbuild.yaml
steps:
# Install node packages
- name: node:12.13.1
entrypoint: npm
args: ['install']
# Build productive files
- name: node:12.13.1
entrypoint: npm
args: [ 'run', 'build', '--prod' ]
# Deploy
- name: 'gcr.io/$PROJECT_ID/firebase'
args: ['deploy', '--project', 'dive-testing-268508', '--token', 'YYY']
Where YYY is repalced with token value ,
firebase.json
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
package.json
{
"name": "ocean-aifrontend",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
output path in angular.json
"outputPath": "dist",
I am unable to understand the root cause behind this !Please let me know if any further info is required for sorting this issue . Thanks
The source of this error might be due to the entrypoint for Docker in your firebase.bash file is set up for Windows, not Linux.
You may want to take a look at this issue and how it was resolved.

Proper .gitignore file for a Neos Flow project?

I recently created a new project using composer create-project --keep-vcs neos/flow-base-distribution ProjectName and I'm a bit confused by the .gitignore file it produces:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
It basically throws out almost every file from the VCS, including the entirety of the Packages/Application folder, where I assumed most of my code would go. So what gives? Why is the .gitignore file so broad?
I don't have previous experience in neos-flow but I installed it with the help of composer on two different computers with Ubuntu OS.
My .gitignore file output is same like your output both time.
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
The Original structure of my project is
. .. .editorconfig .git .github .gitignore Build Configuration Data Packages Readme.rst Web bin composer.json composer.lock flow flow.bat
When i remove all folders and files as declared in .gitignore then my project structure is like this
. .. .editorconfig .git .github .gitignore composer.json composer.lock
As you know, The purpose of the .gitignore file is to allow you to ignore files, such as editor backup files, build products or local configuration overrides that you never want to commit into a repository.
I think that neos-flow just need those files that are remaining after applying .gitignore.
Those are composer.json and composer.lock
The purpose of composer.json is that it shows the details about the project like name, description, license information.
And composer.lock shows all packages, and dependencies for the project, their name, detail and url for downloading the package.
The content of composer.json
{
"name": "neos/flow-base-distribution",
"description": "Flow Base Distribution",
"license": "MIT",
"support": {
"email": "hello#neos.io",
"slack": "http://slack.neos.io/",
"forum": "https://discuss.neos.io/",
"wiki": "https://discuss.neos.io/c/the-neos-project/project-documentation",
"issues": "https://github.com/neos/flow-development-collection/issues",
"docs": "https://flowframework.readthedocs.io/",
"source": "https://github.com/neos/flow-base-distribution"
},
"config": {
"vendor-dir": "Packages/Libraries",
"bin-dir": "bin"
},
"require": {
"neos/flow": "~6.0.0",
"neos/welcome": "~6.0.0"
},
"require-dev": {
"neos/kickstarter": "~6.0.0",
"neos/buildessentials": "~6.0.0",
"neos/behat": "dev-master",
"phpunit/phpunit": "~8.1",
"mikey179/vfsstream": "~1.6"
},
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
"replace": {
"typo3/flow-base-distribution": "self.version"
},
"suggest": {
"ext-pdo_sqlite": "For running functional tests out-of-the-box this is required"
},
"scripts": {
"post-update-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-install-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-package-update": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
"post-package-install": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall"
}
}
First 70 lines of composer.lock
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is #generated automatically"
],
"content-hash": "06d49a77babbafa5a03d726865e61dc3",
"packages": [
{
"name": "composer/ca-bundle",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"shasum": ""
},
"require": {
"ext-openssl": "*",
"ext-pcre": "*",
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\CaBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano#seld.be",
"homepage": "http://seld.be"
}
],
"description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
"keywords": [
"cabundle",
"cacert",
"certificate",
"ssl",
"tls"
],
"time": "2019-08-30T08:44:50+00:00"
}]}
The _readme key in composer.lock json shows the purpose of composer.lock
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is #generated automatically"
],
So in short your .gitignore is absolutely fine and accurate. I also install it on both my ubuntu computers and both are same.
There are two models of .gitignore under their repository:
https://github.com/neos/flow/blob/master/Resources/Private/Installer/Distribution/Defaults/.gitignore
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
https://github.com/neos/flow-development-distribution/blob/master/.gitignore
/Build/Behat/*
/Build/BuildEssentials
/Build/Reports
/Build/Resources
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.txt
/Upgrading.txt
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
As I am an avid Flow user, I can explain why the Packages/ directory is excluded:
As you can see in the composer.json, there is this section:
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
This tells composer to look for your own packages in the DistributionPackages/ directory. This is much cleaner than mixing own packages and dependencies in the Packages/ directory and also helps a bit with dependency management itself (since only the composer.json in your package directory needs to contain the package dependencies - i.e. no need to duplicate them in the root composer.json).
See https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setup and https://www.neos.io/blog/project-repository-best-practice.html for more info about that (this not only applies to Neos site packages, but every project specific package).
As for the other excluded files: Since those get created by composer install, those don't need to be tracked by git.
Exception: You often want to include the Web/ directory (but exclude non-specific contents like Web/_Resources/ or Web/index.php) i.e. for the favicons or other static files needed in the web root.

FIWARE Orion subscription creation failed

Trying to create subscription on FIWARE Orion to notify Cygnus instance. But no matter what I try or do I get failed as subscription status.
Main problem seem to be Cygnus URL I am using for notification, but Cygnus is up and running without any issues and this problem still persist.
FIWARE Orion version:
"orion" : {
"version" : "1.15.0-next",
"uptime" : "0 d, 0 h, 24 m, 24 s",
"git_hash" : "9cf2ea8243e4757a52c9019d197112abcf715dbe",
"compile_time" : "Mon Sep 24 08:22:30 UTC 2018",
"compiled_by" : "root",
"compiled_in" : "ea5d2e530912",
"release_date" : "Mon Sep 24 08:22:30 UTC 2018",
"doc" : "https://fiware-orion.readthedocs.org/en/master/"
}
FIWARE Cygnus version:
version 1.9.0_SNAPSHOT.887d615a9dfc2c09c99e511f8cefb148aa54809e
FIWARE Orion error log:
time=Thursday 27 Sep 13:33:09 2018.712Z | lvl=WARN | corr=N/A |
trans=1538055058-177-00000000002 | from=pending | srv=pending |
subsrv=pending | comp=Orion |
op=AlarmManager.cpp[328]:notificationError | msg=Raising alarm
NotificationError http://172.20.0.2:5050/notify: (curl_easy_perform
failed: Timeout was reached)
Subscription body:
{
"description": "A subscription to get info about Room entity",
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Room"
}
],
"condition": {
"attrs": [
]
}
},
"notification": {
"http": {
"url": "http://172.20.0.2:5050/notify"
},
"attrs": [
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
I found good amount of simmilar problems they all point out to url issues of Cygnus because it is run as docker container.
But you can see in logs and example that I use IP address of containers (not localhost etc), and issue is constant.
What did I miss here since there is no much to do with subscription creation and it looks very simple but still all subscription are getting back with failed as status and issue I describe above.
Thanks.
It seems to be a connectivity problem.
You mention you are using Docker and I understand that Orion and Cygnus run in different docker containers. Thus, probably there is some kind of connectivity problem between, the IP you are using in the subscription is not the right one or Cygnus container is not exposing port 5050 to others.

Why I am getting PowerShell Parsing Error?

I am new to PowerShell and I am trying to get a script to work to list my parallel ports. I took the PowerShell script from here:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ParallelPort")
For Each objItem in colItems
Wscript.Echo "Availability: " & objItem.Availability
For Each strCapability in objItem.Capabilities
Wscript.Echo "Capability: " & strCapability
Next
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Device ID: " & objItem.DeviceID
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "OS Auto Discovered: " & objItem.OSAutoDiscovered
Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
Next
After executing the script I am getting:
PS C:\> .\script.ps1
Unexpected token '_' in expression or statement.
At C:\script.ps1:4 char:44
+ Set objWMIService = GetObject("winmgmts:" _ <<<<
+ CategoryInfo : ParserError: (_:String) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
I even tried changing & by $ as I can see in this script which also doesn't work. Is a problem with my PowerShell or is the script which is causing the problem?
PS: I am using PowerShell v2.0 in Windows XP 32bit
Thank you in advance!
EDIT:
According to the answer so it isn't a PowerShell script but a vbscript. So my question now would be why this script doesn't work if it is indeed a PowerShell Script:
$strComputer = "."
$colItems = get-wmiobject -class "Win32_ParallelPort" -namespace "root\CIMV2" `
-computername $strComputer
foreach ($objItem in $colItems) {
write-host "Availability: " $objItem.Availability
write-host "Capabilities: " $objItem.Capabilities
write-host "Capability Descriptions: " $objItem.CapabilityDescriptions
write-host "Caption: " $objItem.Caption
write-host "Configuration Manager Error Code: " $objItem.ConfigManagerErrorCode
write-host "Configuration Manager User Configuration: " $objItem.ConfigManagerUserConfig
write-host "Creation Class Name: " $objItem.CreationClassName
write-host "Description: " $objItem.Description
write-host "Device ID: " $objItem.DeviceID
write-host "DMA Support: " $objItem.DMASupport
write-host "Error Cleared: " $objItem.ErrorCleared
write-host "Error Description: " $objItem.ErrorDescription
write-host "Installation Date: " $objItem.InstallDate
write-host "Last Error Code: " $objItem.LastErrorCode
write-host "Maximum Number Controlled: " $objItem.MaxNumberControlled
write-host "Name: " $objItem.Name
write-host "Operating System Auto-Discovered: " $objItem.OSAutoDiscovered
write-host "PNP DeviceID: " $objItem.PNPDeviceID
write-host "Powe rManagement Capabilities: " $objItem.PowerManagementCapabilities
write-host "Power Management Supported: " $objItem.PowerManagementSupported
write-host "ProtocolS upported: " $objItem.ProtocolSupported
write-host "Status: " $objItem.Status
write-host "Status Information: " $objItem.StatusInfo
write-host "System Creation Class Name: " $objItem.SystemCreationClassName
write-host "System Name: " $objItem.SystemName
write-host "Time Of Last Reset: " $objItem.TimeOfLastReset
write-host
}
I am getting this error:
Missing expression after unary operator '-'.
At C:\script.ps1:4 char:2
+ - <<<< computername $strComputer
+ CategoryInfo : ParserError: (-:String) [], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
In your revised script, there's a space after the backtick on line 3, so the continuation isn't being recognized. When you use the backtick to for a line continuation in PowerShell, it can't be followed by a whitespace character. Eliminate that space, or make it all one line:
$colItems = get-wmiobject -class "Win32_ParallelPort" -namespace "root\CIMV2" -computername $strComputer
Your example script is not PowerShell, it's vbscript.
PowerShell is much simpler, you would use something like:
Get-WmiObject Win32_ParallelPort

Resources