102 lines
3.0 KiB
YAML
102 lines
3.0 KiB
YAML
---
|
|
# ==============================================================================
|
|
# PLAY 1: Clean Local Build Directories
|
|
# ==============================================================================
|
|
- name: Clean Local Environment
|
|
hosts: localhost
|
|
connection: local
|
|
gather_facts: false
|
|
|
|
vars:
|
|
boot_artifacts_dir: "{{ playbook_dir }}/boot-artifacts"
|
|
ocp_install_dir: "{{ playbook_dir }}/ocp-install"
|
|
|
|
tasks:
|
|
- name: Remove stale local directories
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- "{{ boot_artifacts_dir }}"
|
|
- "{{ ocp_install_dir }}"
|
|
|
|
|
|
# ==============================================================================
|
|
# PLAY 2: Wipe Node Disks and Shutdown
|
|
# ==============================================================================
|
|
- name: Wipe Disks and Shutdown Nodes
|
|
hosts: ocp_nodes
|
|
remote_user: core
|
|
become: true
|
|
gather_facts: false
|
|
|
|
vars:
|
|
vault_dir: "{{ playbook_dir }}/vault_vars"
|
|
ansible_ssh_private_key_file: "/tmp/node_ssh_key"
|
|
# Ignore host key checking and bypass known_hosts verification
|
|
ansible_ssh_common_args: "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
|
|
|
|
vars_files:
|
|
- "{{ vault_dir }}/ssh-key.yml"
|
|
|
|
pre_tasks:
|
|
- name: Write private SSH key to local temporary file
|
|
ansible.builtin.copy:
|
|
content: "{{ vault_ssh_private_key }}"
|
|
dest: "/tmp/node_ssh_key"
|
|
mode: '0600'
|
|
delegate_to: localhost
|
|
run_once: true
|
|
|
|
tasks:
|
|
- name: Execute disk wipe script on node
|
|
ansible.builtin.shell: |
|
|
for DISK in /dev/vda; do
|
|
if [ -b "$DISK" ]; then
|
|
echo "Wiping ${DISK}"
|
|
for gb in 0 1 10 100 1000; do
|
|
dd if=/dev/zero of="$DISK" bs=1K count=400 oflag=direct seek=$((gb * 1024**2)) 2>/dev/null || true
|
|
done
|
|
wipefs -af "$DISK" || true
|
|
fi
|
|
done
|
|
|
|
for DISK in /dev/nvme0n1; do
|
|
if [ -b "$DISK" ]; then
|
|
echo "Wiping ${DISK}"
|
|
for gb in 0 1 10 100 1000; do
|
|
dd if=/dev/zero of="$DISK" bs=1K count=400 oflag=direct seek=$((gb * 1024**2)) 2>/dev/null || true
|
|
done
|
|
wipefs -af "$DISK" || true
|
|
fi
|
|
done
|
|
|
|
for DISK in /dev/nvme1n1; do
|
|
if [ -b "$DISK" ]; then
|
|
echo "Wiping ${DISK}"
|
|
for gb in 0 1 10 100 1000; do
|
|
dd if=/dev/zero of="$DISK" bs=1K count=400 oflag=direct seek=$((gb * 1024**2)) 2>/dev/null || true
|
|
done
|
|
wipefs -af "$DISK" || true
|
|
fi
|
|
done
|
|
args:
|
|
executable: /bin/bash
|
|
ignore_errors: true
|
|
ignore_unreachable: true
|
|
|
|
- name: Initiate node shutdown
|
|
ansible.builtin.command: /sbin/poweroff
|
|
async: 1
|
|
poll: 0
|
|
ignore_errors: true
|
|
ignore_unreachable: true
|
|
|
|
post_tasks:
|
|
- name: Clean up temporary SSH private key file
|
|
ansible.builtin.file:
|
|
path: "/tmp/node_ssh_key"
|
|
state: absent
|
|
delegate_to: localhost
|
|
run_once: true
|