Continuous delivery of infrastructure projects - jenkins

I'm using Jenkins to achieve Continuous Delivery on some infrastructure projects. ATM Master-Slave Jenkins model is used where the jobs are always built by some some slave and not by the master, my intentions are to build and run test-kitchen and leibniz tests using LXC. All the requirements are matched vagrant-lxc, lxc boxes, leibniz and test-kitchen configured, everything works ok on my PC or any other of my team members but when it comes to run the Job through Master-Slave on Jenkins it seems there are some problems with environment, in details:
1- When I run as part of a build step "which lxc-create" it works and shows /usr/bin/lxc-create as it should but
2- When it runs kitchen test is fails showing:
+ kitchen test
-----> Starting Kitchen (v1.1.1)
-----> Cleaning up any prior instances of <default-ubuntu-1204>
-----> Destroying <default-ubuntu-1204>...
Finished destroying <default-ubuntu-1204> (0m0.00s).
-----> Testing <default-ubuntu-1204>
-----> Creating <default-ubuntu-1204>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=lxc ----
STDOUT:
STDERR: The `lxc` package does not seem to be installed or is not accessible on the PATH.
---- End output of vagrant up --no-provision --provider=lxc ----
Ran vagrant up --no-provision --provider=lxc returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
It seems some environment variable is missing or something wired, It matters to say that sshing into the slave and building manually it works fine so is not a setup problem but a Master-Slave environment transmission problem or I'm missing something crucial on the configurations. Can anyone provide some help?
lxc version: 1.0.0
vagrant-lxc: 0.8.0
jenkins: 1.5.49
UPDATE 1:
Here is my kitchen configuration:
---
driver:
name: vagrant
require_chef_omnibus: false
require_chef_berkshelf: true
customize:
memory: 1024
provisioner:
name: chef_solo
platforms:
- name: ubuntu-12.04
driver:
box: "ubuntu-12.04"
box_url: "http://dl.company.com/ubuntu1204-lxc-amd64.box"
provider: lxc
suites:
....

Solved the issue!. The error message raised by Jenkins was wrong, I added Jenkins user to sudoers with NOPASSWORD and it worked just fine. I figured out because on my personal PC creating a container always asks for the sudo password.

Related

Ansible AWX: Unable to choose a playbook when tried creating AWX Job template

I'm tried creating a job template in AWX web interface.
the list of playbooks is not displayed on the interface although the project has been downloaded to git and is visible in the directory ~/var/lib/awx/projects.
my environment:
centOS 8
AWX 17.0.1
Ansible 2.9.17
docker-compose 1.28.2
The yml file must not be empty and must have right syntax.
After that , always sync project and then check
I had this same challenge when creating a new Job Template on Ansible AWX setup on Ubuntu 20.04.
I created some playbooks in a repository that was added to a project. I then created a Job Template and selected the Project, but none of the playbooks were added to the project.
My playbook looked this way:
- name: Check if SSHD is running
command: systemctl status ssh
ignore_errors: yes
Here's how I fixed it:
I simply added hosts to the playbook and it showed up on the Job template for me to select. So my playbook was modified to look this way:
- name: Check if SSHD is running
hosts: all
command: systemctl status ssh
ignore_errors: yes
Note: The value for hosts could be something else. For me, it was all.
Resources: Playbooks aren’t showing up in the “Job Template” drop-down
That's all.
I hope that helps
I had the same problem. Once I made sure my git repo was up-to-date, I manually typed in the playbook name in the awx template creation screen, and my playbook was selected.

which build in a travis matrix build is used for gh_page provider

When I have a travis matrix build with a spec like this:
matrix:
include:
- os: osx
rust: stable
- os: linux
rust: stable
allow_failures:
- os: osx
and I use the deploy provider to upload an html book generated during the build:
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_PAGES_TOKEN
local-dir: target/html
keep-history: false
on:
branch: master
Which build output is that gh_pages provider running on?
From experimentation, it seems that the deploy: gh_pages provided is run on the last build in my matrix, in the example above: linux.
I am unsure if failure_allowed on the other builds (possibly combined with fast_fail) could change that though.
i.e.If the last one is allowed to fail (and it does) then I think the deployer will not run, even if overall the build has "succeeded" and is green.

kubernetes setup on ubuntu machine with 2 minion and 1 master node

