Skip to content

Commit

Permalink
bootstrap chef on SUSE from packages
Browse files Browse the repository at this point in the history
usage:
    knife bootstrap --template-file bootstrap.suse.erb -u root 10.0.0.1

Copied from
https://github.com/mvidner/chef_solo_deploy/blob/cc060741720fe80a2e714573c24e8067ca536e3e/install-chef/opensuse
  • Loading branch information
mvidner committed Mar 27, 2013
1 parent ce19dbd commit 15788c9
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions bootstrap.suse.erb
@@ -0,0 +1,67 @@
#!/bin/bash
set -e

reponame() {
release=$(cat /etc/SuSE-release)
case "$release" in
*openSUSE?11.4*)
echo openSUSE_11.4 ;;
*openSUSE?12.1*)
echo openSUSE_12.1 ;;
*openSUSE?12.2*)
echo openSUSE_12.2 ;;
*"SUSE Linux Enterprise Server"*"VERSION = 11"*"PATCHLEVEL = 1"*)
echo SLE_11_SP1 ;;
*"SUSE Linux Enterprise Server"*"VERSION = 11"*"PATCHLEVEL = 2"*)
echo SLE_11_SP2 ;;
esac
}

# $1 32 bit id
addrepokey() {
rpm -qa gpg-pubkey | grep -i $1 && return
gpg --keyserver pgp.mit.edu --recv-keys $1
KEYFILE=`mktemp gpg-key-$1-XXXXXX`
gpg --armor --export $1 > $KEYFILE
rpm --import $KEYFILE
rm $KEYFILE
}

addrepo() {
REPO=$1
REPOPATH=${REPO//:/:/} # turn a:b:c into a:/b:/c
REPOURL=http://download.opensuse.org/repositories/${REPOPATH}/$(reponame)
REPOKEY=$2

zypper repos --export - | grep --fixed-strings $REPOURL && return
addrepokey $REPOKEY
zypper addrepo $REPOURL ${REPO}
zypper refresh ${REPO}
}

# $1 obs:repo:name
addobsvendor() {
VENDORBASE=${1%%:*}
VENDORID=obs://build.opensuse.org/$VENDORBASE
VDIR=/etc/zypp/vendors.d
mkdir -p $VDIR
test -f $VDIR/$VENDORBASE && return
cat <<EOF > $VDIR/$VENDORBASE
[main]
vendors = SUSE,$VENDORID
EOF
}

install() {
zypper --non-interactive install rubygem-chef
}

rpm -q rubygem-chef && exit

install && exit

addrepo systemsmanagement:chef:10 A0E46E11
install && exit

addobsvendor systemsmanagement:chef:10
install

0 comments on commit 15788c9

Please sign in to comment.