using jenkins to build RPM packages - installation

I want to use Jenkins for creating RPM packages to deploy code and scripts onto a Linux redhat machine(s)
So the applications are a mix of technologies (no compiling needed) i just need to package up the applications deploy them to the correct location restart apache
Would anybody have some instructions on how to do these steps for a total Newbie:
Some questions:
Do i need to install jenkins on a local linux machine if im going to be creating RPM's that will be deployed on to linux redhat machine (i was hoping to install jenkins on windows)
Does anybody have a example of creating a package out of a local folder (no source control for the moment)
I want to just specify the directory of where to take the code from and specify where to deploy the code to on a machine the rpm is installed on
On the destination machine i want to run something like
yum -install mypackage-version12.rpm
and it will install the code/scripts to the specified directory and restart apache
i need an example of this also.
Thanks

You can install Jenkins on a different machine, but you generally must have a Jenkins "node", "slave", "agent" installed on a machine that can generate RPM packages.
Running each step of the RPM package setup is putting all the steps to build within Jenkins. It works much better if you extend your build system to build the RPM, and have Jenkins do what it does best, manage the build (schedule, etc), not micro-manage the build (do the steps).
Depending on what you currently have as your build system, this might include ant directives to setup the rpm build tree, copy in the .spec file, and a executable call to rpmbuild.
Jenkins can easily call a post-build task to do this, or you might want to configure a mini "fake" project that does the update, depending on tastes.
As an aside, for a yum command to work without using the --localinstall option, you will need to have a web server set up, the new RPM copied to the right folder on the web server, and the indexing files rebuilt (repobuild is the script to do so, if I recall correctly).
On the client machine (where the package will be installed), you will need to have a yum configuration that directs the client machine to include the web server as one of the known yum repositories.