I am following this tutorial at https://gettech1.wordpress.com/2016/05/26/setting-up-kubernetes-cluster-on-ubuntu-14-04-lts/ to setup kubernet multi node with 2 minions and 1 master node on remote ubuntu machines, after following all the steps it goes OK. But when I am trying to run the ./kube-up.sh bash file. It returns the following errors
ubuntu#ip-XXX-YYY-ZZZ-AAA:~/kubernetes/cluster
$ ./kube-up.sh
Starting cluster in us-central1-b using provider gce ... calling
verify-prereqs Can't find gcloud in PATH, please fix and retry. The
Google Cloud SDK can be downloaded from
https://cloud.google.com/sdk/.
Edit : I have fixed above issue after exporting different environment variables like
$ export KUBE_VERSION=2.2.1
$ export FLANNEL_VERSION=0.5.5
$ export ETCD_VERSION=1.1.8
but after that it is generating this issue
kubernet gzip: stdin: not in gzip format tar: Child returned status 1
tar: Error is not recoverable: exiting now
The command you should be executing is KUBERNETES_PROVIDER=ubuntu ./kube-up.sh
Without setting that environment variable kube-up.sh tries to deploy VMs on Google Compute Engine and to do so it needs the gcloud binary that you don't have installed.

How to setup a Travis/Rails project to submit to Coverity Scan?

