import old book

This commit is contained in:
2026-09-15 09:18:07 +05:30
parent 8972d33311
commit bc85ab7969
17 changed files with 580 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
#SPDX-License-Identifier: MIT-0
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
+48
View File
@@ -0,0 +1,48 @@
- name: get list of disks
changed_when: false
shell: >
lsblk
--json
--paths
--filter 'MIN == 0 && TYPE == "disk" && MOUNTPOINT != "[SWAP]"'
| jq '.blockdevices'
register: disks
- name: backup partition tables
become: true
shell: |
if [ {{ item.type }} != disk ]; then exit 0; fi
sfdisk --dump {{ item.name }} >{{ backup_directory }}/disks/{{ item.name | basename }}.sfdisk
loop: "{{ disks.stdout }}"
- name: get list of luks devices
changed_when: false
shell: >
lsblk
--json
--paths
| jq '[ .blockdevices[]|.children[]?|select(recurse(.children[]?)|.type == "crypt") ]'
register: cryptdisks
- name: backup luks2 headers
become: true
loop: "{{ cryptdisks.stdout }}"
shell: |
rm -f {{ backup_directory }}/disks/{{ item.children[0].name | basename }}.luks2header
cryptsetup luksHeaderBackup {{ item.name }} \
--header-backup-file {{ backup_directory }}/disks/{{ item.children[0].name | basename }}.luks2header
- name: backup lvm volume groups
become: true
shell: |
if [ ! -d /etc/lvm/backup ]; then exit 0; fi
for vg in /etc/lvm/backup/*; do
cp $vg {{backup_directory}}/disks/${vg##*/}.volumegroup
done
# get list of disks
# run sfdisk on it
# get list of partitions with luks2
# # backup their headers
# get list of partitions with lvm2
# # copy the metadata