Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Instructions:
# 1. save this file somewhere, for example /home/stack/ceph_wipe_disk.yaml
# 2. create an empty ceph_wipe_env.yaml with the following contents:
#
# resource_registry:
# OS::TripleO::NodeUserData: /home/stack/ceph_wipe_disk.yaml
# parameter_defaults:
# ceph_disks: "/dev/sdb /dev/sdc"
#
# 3. when deploying, add to the CLI command the following argument:
#
# -e /path/to/ceph_wipe_env.yaml
heat_template_version: 2014-10-16
parameters:
ceph_disks:
type: string
description: A list of block devices to be cleared with an empty GPT label.
default: "/dev/sdb /dev/sdc"
description: >
This is an example showing how you can clear the cephstorage nodes disk with an empty GPT label on firstboot.
resources:
userdata:
type: OS::Heat::MultipartMime
properties:
parts:
- config: {get_resource: wipe_disk}
wipe_disk:
type: OS::Heat::SoftwareConfig
properties:
config:
str_replace:
template: |
#!/bin/bash
case "$(hostname)" in
*cephstorage*)
for d in $disks; do
if [ -b ${d} ]; then
echo "Wiping disk ${d} ..."
sgdisk -Z ${d}
sgdisk -o ${d}
fi
done
;;
esac
params:
$disks: {get_param: ceph_disks}
outputs:
OS::stack_id:
value: {get_resource: userdata}
@cybertron

Note that this will only work if the user hasn't renamed their ceph nodes. If someone sets their ceph hostname format to my-super-awesome-ceph-node-%index% this isn't going to work properly.

Also, is there any way we could avoid duplicating the disk list? That information should already be available in the ceph metadata, shouldn't it?

@gfidente
Owner
gfidente commented Dec 2, 2015

hi, I think best option to make sure this is applied only on the relevant nodes is to add role-specific NodeUserData in the parent templates, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment