Created
March 8, 2023 03:55
-
-
Save acmiyaguchi/dd55b6261a8d0d3efbb8ac0cd21f307a to your computer and use it in GitHub Desktop.
configure local-ssd on gcp via ansible
This file contains 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
- name: set ssd mount point variable | |
set_fact: | |
ssd_mount_point: /mnt/ssd | |
ssd_device: /dev/sdb | |
- name: check if ssd is mounted | |
become: true | |
shell: mount | grep {{ ssd_mount_point }} | |
register: ssd_mounted | |
ignore_errors: true | |
- name: configure local-ssd | |
become: true | |
when: ssd_mounted.rc != 0 | |
block: | |
- name: format local-ssd | |
shell: mkfs.ext4 -F {{ ssd_device }} | |
- name: create local-ssd mount point | |
file: | |
path: "{{ ssd_mount_point }}" | |
state: directory | |
- name: mount local-ssd | |
mount: | |
path: "{{ ssd_mount_point }}" | |
src: "{{ ssd_device }}" | |
fstype: ext4 | |
state: mounted | |
- name: add fstab entry for local-ssd | |
lineinfile: | |
path: /etc/fstab | |
line: "{{ ssd_device }} {{ ssd_mount_point }} ext4 defaults 0 0" | |
state: present | |
create: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment