sync repositories - add Jenkinsfile

This commit is contained in:
juju4 2017-01-07 03:55:05 -05:00
parent 717aa9c792
commit 6e852992f7
12 changed files with 101 additions and 19 deletions

@ -22,8 +22,9 @@ provisioner:
platforms: platforms:
- name: ubuntu-16.04 - name: ubuntu-16.04
- name: ubuntu-14.04 ## FIXME! test frozing/stalling on '-----> Running bats test suite' for trusty and precise???
- name: ubuntu-12.04 # - name: ubuntu-14.04
# - name: ubuntu-12.04
- name: centos-7 - name: centos-7
# - name: centos-6 # - name: centos-6
## FIXME! 'Installing Chef Omnibus to install busser to run tests' not supported = can disable ## FIXME! 'Installing Chef Omnibus to install busser to run tests' not supported = can disable

@ -39,8 +39,7 @@ before_install:
- env - env
- pwd - pwd
- find -ls - find -ls
- ln -s ansible-fprobe ../juju4.fprobe - "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- ./get-dependencies.sh
- cp test/travis/initctl_faker test/ - cp test/travis/initctl_faker test/
# Customize container # Customize container
- 'sudo docker build --rm=true --file=test/travis/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible test' - 'sudo docker build --rm=true --file=test/travis/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible test'

@ -39,8 +39,7 @@ before_install:
- env - env
- pwd - pwd
- find -ls - find -ls
- ln -s ansible-fprobe ../juju4.fprobe - "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- ./get-dependencies.sh
- cp test/travis/initctl_faker test/ - cp test/travis/initctl_faker test/
# Customize container # Customize container
- 'sudo docker build --rm=true --file=test/travis/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible test' - 'sudo docker build --rm=true --file=test/travis/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible test'

@ -24,8 +24,7 @@ before_install:
- pwd - pwd
- find -ls - find -ls
## use appropriate role path and not github name ## use appropriate role path and not github name
- ln -s ansible-fprobe ../juju4.fprobe - "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- ./get-dependencies.sh
## No Xenial, https://github.com/travis-ci/travis-ci/issues/5821 ## No Xenial, https://github.com/travis-ci/travis-ci/issues/5821
# - sudo apt install lxd # - sudo apt install lxd
- echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/trusty-backports.list - echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/trusty-backports.list
@ -38,7 +37,7 @@ before_install:
- sudo -E su $USER -c "lxc remote list" - sudo -E su $USER -c "lxc remote list"
- sudo -E su $USER -c "lxc image list" - sudo -E su $USER -c "lxc image list"
## pre-download base images ## pre-download base images
- 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] || lxc image copy images:/${distribution}/${version}/amd64 local: --alias=${distribution}-${version}"' - 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] || lxc image copy images:${distribution}/${version}/amd64 local: --alias=${distribution}-${version}"'
- 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] && lxc image copy ubuntu:${version} local: --alias=${distribution}-${version}" || true' - 'sudo -E su $USER -c "[ ${distribution} == ubuntu ] && lxc image copy ubuntu:${version} local: --alias=${distribution}-${version}" || true'
## configure lxd-bridge ## configure lxd-bridge
- sudo perl -pi -e 's@^LXD_IPV4_ADDR=""@LXD_IPV4_ADDR="10.252.116.1"@;s@^LXD_IPV4_NETMASK=""@LXD_IPV4_NETMASK="255.255.255.0"@;s@^LXD_IPV4_NETWORK=""@LXD_IPV4_NETWORK="10.252.116.1/24"@;s@^LXD_IPV4_DHCP_RANGE=""@LXD_IPV4_DHCP_RANGE="10.252.116.2,10.252.116.254"@;s@^LXD_IPV4_DHCP_MAX=""@LXD_IPV4_DHCP_MAX="252"@;s@LXD_IPV6_PROXY="true"@LXD_IPV6_PROXY="false"@' /etc/default/lxd-bridge - sudo perl -pi -e 's@^LXD_IPV4_ADDR=""@LXD_IPV4_ADDR="10.252.116.1"@;s@^LXD_IPV4_NETMASK=""@LXD_IPV4_NETMASK="255.255.255.0"@;s@^LXD_IPV4_NETWORK=""@LXD_IPV4_NETWORK="10.252.116.1/24"@;s@^LXD_IPV4_DHCP_RANGE=""@LXD_IPV4_DHCP_RANGE="10.252.116.2,10.252.116.254"@;s@^LXD_IPV4_DHCP_MAX=""@LXD_IPV4_DHCP_MAX="252"@;s@LXD_IPV6_PROXY="true"@LXD_IPV6_PROXY="false"@' /etc/default/lxd-bridge

@ -24,8 +24,7 @@ before_install:
- pwd - pwd
- find -ls - find -ls
## use appropriate role path and not github name ## use appropriate role path and not github name
- ln -s ansible-fprobe ../juju4.fprobe - "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- ./get-dependencies.sh
## No Xenial, https://github.com/travis-ci/travis-ci/issues/5821 ## No Xenial, https://github.com/travis-ci/travis-ci/issues/5821
# - sudo apt install lxd # - sudo apt install lxd
- echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/trusty-backports.list - echo "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/trusty-backports.list

