Add a new git/make_checkout_seed role
This will be needed to migrate Dist Git from puppet to ansible.
This commit is contained in:
parent
7916770b41
commit
9dd33b21dd
2 changed files with 60 additions and 0 deletions
47
roles/git/make_checkout_seed/files/make-git-checkout-seed.sh
Normal file
47
roles/git/make_checkout_seed/files/make-git-checkout-seed.sh
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Puppet notes -- script is file
|
||||||
|
# mkdir /srv/git_seed
|
||||||
|
# cron job to invoke file daily
|
||||||
|
# Need to setup OUTPUT_DIR to be served by apache
|
||||||
|
|
||||||
|
# Where the git repos live. These are bare repos
|
||||||
|
ORIGIN_DIR=/srv/git/rpms
|
||||||
|
|
||||||
|
# Where we'll create the repos to tar up
|
||||||
|
WORK_DIR=/srv/git_seed
|
||||||
|
# Subdirectory makes cleanup easier
|
||||||
|
SEED_DIR=$WORK_DIR/git-checkout
|
||||||
|
|
||||||
|
# Where to store the seed tarball for download
|
||||||
|
OUTPUT_DIR=/srv/cache/lookaside/
|
||||||
|
|
||||||
|
# Instead of starting fresh each time, we'll try to use git pull to keep things synced
|
||||||
|
#rm -rf $WORK_DIR/*
|
||||||
|
mkdir -p $SEED_DIR
|
||||||
|
|
||||||
|
# Give people an indication of when this checkout was last synced
|
||||||
|
TIMESTAMP=`date --rfc-3339=seconds`
|
||||||
|
DATE=`date +'%Y%m%d'`
|
||||||
|
echo "$TIMESTAMP" > $SEED_DIR/TIMESTAMP
|
||||||
|
|
||||||
|
|
||||||
|
for repo in $ORIGIN_DIR/*.git ; do
|
||||||
|
working_tree=$SEED_DIR/$(basename $repo .git)
|
||||||
|
if [ -d $working_tree ] ; then
|
||||||
|
pushd $working_tree &> /dev/null
|
||||||
|
sed -i "s@url = .*@url = $repo@" $working_tree/.git/config
|
||||||
|
git pull --all &> /dev/null
|
||||||
|
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$(basename $repo .git)@" $working_tree/.git/config
|
||||||
|
popd &>/dev/null
|
||||||
|
else
|
||||||
|
pushd $SEED_DIR &>/dev/null
|
||||||
|
git clone $repo &> /dev/null
|
||||||
|
popd &>/dev/null
|
||||||
|
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$(basename $repo .git)@" $working_tree/.git/config
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
tar -cf - -C$WORK_DIR $(basename $SEED_DIR)|xz -2 > $OUTPUT_DIR/.git-seed-$DATE.tar.xz
|
||||||
|
rm $OUTPUT_DIR/git-seed*tar.xz
|
||||||
|
mv $OUTPUT_DIR/.git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-$DATE.tar.xz
|
||||||
|
ln -s git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-latest.tar.xz
|
13
roles/git/make_checkout_seed/tasks/main.yml
Normal file
13
roles/git/make_checkout_seed/tasks/main.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
# tasklist for setting up the Git checkout seed
|
||||||
|
|
||||||
|
- name: create the destination directory
|
||||||
|
file: dest=/srv/git_seed owner=root group=root mode=0755 state=directory
|
||||||
|
|
||||||
|
- name: install the script and schedule its execution
|
||||||
|
copy: src=make-git-checkout-seed.sh dest=/usr/local/bin/make-git-checkout-seed.sh mode=0755
|
||||||
|
cron: >
|
||||||
|
name="make-git-checkout-seed" cron_file="ansible-make-git-checkout-seed"
|
||||||
|
minute=0 hour=2
|
||||||
|
user=root
|
||||||
|
job='/usr/local/bin/lock-wrapper make-git-checkout-seed "/usr/local/bin/make-git-checkout-seed.sh | /usr/local/bin/nag-once fassync 1d 2>&1"'
|
Loading…
Add table
Add a link
Reference in a new issue