Created
July 15, 2015 18:17
-
-
Save buth/df5736266dc99ca09964 to your computer and use it in GitHub Desktop.
Autmoatically format and mount a drive with CoreOS Cloud-Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was the
format-vault
in the second unit actually supposed to beformat-drive
(the name of the first service)?