-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
58 lines (53 loc) · 1.57 KB
/
playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
- hosts: all
gather_facts: no
become: yes
vars:
data_disk_device: /dev/vdb
tasks:
#
# intialize the data disk.
# NB to re-test this block use following commands to wipe/delete
# all the filesystems and partitions/labels:
# umount /data; wipefs --all $(ls -1 /dev/vdb* | grep -E '[0-9]+$') /dev/vdb; sed -i -E '/^\/dev\/vdb.+/d' /etc/fstab
- name: Intialize the data disk
block:
- name: Partition the data disk
community.general.parted:
device: '{{ data_disk_device }}'
number: 1
label: gpt
name: data
state: present
- name: Create the data filesystem
community.general.filesystem:
dev: '{{ data_disk_device }}1'
fstype: ext4
opts: -L data
- name: Mount the data filesystem
ansible.posix.mount:
src: '{{ data_disk_device }}1'
path: /data
fstype: ext4
opts: defaults,nodev
state: mounted
- name: Get summary
args:
executable: /bin/bash
shell: |
exec 2>&1
function title {
echo
echo '#'
echo "# $*"
echo '#'
echo
}
title data disk device
lsblk -x KNAME -o KNAME,SIZE,TRAN,SUBSYSTEMS,FSTYPE,UUID,LABEL,MODEL,SERIAL {{ data_disk_device }}
title data disk partitions
parted {{ data_disk_device }} print
register: summary
changed_when: false
- name: Show summary
debug:
var: summary.stdout