I'm looking for a std travis coverity setup for a rails application.
My current .travis.yml file looks like this:
# environment settings
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "<SECURE>"
# project language
language: ruby
rvm:
- 2.3.1
# branches to build (whitelist)
branches:
only:
- master
- coverity_scan
- testing
# command to run before install
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
# arguments for the bundler
bundler_args: --without production development
# addons
addons:
coverity_scan:
project:
name: "<PROJECT_NAME>"
description: "Build submitted via Travis CI"
notification_email: <MY_EMAIL>
build_command_prepend: ""
build_command: "--no-command"
branch_pattern: coverity_scan
# script
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
- bundle exec cucumber
# run before script
before_script:
- mysql -e 'create database my_app_test'
- psql -c 'create database my_app_test' -U postgres
I'm not sure what to put in the build_command part of addons.coverity_scan. I already tried leaving it empty, --no-command, bundle install, and bundle install --jobs=3 --retry=3, but none of them worked. --no_command, for example, gives me the following message:
Coverity Scan analysis selected for branch coverity_scan.
Coverity Scan analysis authorized per quota.
$ curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | COVERITY_SCAN_PROJECT_NAME="$PROJECT_NAME" COVERITY_SCAN_NOTIFICATION_EMAIL="<MY_EMAIL>" COVERITY_SCAN_BUILD_COMMAND="--no-command" COVERITY_SCAN_BUILD_COMMAND_PREPEND="" COVERITY_SCAN_BRANCH_PATTERN=coverity_scan bash
Note: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com
Coverity Scan configured to run on branch coverity_scan
Coverity Scan analysis authorized per quota.
Downloading Coverity Scan Analysis Tool...
2016-09-13 23:26:36 URL:https://scan.coverity.com/download/Linux [449455458/449455458] -> "/tmp/cov-analysis-Linux.tgz" [1]
Extracting Coverity Scan Analysis Tool...
/tmp/coverity-scan-analysis ~/build/<PROJECT_NAME>
~/build/<PROJECT_NAME>
Running Coverity Scan Analysis Tool...
Coverity Build Capture (64-bit) version 8.5.0.3 on Linux 3.13.0-92-generic x86_64
Internal version numbers: db70178643 p-kent-push-26368.949
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
/home/travis/build/<PROJECT_NAME>/cov-int/build-log.txt
Extracting SCM data for 0 files...
Please see the log file '/home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt' for warnings and SCM command issues.
[WARNING] Unable to gather all SCM data - see log at /home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt for details.
Successfully added SCM data for 0 files
Tarring Coverity Scan Analysis results...
Uploading Coverity Scan Analysis results...
And because I'm using travis I'm not able to look into the log files...
When the command is empty it fails with the error, that a command needs to be given and it does nothing.
Can someone help me with some kind of a std setup for a rails app?
Thanks in advance!
Instructions for using Coverity SCAN the new languages supported by 8.5 are found here : https://scan.coverity.com/download?tab=other . We assume that users first read these instructions prior to attempting TravisCI integration. It is also highly recommended that local integration is tested to ensure clean captures before attempting any CI.
Ruby is supported in Coverity 8.5. Debugging this is difficult without the log. It's possible the SCAN kit is missing a config for Ruby, which can be fixed by running cov-configure --ruby.
The more likely problem, however, is that Ruby is what Coverity considers a "non-compiled" language (meaning you don't usually have a build that compiles them before they can be used). So this means you need to inform cov-build about where your Ruby files are. Looking at your travis config, I expect you need to add this to your build_command: --fs-capture-search /path/to/your/ruby/files
It seems that it is not possible to analyse rails (interpreted ones in general) projects (correct me if I'm wrong). I deleted my project from coverity.

How to Install Jenkins using Apache Brooklyn and Chef

I want to install Jenkins on a VM using Chef (and Apache Brooklyn). The blueprint being used is,
name: chef-jenkins
location:
jclouds:aws-ec2:
region: xyz
services:
- type: chef:jenkins
cookbook_urls:
jenkins: .../jenkins.tgz
runit: ... /runit.tgz
apt: .../apt.tgz
yum: .../yum20150407-59421-1bw7bou.tar.gz
launch_run_list: [ "jenkins::start" ]
service_name: jenkinsd
The service_name parameter is incorrect.
Running this throws an error "Failure running task ssh: run chef for launch (jSUGhBph): SSH task ended with exit code 1 when 0 was required, in Task[ssh: run chef for launch:jSUGhBph]: run chef for launch".
What else am I missing? Is it possible to run a simple chef recipe (e.g. https://gist.github.com/nstielau/978920) directly?
The error message you saw indicates that one of the shell commands that Brooklyn tried to run on the cloud server failed - in particular to "run chef for launch" command. To find out why this failed, use the Activity tab:
The tree view on the left contains the whole application. Expand this.
This will reveal the entities that make up the application. This blueprint has only one, called jenkins (chef) - click on this.
Click on the Activity tab. This will show you the list of tasks. One of them will have the status Failed - click on this.
Tasks can have subtasks, so you may see another task list, with one in status Failed - keep following this trail until you come to the last failed task
If this is an SSH task, you will have links to download stdout and stderr - you can inspect these to find out exactly why the shell command failed.
You can also find a section on troubleshooting in the Apache Brooklyn user guide which may help diagnose other problems.
I've taken your blueprint and made a few modifications; this is now working on my Ubuntu 14.04 image:
name: chef-jenkins
location: vagrant-trusty
services:
- type: chef:jenkins
cookbook_urls:
jenkins: data:application/octet-stream;charset=UTF-8;base64,H4sIAC/fwVUAA+1b3W/bOBLvM/8K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mQO2WrR/PL/49uZi2qhg9xuO3P5aUbwV/+3NQcF2gar6bKW/+dnKimPEiHpsg8JyYcPMqilzARVrdfAhKmpRORuABKo4r3vh13baY6aQITBhia85BtCK1f3E4qZr7xrfGzFZvnI3c05jxMC0iWtaTskASGwlv2JPIRLhXtXgK34hA4VtGgEUd5U54BA9xaD3YJqP31ocZU71qW5FjQ2QsCDArGzDxIIPY7gUFA6U3RBs91QnovwKjl5ds7/gxVsJGYnlGSATHQkRlNL1pZS4Y12Bzq/5Uhgk3SK4bTzJN2GMDISiDrFwopoVcQnbZ5kZppArJyn8IwcDmi/iJzGnACG8A4YIutxO2Huf68FDDWvosF9zE/uNPjYBxIpetxmcoIKGNPBuDEKzFQzkJFySmD600Dit5y0K62XCYVrmQhuNYaZEf47EdJbhLalNr/D+tyignQUo/O++xg4ODg4ODg4ODg4ODg4ODg4ODg4PD3xa/A3Nc9FMAUAAA
apt: https://github.com/opscode-cookbooks/apt/archive/v2.7.0.tar.gz
java: https://github.com/agileorbit-cookbooks/java/archive/v1.29.0.tar.gz
launch_run_list: [ "jenkins::default" ]
service_name: jenkins
launch_attributes:
java:
jdk_version: 7
This blueprint is ready-to-run (except for changing the location to match your requirements). Here are some of the changes I have made:
Full URLs for the three cookbooks
The jenkins data URL contains a bare-bones cookbook containing the recipe you referred to in a gist, tarred-and-gzipped
For the jenkins cookbook, I had to specify depends "apt" and depends "java" in metadata.rb otherwise I got strange Chef errors
Fixed launch_run_list to refer to the correct recipe name
Fixed service_name to refer to the correct service name
Added launch_attributes to configure the Java cookbook to install Java 7 (the default of Java 6 is not supported by Jenkins)

Resources