@ -5,8 +5,7 @@ python: "2.7"
before_install: before_install:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq python-apt python-pycurl - sudo apt-get install -qq python-apt python-pycurl
- ln -s ansible-fprobe ../juju4.fprobe - "[ -f get-dependencies.sh ] && sh -x get-dependencies.sh"
- ./get-dependencies.sh
## for local travis execution as we use same default.yml than kitchen ## for local travis execution as we use same default.yml than kitchen
- mkdir /tmp/kitchen - mkdir /tmp/kitchen
- ln -s /home/travis/build/juju4/ansible-fprobe/test/integration/default/tmp /tmp/kitchen/tmp - ln -s /home/travis/build/juju4/ansible-fprobe/test/integration/default/tmp /tmp/kitchen/tmp

59
Jenkinsfile vendored Normal file

@ -0,0 +1,59 @@
// Work in progress
node {
try{
currentBuild.result = "SUCCESS"
def workspace = pwd()
def directory = "juju4.fprobe"
stage 'Clean Workspace'
deleteDir()
stage("Download source and capture commit ID") {
sh "mkdir $directory"
dir("$directory") {
checkout scm
// Get the commit ID
sh 'git rev-parse --verify HEAD > GIT_COMMIT'
git_commit = readFile('GIT_COMMIT').take(7)
echo "Current commit ID: ${git_commit}"
}
}
dir("$directory") {
stage("Get dependencies"){
sh "sh -x get-dependencies.sh"
}
stage("Build and verify 1"){
defaultplatform = sh (
script: '''#!/bin/bash
kitchen list | awk "!/Instance/ {print \\$1; exit}"
''',
returnStdout: true
).trim()
echo "default platform: ${defaultplatform}"
sh "kitchen test ${defaultplatform}"
// must keep instance for security testing after
//sh "kitchen verify ${defaultplatform}"
}
stage("Build and verify all platforms"){
sh "kitchen test"
}
stage("Cleanup if no errors"){
sh "kitchen destroy"
}
}
}
catch(err) {
currentBuild.result = "FAILURE"
throw err
}
}

@ -10,4 +10,10 @@ rolesdir=$(dirname $0)/..
fi fi
[ ! -d $rolesdir/juju4.redhat-epel ] && git clone https://github.com/juju4/ansible-redhat-epel $rolesdir/juju4.redhat-epel [ ! -d $rolesdir/juju4.redhat-epel ] && git clone https://github.com/juju4/ansible-redhat-epel $rolesdir/juju4.redhat-epel
## galaxy naming: kitchen fails to transfer symlink folder
#[ ! -e $rolesdir/juju4.fprobe ] && ln -s ansible-fprobe $rolesdir/juju4.fprobe
[ ! -e $rolesdir/juju4.fprobe ] && cp -R $rolesdir/ansible-fprobe $rolesdir/juju4.fprobe
## don't stop build on this script return code
true

@ -1,7 +1,7 @@
--- ---
galaxy_info: galaxy_info:
author: juju4 author: juju4
description: TEMPLATE description: setup fprobe as netflow exporter
license: BSD license: BSD
min_ansible_version: 2.0 min_ansible_version: 2.0
# #

@ -32,7 +32,10 @@
- name: add init.d script - name: add init.d script
template: src=init.d-fprobe.j2 dest=/etc/rc.d/init.d/fprobe-ulog mode=0755 template: src=init.d-fprobe.j2 dest=/etc/rc.d/init.d/fprobe-ulog mode=0755
when: ansible_os_family == 'RedHat' when: ansible_os_family == 'RedHat' and ansible_service_mgr != 'systemd'
- name: add systemd script
template: "src=systemd-fprobe-ulog.service.j2 dest=/lib/systemd/system/{{ fprobe_svc }}.service mode=0644"
when: ansible_service_mgr == 'systemd'
- name: ensure service is enabled and started - name: ensure service is enabled and started
service: name={{ fprobe_svc }} state=started enabled=yes service: name={{ fprobe_svc }} state=started enabled=yes

@ -14,15 +14,16 @@
start() { start() {
echo -n "Starting fprobe-ulog: " echo -n "Starting fprobe-ulog"
fprobe-ulog -c /var/tmp $FLOW_COLLECTOR fprobe-ulog -c /var/tmp $FLOW_COLLECTOR
touch /var/lock/subsys/fprobe-ulog touch /var/lock/subsys/fprobe-ulog
echo . echo .
ps axu | egrep '[f]probe-ulog'
return 0 return 0
} }
stop() { stop() {
echo -n "Shutting down fprobe-ulog: " echo -n "Shutting down fprobe-ulog"
pkill fprobe-ulog pkill fprobe-ulog
rm -f /var/lock/subsys/fprobe-ulog rm -f /var/lock/subsys/fprobe-ulog
echo . echo .

@ -0,0 +1,17 @@
[Unit]
Description=fprobe netflow collector
Requires=network.target
[Service]
Type=simple
{% if ansible_os_family == 'RedHat' %}
ExecStart=/usr/bin/fprobe-ulog -c /var/tmp {{ fprobe_flow_collector }} -l 3
{% else %}
ExecStart=/usr/sbin/fprobe -i{{ fprobe_if }} {{ fprobe_args }} {{ fprobe_flow_collector }} -l 3
{% endif %}
TimeoutSec=30
RestartSec=15s
Restart=always
[Install]
WantedBy=multi-user.target