Error while copying war file from workstation to client node?` - copy

Hi I am using chef for deployment, I have created a war file on my chef workstation and copied it to my templates folder of cookbook
now I have written a simple recipe to copy it to my client here is the recipe
template "/opt/tomcat7/webapps/SampleProject.war" do
source "SampleProject.war"
end
Now if I run the recipe from my chef-workstation using knife ssh it is unable to copy the war file
knife ssh 'name:staging2.akosha.com' 'chef-client' -x root -P
but if I give some other file like *.txt it copies the file successfully.

I haven't seen a reference for that anywhere, but you shouldn't use the template resource for binaries - the same happened to me also. It seems that the erb-processing flips some bits.
Instead, use the cookbook_file resource, or better the remote_file, to avoid polluting your Chef server with large artifacts (which do not really belong there).

Related

Deploying config files to PLC

Is it possible include arbitrary files (in this case a .csv) from a TwinCAT project direct to the Boot directory of a PLC?
By using PATH_BOOTPATH in the file open/read FBs it is possible to load files from this directory in a convenient manner regardless of whether using a CE or Windows deployment, However deployment of files to this location seems to be the sticking point.
I know that a copy of the project code is included within the CurrentConfig<Project>.tpzip file, but this file is not easily accessible from code, or updateable.
I've found the 'Additional Files' section within the system configuration, but it makes little sense.
Adding a file from inside the project as a 'Relative' path doesn't seem to do anything
Adding a file from inside the project as an external path includes the file (via symbolic links?) in the 'CurrentConfig.tszip' file, which has the same issues as the .tpzip
Adding an external file as an external path again includes the file inside of the .tszip.
I'm willing to accept that this might not be possible, but it just feels odd that the PATH_BOOTPRJ and PATH_BOOTPATH roots are there and not accessing useful paths.
Deployment
To quote Beckhoff:
Deployment is used to set up commands that are to be executed during the installation and startup of an application.
The event types are essentially at what stage of the deployment process the command is performed, where the command can either be copying a file or execution of a script/program.
Haven't performed extensive testing but between absolute/relative pathing and execution this should solve nearly all issues with deployment configuration.

.NET Core - how does the 'dotnet publish' command work?

I have a solution with some projects targeting .NET Standard 2.0 and a console application project targeting .NET Core 2.1.
I set "myFolder" as the output folder.
Building from VisualĀ Studio, I get all DLL files in:
"myFolder\netstandard2.0"
"myFolder\netcoreapp2.1"
I get the same using the "dotnet build" command.
Now I need my console application's EXE file.
So I use the "dotnet publish -c Release -r win-x64 MySolution.sln" command.
Now I get this new directory, "myFolder\netcoreapp2.1\win-x64", where I find all DLL files and the console application's EXE file.
Not enough!
I find one directory more, "myFolder\netcoreapp2.1\win-x64\publish", where I find again all DLL files and the console application's EXE file.
Which meaning do they have? I read the command documentation, but I didn't find my answer.
Per the documentation
-o|--output <OUTPUT_DIRECTORY>
Specifies the path for the output directory. If not specified, it defaults to ./bin/[configuration]/[framework]/publish/ for a framework-dependent deployment or ./bin/[configuration]/[framework]/[runtime]/publish/ for a self-contained deployment.
dotnet publish -c Release -r win-x64 --output ./MyTargetFolder MySolution.sln
All you really need to understand to be able to successfully publish and deploy is that you need to dotnet publish and ensure that you have a Release configuration -c Release, as well as any other required options on the command line.
All of your files will be in the 'publish' subfolder, e.g. ./bin/Release/[framework that your solution is targeting]/publish. The files contained here are everything that is needed for a running instance of your application/service. The MySolution.dll is the entry point for your app/service, and will automatically link to all of the other dependencies and configuration stored in the publish folder.
To configure and deploy a running instance, you need to work out how to deploy all of those files to a server, and somehow configure something (e.g. a web server, runtime, service host ...) to call your MySolution.dll.
Note that in your dotnet publish you're specifying -r, which means that your application is targetted to run under 64 bit Windows, as opposed to a Linux distribution or OSĀ X (which makes it less portable, but it has the advantage of isolating your application from changes to an installed runtime on a server that you deploy it to.). That's why you're seeing an extra folder win-x64.
Also you're explicitly building from the solution configuration specified by your solution file MySolution.sln, which is probably the most reliable thing to do as this will ensure that any projects used as dependencies by your solution (which is a typical good practice) will be included in the build/publish.

Can I deduplicate content of zip files on Artifactory side?

I'm using JFrom Artifactory, which has deduplication feature - see documentation. Our deployment procedure is the following:
Create zip file with libraries: jars, dlls, etc. This is the same with war file or with fat jar.
During deployment: just extract content of zip file and do small initialization scripts.
As you understand, the most of content on these files is already on the Artifactory:
3rd party java dependencies are already on the same Artifactory
Previous installation has a lot of the same binaries
So, question: how can I ask Artifactory to unzip my archives on server side during upload and then transparent zip it back during download?
This solution will give major data deduplication for me, which gain the following advantages:
Saving disk space
Decreasing server IO
And I know, that there will be the following disadvantages:
Checksum of the zip package can be changed
CPU load can be increased during artifacts upload and download
I don't think this is doable transparently from the client side. However, if you are ready to change your clients, I can imagine:
On the upload / release front, use JFrog CLI and its --explode option for uploads.
The rationale for this flag is at https://github.com/JFrogDev/jfrog-cli-go/issues/5 and the feature is quickly described in https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-UploadingFiles
Instead of uploading simply your ZIP / WAR with any client or JFrog CLI like
jfrog rt u my.zip repo-release/test/0.5/my-0.5.zip
You would upload it while asking for it to be exploded on the target
jfrog rt u --explode my.zip repo-release/test/0.5/my-0.5.zip/thisisignored.zip
On the download side, use a User Plugin (only available with Pro instances though) to zip the directory content on the fly. There is an existing implementation at https://github.com/JFrogDev/artifactory-user-plugins/tree/master/download/downloadDirectoryContent that you can install on your Artifactory server.
Once this is set up, you should be able to retrieve your original zip with
curl -X GET -uadmin:password "http://localhost:8081/artifactory/repo-release/test/0.5/my-0.5.zip;downloadDirectory+=true" > my.zip

Tomcat 6 Eclipse root deployment

I have a Java web application running on Tomcat6 built with Eclipse. It has always been run in a subdirectory:
/webapps/appDIR
As a result, the URL is:
www.application.com/appDIR
I now want it to just be deployed to the top level. I rename the directory to ROOT and extract the WAR. Set the permissions, and it doesn't work. It goes to an infinite redirect of the error page, and then the page dies.
I can rename the the directory to anything else and it works. For example I could call it test, in which case the URL becomes:
www.application.com/test
.....works fine. I just can't use "ROOT", which would allow the wwww.application.com URL to work.
I did some searching, and decided it was related to the context.xml file. It is currently sitting in the /WEB-INF directory (wrong?), and it only contains an end tag of "" (more wrong?). I moved that file to the /META-INF directory, and it didn't work. I figured that maybe it couldn't be empty and I added the contents of the following link to it:
http://www.wellho.net/resources/ex.php4?item=a654/6_context.xml
And still no go.
Any ideas? For a little more background, I'm now deploying it to Amazon's Beanstalk whereas before it was self hosted. Beanstalk defaults to deploying to ROOT, and I didn't see a reason to fight them on it, whereas Eclipse feels differently.
You mentioned: "Beanstalk defaults to deploying to ROOT, and I didn't see a reason to fight them on it".
If you care to fight -
A hack to be sure, but to get our app to deploy under a subdirectory, we did the following with a beanstalk config file (.ebextensions)
commands:
# This modified the default beanstalk deploy script so that our WAR file sits in appropriate subdirectory.
fixdeployscript:
command: sed -i 's/webapps\/ROOT/webapps\/MyAppName/g' /opt/elasticbeanstalk/hooks/appdeploy/enact/03deploy.sh

Pack a Zend Framework app and deploy it on Zend Server

I created a small Zend Framework application from command prompt using Zend_Tool.
I deployed it in apache server htdocs folder and it is running fine.
Now I need to deploy it to Zend Server. For that i used a command zdpack pack appname.
While trying that i am getting lot of errors like
deployment.xml is missing
I created it in the app root folder.
Then i got
appnaama/data folder is missing error
I created a data folder.
Then
zend-scripts missing
error....
Please help me in deploying an applicaiton created from zf create project projname in Zend server and run it in the browser.
You need to come out of the directory when calling zdpack pack command. If you pack the file inside the project directory you get the "deployment.xml is missing" error.
Pass the following commands at the location where you are creating the
zpk file. For illustration, I will be doing it in the myapp folder of my desktop.
C:\Users\lura\Desktop\myapp> zdpack.exe create demoapp
Move into the directory using cd demoapp and list the directory. Copy your php codes into the data folder. The scripts folder and deployment.xml file can be left as it is. Next run the validate command when inside the directory.
C:\Users\lura\Desktop\myapp\demoapp> zdpack.exe validate --schema="C:\Program Files (x86)\Zend\ZendServer\share\deployment.xsd" deployment.xml
now you can move a folder back with the command cd .. and execute the following.
C:\Users\lura\Desktop\myapp>zdpack pack demoapp
That's it! The zpk file is created! A screenshot of my cmd.
This YouTube tutorial will help, if your still confused. To execute on Linux and for more info read this documentation from zend.
You are using zdpack command wrong!
Step 1: Open shell and ls or cd into the zend workspace.
Step 2: use "zdpack create <ProjectName>" command. It will create deployment.xml, data and script directories. Refresh project explorer you will see changes.
Step 3: Configure deployment.xml if needed.
Step 4: Use "zdpack pack <ProjectName>" command to create zpk file.
That's all.
I think you just pass incorrect path to the app.
Try following this scheme:
zdpack pack <path>/ProjectName
to generate required files.
Step 1: Create skeleton from the zend server zdpack command
#/usr/local/zend/bin/zdpack create <project-name>
It will create project skeleton.
Step 2: Configure deployment.xml if needed.After that check your Deployment.xml is valid.
# /usr/local/zend/bin/zdpack validate --schema="/usr/local/zend/share/deployment.xsd" deployment.xml
Step 3: Now create the zpk file for the aplication
# /usr/local/zend/bin/zdpack pack <project-name>