Why not use an Docker images to build the RPM inside it though a dedicated stage ?
Your code needs to provide /rpm/SPEC files and inside the Docker (Jenkins) you can have a Jenkinsfile like :
mkdir -p ./rpm/BUILD && cd ./rpm/ && for f in ./SPECS/*; do rpmbuild --define \"_topdir \$(pwd)/\" --define \"_builddir \$(pwd)/BUILD\" -bb \$f;
And you are done.

Related

Windows Package Creation with Ansible for Chocolatey

I'm new to Ansible and I'm trying to create a package to deploy to a Windows client running Chocolatey. I have all the winrm connections working between my ansible server and my windows client, but I am struggling to understand how to define and create packages.
As an example:
I want to install Notepad++ on the Windows client. I do not want it to connect to the internet to download the installer executable. Instead, I want the ansible server to push the exe to the client, then have the client execute it locally.
Can anyone explain and/or provide an example of a playbook to handle this? I know this is more easily achievable on windows via other products like SCCM, but for these purposes ansible is required.
The ansible playbook call you would look to make would look like such:
- name: Install notepadplusplus.install
win_chocolatey:
name: notepadplusplus.install
version: '8.4.5'
source: https:/YourInternalNuGetV2Repo
state: present
You would look to host the Chococlatey package on an internal NuGet V2 Repository
I think the part here that's missing is that you don't have a packages repository for Chocolatey to pull from. If you want to deploy a package with Chocolatey, it needs to get it from somewhere; the Ansible playbooks don't allow you to create packages directly and push them to machines, they mostly just allow you to setup Chocolatey and run Chocolatey commands.
If you want to build a Chocolatey package directly on the Ansible server, the Ansible modules for Chocolatey specifically don't have that functionality built in. You could potentially use other Ansible modules to construct the necessary script and zip files for the Chocolatey package, bundle in a targeted installer .exe, and upload it to the client. Not sure exactly how you'd do that, Ansible is generally for the deployment itelf moreso than packaging things for deployment.
Then, you could have the client instructed to install it by first adding the local folder that the package was uploaded to as a Chocolatey source:
win_chocolatey_source:
name: local
state: present
source: C:\\packages_folder
win_chocolatey:
name: package_name
source: local
state: latest
Instead, I want the ansible server to push the exe to the client, then have the client execute it locally.
If that is all you want then you don't need Chocolatey. Use win_copy to copy the EXE over from the server to the client and use something like win_command to execute it.
There are some caveats to it. You will need the command line arguments to make it run silently and headless. You'll need to test it all as some installers return immediately (and so control would return immediately to your playbook) even though they are still installing.
If you need to use Chocolatey then the other answers here are what you are looking for.

How to run RediSearch module with Redis on WSL (Windows Subsystem for Linux)

I followed the steps on https://redislabs.com/blog/redis-on-windows-10/ and have installed Ubuntu 18.04 and am successfully running Redis v4.09 on Windows. But, when following the steps on https://oss.redislabs.com/redisearch/Quick_Start/, I have some issues.
In the download and running binaries section, I don't understand what I'm supposed to replace /path/to/module/src/redisearch.so with. I've downloaded RediSearch for Ubuntu 18.04 and I've moved the files to a folder named RediSearch within my Downloads folder. Could someone help me with the pathing considering I'm using Ubuntu on Windows? I've also tried it with Building and Running with Source section but that just runs into an error every time I run make:
*** No rule to make target 'build'. Stop.
How can I run the module with Redis?
With WSL, you have access to C: through /mnt/c/ from Linux.
So, if you really want to have redisearch on a folder in Downloads you need to use something like:
/mnt/c/Users/<yourUser>/Downloads/yourFolder/src/redisearch.so
However, you probably should use a folder within Linux instead. You can use wget to download from Linux.

package Vagrant/Chef build with ALL dependancies

Current setup:
I have a project that builds with Vagrant/Chef (bunch of other tools, docker, bundler etc in play as well but this is the focus) Target is only Ubuntu 14.04 64 bit.
1) Vagrant sets up a ubuntu VM runs Chef with Berkshelf and all the other Ruby build goodies.
2) Chef runs through all the cookbooks:
presumably download any missing dependencies via aptitude, install packages via dpkg
pull/build source from git repos
initialize databases, probably set permissions and create files etc
There are some tools such as https://github.com/phusion/traveling-ruby that claim to effectively "freeze" a ruby application so you can ship it with an interpreter and all the dependencies/gems. This would be fine for a static application if not the last bit: running through cookbooks is actually an important step to deploying the application.
The deploy target will have no or limited bandwidth, is it possible to package a Chef build to locally contain all dependencies so that no remote download is necessary?
My idea so far is to run a clean build and make a copy of the chef cache folder and aptitude cache.

Installing MULE ESB mule-standalone-3.3.1

Can some guide me .. for installing Mule ESB(mule-standalone-3.3.1) in Ubuntu . I am unable to find any documentation for installing. i want to automate it through Chef.
It's can be as simple as downloading and unpacking the archive file from: http://dist.codehaus.org/mule/distributions/mule-standalone-3.3.1.zip
Note: You need jdk 6/7 installed first.
Here's a chef cookbook that does this: https://github.com/ryandcarter/mule-cookbook
And here's a Vagrant script for running the mule cookbook on ubuntu etc: https://github.com/ryandcarter/vagrant-mule
It is very simple.
Download and unpacking the archive file from: http://dist.codehaus.org/mule/distributions/mule-standalone-3.3.1.zip or whatever version you want to install.
put this unpack file to anywhere where you want like /opt/ or /usr/local/
put you mule application inside apps folder.
& go to bin directory and run ./mule start command. Now mule server is running. You can also check mule log inside log folder mule.log file
This is an old question, but in case there are others who are looking.
You want to install Mule as a Ubuntu Service, so that it restarts when The server restarts. There are a couple of basic steps to this
I detailed out instructions and installation files at my github repository
https://github.com/jamesontriplett/mule_linux_service_install
Steps in general:
Install a startup script in /etc/init.d
Install a startup parameter file in /etc/mule
Customize parameters in the wrapper.conf file in /conf/wrapper.conf
Install the license file onto the server if using enterprise
Add the startup script to the run levels.
To test, you want to reboot the linux service to make sure that it will come back after a reboot. If it doesn't you have a reliability issue.

Running multiple TeamCity Agents on the same computer?

We have several build machines, each running a single TeamCity build agent. Each machine is very strong, and we'd like to run several build agents on the same machine.
Is this possible, without using virtualization? Are there quality alternatives to TeamCity that support this?
Yes, it's possible:
Several agents can be installed on a single machine. They function as separate agents and TeamCity works with them as different agents, not utilizing the fact that they share the same machine.
After installing one agent you can install additional one, providing the following conditions are met:
the agents are installed in the separate directories
they have distinctive work and temp directories
buildAgent.properties is configured to have different values for name and ownPort properties
Make sure, there are no build configurations that have absolute checkout directory specified (alternatively, make sure such build configurations have "clean checkout" option enabled and they cannot be run in parallel).
Under Windows, to install additional agents as services, modify [agent dir]\launcher\conf\wrapper.conf
to change the properties to have distinct name within the computer:
wrapper.console.title
wrapper.ntservice.name
wrapper.ntservice.displayname
wrapper.ntservice.description
You could also take a look at this blog post for Step-by-step guide
http://handcraftsman.wordpress.com/2010/07/20/multiple-teamcity-build-agents-on-one-server/
The top answer is the correct method, but if you want to complete this more easily you can use the TeamCityAgent Chocolatey package and supply the agent name, the agent folder and the port as --params and it will handle setting up the config files as well as pulling in the required version of Java via the server-jre package.
The one caveat to this is you need to use --force on any installs after the first agent as Chocolatey doesn't currently understand installing the same application with a different configuration as a "new" installation.
You will also need to use --version 2.0.1-beta-05 since this is still in a testing phase, but should make it out of beta soon.
Full install example for a second agent:
choco install teamcityagent --force -y --params 'serverUrl=http://teamcity.local:8111 agentName=AgentUno agentDir=C:\buildAgentUno ownPort=9091' --version 2.0.1-beta-05

Resources