Skip to content

Commit 9d69fdc

Browse files
committed
compare-puppet-catalogs: minor tweaks
I did my best to make the software NOT depend on being run as root out of vagrant, and in general to play nicer for a "production" installation. Change-Id: I72c5b17b58c327b973279bc89966bc6c44a56259 Signed-off-by: Giuseppe Lavagetto <glavagetto@wikimedia.org>
1 parent f3eef6b commit 9d69fdc

File tree

9 files changed

+21
-15
lines changed

9 files changed

+21
-15
lines changed

compare-puppet-catalogs/provision.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
apt-get update
44
apt-get -y install curl git-core vim python-pip python-dev
5-
apt-get -y install ruby1.8 rubygems ruby-bundler ruby1.8-dev
5+
apt-get -y install ruby1.8 rubygems ruby-bundler ruby1.8-dev ruby-bcrypt
66
echo mysql-server-5.5 mysql-server/root_password password cucciolo | debconf-set-selections
77
echo mysql-server-5.5 mysql-server/root_password_again password cucciolo | debconf-set-selections
88
apt-get install -y mysql-common mysql-server mysql-client

compare-puppet-catalogs/puppet_compare/app_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
MYDIR=os.path.dirname(os.path.realpath(__file__))
33
PARENT=os.path.realpath(os.path.join(MYDIR,'..'))
4-
BASEDIR = os.environ.get('PUPPET_DIFFER_BASEDIR', '/vagrant')
4+
BASEDIR = os.environ.get('PUPPET_COMPILER_BASEDIR', PARENT)
55
get_path = lambda x: os.path.join(BASEDIR, x)
66
COMPILE_SCRIPT = get_path('shell/compile')
77
FETCH_CHANGE = get_path('shell/prepare_change')

compare-puppet-catalogs/puppet_compare/generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717

1818
def run(cmd, sudo=False, sudo_user='root', capture=True):
19+
env = os.environ.copy()
1920
if sudo:
20-
cmd = "sudo -u %s '%s'" % (sudo_user, cmd)
21+
cmd = "sudo -E -u %s '%s'" % (sudo_user, cmd)
2122

2223
cmdlist = shlex.split(cmd)
2324

@@ -27,7 +28,7 @@ def run(cmd, sudo=False, sudo_user='root', capture=True):
2728
# This just works in python 2.7. Wrap this again?
2829
method = subprocess.check_call
2930

30-
return method(cmdlist)
31+
return method(cmdlist, env=env)
3132

3233

3334
def ruby(cmd, **kwdargs):

compare-puppet-catalogs/shell/compile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ else
1616
CHANGE=${4}
1717
fi;
1818

19+
# Get the password externally, or use the default
20+
if [ -z ${PUPPET_DIFFER_MYSQL_PWD} ]; then
21+
DBPASSWORD='puppet'
22+
else
23+
DBPASSWORD=${PUPPET_COMPILER_MYSQL_PWD}
24+
fi;
25+
26+
1927
ETCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2028
PUPPET_VERSION=${1}
2129
MY_GEMDIR=${ETCDIR}/env_puppet_${PUPPET_VERSION}
@@ -45,7 +53,7 @@ TIME_FILE=$CATALOG_DIR/$2.time
4553
WARNINGS_FILE=$CATALOG_DIR/$2.warnings
4654

4755
if [ "$PUPPET_VERSION" == "3" ]; then
48-
COMPILE_OPTIONS="--storeconfigs true --thin_storeconfigs true --dbadapter mysql --dbserver localhost --dbuser puppet --dbpassword puppet"
56+
COMPILE_OPTIONS="--storeconfigs true --thin_storeconfigs true --dbadapter mysql --dbserver localhost --dbuser puppet --dbpassword $DBPASSWORD"
4957
else
5058
# storeconfigs gets you issues with compiling 2.7 catalogs
5159
# Verified on palladium, with storeconfigs the format of compiled catalogs changes in 2.7

compare-puppet-catalogs/shell/differ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ OUT_DIR=${2}
1818
OUTPUT_FILE=${OUT_DIR}/${1}.diff
1919

2020
test -d ${OUT_DIR} || mkdir -p ${OUT_DIR}
21-
bundle exec puppet catalog diff --content_diff ${OLD_CATALOG_DIR}/${1}.pson ${NEW_CATALOG_DIR}/${1}.pson > ${OUTPUT_FILE}
21+
bundle exec puppet catalog diff --modulepath=${PARENT}/external/puppet/modules --content_diff ${OLD_CATALOG_DIR}/${1}.pson ${NEW_CATALOG_DIR}/${1}.pson > ${OUTPUT_FILE}
2222
popd

compare-puppet-catalogs/shell/env_puppet_2.7/,gitingnore renamed to compare-puppet-catalogs/shell/env_puppet_2.7/.gitignore

File renamed without changes.

compare-puppet-catalogs/shell/env_puppet_2.7/Gemfile.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ GEM
1111
activeresource (2.3.14)
1212
activesupport (= 2.3.14)
1313
activesupport (2.3.14)
14-
bcrypt (3.1.7)
15-
bcrypt-ruby (3.1.5)
16-
bcrypt (>= 3.1.3)
1714
facter (1.7.5)
1815
hiera (1.3.2)
1916
json_pure
@@ -34,7 +31,6 @@ GEM
3431
rake (>= 0.8.3)
3532
rake (10.3.1)
3633
trocla (0.0.9)
37-
bcrypt-ruby
3834
highline
3935
moneta (~> 0.7.2)
4036

compare-puppet-catalogs/shell/env_puppet_3/Gemfile.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ GEM
1111
activeresource (2.3.14)
1212
activesupport (= 2.3.14)
1313
activesupport (2.3.14)
14-
bcrypt (3.1.7)
15-
bcrypt-ruby (3.1.5)
16-
bcrypt (>= 3.1.3)
1714
facter (1.7.5)
1815
hiera (1.3.2)
1916
json_pure
@@ -35,7 +32,6 @@ GEM
3532
rake (10.3.1)
3633
rgen (0.6.6)
3734
trocla (0.0.9)
38-
bcrypt-ruby
3935
highline
4036
moneta (~> 0.7.2)
4137

compare-puppet-catalogs/shell/helper

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ function update() {
104104
}
105105

106106
function copy_facts() {
107-
test -f ${FACTS_ARCHIVE} || ( log "Could not find ${FACTS_ARCHIVE}" && exit 1)
107+
# there is no need to block run if facts are not in place.
108+
if [ ! -f ${FACTS_ARCHIVE} ]; then
109+
log "Could not find ${FACTS_ARCHIVE}"
110+
return
111+
fi;
108112
# This expects a file called puppet-facts.tar.xz in the parent of the installation
109113
pushd ${EXTDIR}
110114
log "Extracting the facts archive"
@@ -117,6 +121,7 @@ function purge() {
117121
rm -rf ${PRIVATEDIR}
118122
rm -rf ${DIR}/var/yaml
119123
}
124+
120125
function setup_naggen() {
121126
if [ ! -f /usr/local/bin/naggen ]; then
122127
cp ${PUPPETDIR}/modules/puppetmaster/files/naggen /usr/local/bin/naggen

0 commit comments

Comments
 (0)