Skip to content
Extraits de code Groupes Projets
Valider c870aa69 rédigé par Théo - Le Filament's avatar Théo - Le Filament
Parcourir les fichiers

change: better formating for collected versions

parent 399b8099
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -3,30 +3,34 @@ ...@@ -3,30 +3,34 @@
# Copyright © 2019 Le Filament (<http://www.le-filament.com>) # Copyright © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
mkdir -p /home/{{ host_user }}/versions
TODAY=`date +%F` VERSIONS_DIR='/home/{{ host_user }}/versions'
file="/home/{{ host_user }}/versions/{{ inventory_hostname|lower }}.$TODAY" today=$(date '+%F')
latest_file="/home/{{ host_user }}/versions/{{ inventory_hostname|lower }}.latest" outfile_apt="${VERSIONS_DIR}/apt_{{ inventory_hostname|lower }}.${today}"
printf "DATE = $TODAY" > $file outfile_apt_hr="${VERSIONS_DIR}/apt-hr_{{ inventory_hostname|lower }}.${today}"
printf "\n\n-- OS version --\n" >> $file outfile_pip3="${VERSIONS_DIR}/pip3_{{ inventory_hostname|lower }}.${today}"
lsb_release -a >> $file outfile_pip3_hr="${VERSIONS_DIR}/pip3-hr_{{ inventory_hostname|lower }}.${today}"
printf "\n\n-- Installed OS packages --\n" >> $file
apt list --installed >> $file mkdir --parents "${VERSIONS_DIR}"
if [[ -f "/usr/bin/pip" ]]; then
printf "\n\n-- Installed Python packages --\n" >> $file dpkg-query --no-pager --show --showformat '${Package}|${Version}|${Architecture}|${db:Status-Abbrev}\n' | paste -s -d ';' > $outfile_apt
pip list installed >> $file apt-mark showmanual | paste -s -d ';' >> $outfile_apt
fi
if [[ -f "/usr/bin/pip3" ]]; then python3 -m pip list --pre --format json > $outfile_pip3
printf "\n\n-- Installed Python 3 packages --\n" >> $file python3 -m pip list --pre --not-required --format json >> $outfile_pip3
pip3 list installed >> $file
fi apt list --installed > $outfile_apt_hr
cp $file $latest_file
chmod 644 $file $latest_file pip3 list installed > $outfile_pip3_hr
{% for host in groups.backup_server %} {% for host in groups.backup_server %}
{% if host != inventory_hostname %} {% if host != inventory_hostname %}
sftp -P {{ default_sshd_port }} -o IdentityFile=/home/{{ host_user }}/.ssh/id_ed25519 {{ backup_sftp_user }}@{{ hostvars[host].ansible_host }} << COMMANDS sftp -b - -P {{ default_sshd_port }} -o IdentityFile=/home/{{ host_user }}/.ssh/id_ed25519 {{ backup_sftp_user }}@{{ hostvars[host].ansible_host }} << COMMANDS
put $file {{ inventory_hostname|lower }}/ -put ${outfile_apt} {{ inventory_hostname|lower }}/
-put ${outfile_pip3} {{ inventory_hostname|lower }}/
-put ${outfile_apt_hr} {{ inventory_hostname|lower }}/
-put ${outfile_pip3_hr} {{ inventory_hostname|lower }}/
quit quit
COMMANDS COMMANDS
{% endif %} {% endif %}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter