arioch / poc-puppet-module-packaging Goto Github PK
View Code? Open in Web Editor NEWProof of concept script to build native OS packages from puppet modules.
Proof of concept script to build native OS packages from puppet modules.
There is an issue when there isn't a dependency declared in the Modulefile the fpm command fails because of the emptiness of the --depends parameter.
I tackled it using the if statement to grab the dependencies out of the Modulefile. If there are dependency execute the fpm command with the --depends param.
If not execute the fpm command without the --depends param.
I used this code to start writing a managed script in a jenkins instance with the os as a parameter.
So this script can be ran in a jenkins job pointing to the puppet-module git repository:
DATE=$(date '+%Y%m%d%H%M')
PUPPET_TREE='/etc/puppet'
BUILD_OS=$1
MODULE_NAME=$(
grep -i ^name Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f2
| cut -d '-' -f2
)
MODULE_VERSION=$(
grep -i ^version Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f2
)
MODULE_LICENSE=$(
grep -i ^license Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f2
)
MODULE_DESCRIPTION=$(
grep -i ^description Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f2
)
MODULE_URL=$(
grep -i ^project_page Modulefile
| cut -d "'" -f2
)
if [ -n "$(grep -i ^dependency Modulefile)" ]
then
DEPENDENCY_NAME=$(
grep -i ^dependency Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f2
| cut -d '/' -f2
)
DEPENDENCY_VERSION=$(
grep -i ^dependency Modulefile
| sed -e "s+"+'+g"
| cut -d "'" -f4
)
FPM_DEPENDS="puppet-module-${DEPENDENCY_NAME} ${DEPENDENCY_VERSION}"
fi
build_centos() {
fpm -s dir -t rpm
-v ${MODULE_VERSION}
--url '${MODULE_URL}'
--epoch ${BUILD_NUMBER}
--iteration ${BUILD_NUMBER}
--prefix ${PUPPET_TREE}/modules/${MODULE_NAME}
--directories .
--exclude .git*
--exclude ..lock
--exclude ..swp
--exclude .gem*
--exclude .project
--exclude .vim*
--exclude .travis.yml
-a all
-n puppet-module-${MODULE_NAME}
.
}
build_squeeze() {
fpm -s dir -t deb
--architecture all
-n puppet-module-${MODULE_NAME}
-v ${MODULE_VERSION}-${DATE}+squeeze1
--license "${MODULE_LICENSE}"
--prefix ${PUPPET_TREE}/modules/${MODULE_NAME}
--description "${MODULE_DESCRIPTION}"
--depends "${FPM_DEPENDS}"
--directories .
--exclude .git*
--exclude ..lock
--exclude ..swp
--exclude .gem*
--exclude .project
--exclude .vim*
--exclude .travis.yml
.
}
build_wheezy() {
fpm -s dir -t deb
--architecture all
-n puppet-module-${MODULE_NAME}
-v ${MODULE_VERSION}-${DATE}+wheezy1
--license "${MODULE_LICENSE}"
--prefix ${PUPPET_TREE}/modules/${MODULE_NAME}
--description "${MODULE_DESCRIPTION}"
--depends "${FPM_DEPENDS}"
--directories .
--exclude .git*
--exclude ..lock
--exclude ..swp
--exclude .gem*
--exclude .project
--exclude .vim*
--exclude .travis.yml
.
}
build_debian() {
build_squeeze
build_wheezy
}
case $BUILD_OS in
centos_)
build_centos
exit
;;
debian_)
build_debian
exit
;;
*)
echo "This OS, $BUILD_OS isn't supported by this script"
exit
;;
esac
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.