-
Notifications
You must be signed in to change notification settings - Fork 2
/
playbook_partition.yml
86 lines (73 loc) · 1.85 KB
/
playbook_partition.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
- name: all playbook
hosts: all
vars:
data_raw_size: "20.00 GB"
arch_raw_size: "20.00 GB"
tasks:
- set_fact:
disks: "{{ ansible_devices.keys() | list }}"
- set_fact:
usable_disks: "{{ disks |select('match', '^(s|v)d+') | list }}"
- set_fact:
data_raw_disk_name: "{{ item }}"
when:
- "ansible_devices.{{ item }}.partitions.keys() |list | length <= 0"
- ansible_devices.{{ item }}.size == "{{ data_raw_size }}"
with_items:
- "{{ usable_disks }}"
- parted:
device: "/dev/{{ data_raw_disk_name }}"
number: 1
state: present
part_end: 25%
- parted:
device: "/dev/{{ data_raw_disk_name }}"
number: 2
state: present
part_start: 25%
part_end: 50%
- parted:
device: "/dev/{{ data_raw_disk_name }}"
number: 3
state: present
part_start: 50%
part_end: 75%
- parted:
device: "/dev/{{ data_raw_disk_name }}"
number: 4
state: present
part_start: 75%
part_end: 100%
- name: Collect only facts returned by facter
setup:
- set_fact:
arch_raw_disk_name: "{{ item }}"
when:
- "ansible_devices.{{ item }}.partitions.keys() |list | length <= 0"
- ansible_devices.{{ item }}.size == "{{ arch_raw_size }}"
with_items:
- "{{ usable_disks }}"
- parted:
device: "/dev/{{ arch_raw_disk_name }}"
number: 1
state: present
part_end: 25%
- parted:
device: "/dev/{{ arch_raw_disk_name }}"
number: 2
state: present
part_start: 25%
part_end: 50%
- parted:
device: "/dev/{{ arch_raw_disk_name }}"
number: 3
state: present
part_start: 50%
part_end: 75%
- parted:
device: "/dev/{{ arch_raw_disk_name }}"
number: 4
state: present
part_start: 75%
part_end: 100%