This commit is contained in:
Beth Parker 2024-10-05 18:39:21 -05:00
parent 0912b451f2
commit a34df88a5d
2 changed files with 11 additions and 8 deletions

View file

@ -50,6 +50,9 @@ if $regrab;then
exit exit
fi fi
# install/update dependencies
pacman -Sy git --noconfirm
fqdn=`hostnamectl hostname` fqdn=`hostnamectl hostname`
curl -k "https://git.actcur.com/actcur-ansible/playbook-builder/raw/branch/$branch/playbook_templates/$fqdn" -H "accept: application/raw" -o /tmp/$fqdn curl -k "https://git.actcur.com/actcur-ansible/playbook-builder/raw/branch/$branch/playbook_templates/$fqdn" -H "accept: application/raw" -o /tmp/$fqdn
@ -61,7 +64,7 @@ exit
fi fi
# build playbook, retrieve roles and add variables to roles # build playbook, retrieve roles and add variables to roles
mkdir /ansible/roles/ mkdir -p /ansible/roles/
mkdir -p /ansible/new/roles mkdir -p /ansible/new/roles
mkdir -p /ansible/prev/roles mkdir -p /ansible/prev/roles
# delete roles from previous attempt to update them # delete roles from previous attempt to update them
@ -76,12 +79,12 @@ echo "- hosts: $fqdn
while read line while read line
do do
elements=() elements=()
for element in $(echo $line | tr ":" "\n"); do elements+=("$e");done for e in $(echo $line | tr ":" "\n"); do elements+=("$e");done
case ${elements[0]} in case ${elements[0]} in
"role") "role")
# format role:role name:branch/tag to use # format role:role name:branch/tag to use
# clone role repo from specific tag/branch w/o history # clone role repo from specific tag/branch w/o history
git clone -b ${elements[2]} --depth 1 https://git.actcur.com/actcur-ansible/role-${element[1]}.git:/ansible/new/${element[0]} git clone -b ${elements[2]} --depth 1 https://git.actcur.com/actcur-ansible/role-${elements[1]}.git /ansible/new/roles/${elements[1]}
# verify branch was cloned successfully # verify branch was cloned successfully
count=`ls /new/$role/ | wc -l` count=`ls /new/$role/ | wc -l`
@ -89,7 +92,7 @@ do
echo "issue grabbing role $role - dir/file count less than 9, exiting" echo "issue grabbing role $role - dir/file count less than 9, exiting"
exit exit
fi fi
mv /tmp/roles/${element[0]} /ansible/new/roles mv /tmp/roles/${elements[0]} /ansible/new/roles
echo " - nginx-ssl" >> /ansible/new/$fqdn.yml echo " - nginx-ssl" >> /ansible/new/$fqdn.yml
# retrieve var file if it exists # retrieve var file if it exists
@ -98,7 +101,7 @@ do
# verifty file was downloaded successfully # verifty file was downloaded successfully
count=`grep -P "(---)|(end of file)" /tmp/build_ansible.sh | wc -l` count=`grep -P "(---)|(end of file)" /tmp/build_ansible.sh | wc -l`
if [ "$count" != "2" ];then if [ "$count" != "2" ];then
echo "issue grabbing vars file for ${element[0]} role on $fqdn - either file is invalid or download filed, exiting" echo "issue grabbing vars file for ${elements[0]} role on $fqdn - either file is invalid or download filed, exiting"
exit exit
fi fi
;; ;;

View file

@ -1,5 +1,5 @@
role:deluge:branch:testing role:deluge:testing
role:nginx-ssl:branch:testing role:nginx-ssl:testing
role:certbot:branch:testing role:certbot:testing
# end of file # end of file