Skip to content

Instantly share code, notes, and snippets.

@buth
Created July 15, 2015 18:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buth/df5736266dc99ca09964 to your computer and use it in GitHub Desktop.
Save buth/df5736266dc99ca09964 to your computer and use it in GitHub Desktop.
Autmoatically format and mount a drive with CoreOS Cloud-Config
#cloud-config
coreos:
units:
- name: format-drive.service
command: start
content: |
[Unit]
Description=Formats the drive
After=dev-xvdc.device
Requires=dev-xvdc.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bash -c 'if [ "$(blkid -s TYPE -o value /dev/xvdc)" != "ext4" ]; then /usr/sbin/mkfs.ext4 /dev/xvdc; fi'
- name: etc-drive.mount
command: start
content: |
[Unit]
Description=Mount the drive to /etc/drive
Requires=format-vault.service
After=format-vault.service
[Mount]
What=/dev/xvdc
Where=/etc/drive
Type=ext4
@mgalgs
Copy link

mgalgs commented Mar 11, 2017

Was the format-vault in the second unit actually supposed to be format-drive (the name of the first service)?

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