Add create-local-repo.sh script

This commit is contained in:
Joshua Boniface 2023-09-01 15:42:27 -04:00
parent 24fd853294
commit 13d1c00eda
2 changed files with 66 additions and 0 deletions

View File

@ -38,6 +38,7 @@ A full explanation of all variables can be found in [the manual](https://paralle
are ignored by this Git repository. It is advisable to manage these files securely are ignored by this Git repository. It is advisable to manage these files securely
in a separate repository and use symlinks to place them in the expected locations in in a separate repository and use symlinks to place them in the expected locations in
this repository. Note that the `files/` data is created during cluster bootstrap. this repository. Note that the `files/` data is created during cluster bootstrap.
You can leverage the `create-local-repo.sh` script to do so automatically.
For full details, please see the general [PVC install documentation](https://parallelvirtualcluster.readthedocs.io/en/latest/installing/). For full details, please see the general [PVC install documentation](https://parallelvirtualcluster.readthedocs.io/en/latest/installing/).

65
create-local-repo.sh Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Creates a local repo for storing group_vars/files/inventories, with this
# project as a submodule.
echo "This script will create a new repository for storing your local modifications"
echo "and configurations. It will then include the pvc-ansible repository as a"
echo "submodule for ease of updating and management. Please enter the requested"
echo "details to proceed."
echo
echo -n "Absolute path to new repository ('~', '\$HOME', etc. are NOT supported): "
read target_path
echo
echo "Creating new repo at ${target_path}..."
mkdir -p ${target_path}
pushd ${target_path}
git init .
echo "Adding submodule..."
git submodule add https://github.com/parallelvirtualcluster/pvc-ansible
echo "Creating directories and symlinks..."
mkdir files group_vars roles
ln -s ../pvc-ansible/files/default files/default
ln -s ../pvc-ansible/group_vars/default group_vars/default
ln -s pvc-ansible/oneshot oneshot
ln -s ../pvc-ansible/roles/base roles/base
ln -s ../pvc-ansible/roles/pvc roles/pvc
cp pvc-ansible/pvc.yml .
touch hosts
cat <<EOF >update-remote.sh
#!/usr/bin/env bash
# Updates the local copy of pvc-ansible
set -o errexit
pushd pvc-ansible
git pull --rebase
popd
git add pvc-ansible && git commit -m "Update pvc-ansible from upstream"
EOF
chmod +x update-remote.sh
echo "Adding and performing initial commit..."
git add .
git commit -m "Initial commit of new repository"
popd
echo
echo -e "Success: your new repository has been created at ${target_path}."
echo -e "* You no longer need this copy of the repository and may delete it."
echo -e "* You may edit the initial commit message and author details with the command:"
echo -e " git commit --amend"
echo -e " inside the new repository."
echo -e "* A copy of the file 'pvc.yml' has been made there, as well as your own 'roles/'"
echo -e " directory, so you may add your own roles and customizations to these files"
echo -e " if you so desire."
echo -e "* An empty 'hosts' inventory along with empty 'group_vars' and 'files'"
echo -e " directories have also been prepared; edit these as required."
echo -e "* You may use the 'update-remote.sh' script in this new repository to keep your"
echo -e " copy of pvc-ansible updated, or use normal git commands to do so."