110 lines
2.7 KiB
YAML
110 lines
2.7 KiB
YAML
|
---
|
||
|
- name: Prepare data disk
|
||
|
hosts: all
|
||
|
|
||
|
environment:
|
||
|
http_proxy: "{{ lookup('env','http_proxy') }}"
|
||
|
https_proxy: "{{ lookup('env','https_proxy') }}"
|
||
|
HTTPS_PROXY: "{{ lookup('env','HTTPS_PROXY') }}"
|
||
|
HTTP_PROXY: "{{ lookup('env','HTTP_PROXY') }}"
|
||
|
|
||
|
vars:
|
||
|
fsconf:
|
||
|
vgn: "{{ lookup('env', 'vgname') }}"
|
||
|
lvs: "{{ lookup('env', 'lvnames').split(' ') }}"
|
||
|
szs: "{{ lookup('env', 'lvsizes').split(' ') }}"
|
||
|
fss: "{{ lookup('env', 'lvfssys').split(' ') }}"
|
||
|
mps: "{{ lookup('env', 'lvmntps').split(' ') }}"
|
||
|
|
||
|
tasks:
|
||
|
|
||
|
- name: GrowPart
|
||
|
command: "growpart /dev/vda 4"
|
||
|
environment:
|
||
|
LC_ALL: C
|
||
|
|
||
|
- name: Resize main vg
|
||
|
lvg:
|
||
|
vg: "{{ fsconf.vgn }}"
|
||
|
pvs: /dev/vda4
|
||
|
pvresize: yes
|
||
|
|
||
|
- name: Create logical volumes.
|
||
|
lvol:
|
||
|
vg: "{{ fsconf.vgn }}"
|
||
|
lv: "{{ item }}"
|
||
|
size: "{{ fsconf.szs[idx] }}"
|
||
|
active: yes
|
||
|
force: no
|
||
|
state: present
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Create filesystems
|
||
|
filesystem:
|
||
|
fstype: "{{ fsconf.fss[idx] }}"
|
||
|
dev: "/dev/{{ fsconf.vgn }}/{{ item }}"
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Find what to backup
|
||
|
stat:
|
||
|
path: "{{ item }}"
|
||
|
with_items: "{{ fsconf.mps }}"
|
||
|
register: mountPoints
|
||
|
|
||
|
|
||
|
- name: Create mount points
|
||
|
file:
|
||
|
path: "{{ fsconf.mps[idx] }}"
|
||
|
state: directory
|
||
|
mode: '0755'
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Create temporary mount points
|
||
|
file:
|
||
|
path: "/tmp{{ fsconf.mps[idx] }}"
|
||
|
state: directory
|
||
|
mode: '0755'
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Mount fs in temporary mount points
|
||
|
command: mount /dev/{{ fsconf.vgn }}/"{{ item }}" "/tmp{{ fsconf.mps[idx] }}"
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Configure filesystems create entry in fstab
|
||
|
mount:
|
||
|
path: "{{ fsconf.mps[idx] }}"
|
||
|
src: /dev/{{ fsconf.vgn }}/{{ item }}
|
||
|
state: present
|
||
|
fstype: "{{ fsconf.fss[idx] }}"
|
||
|
loop: "{{ fsconf.lvs }}"
|
||
|
loop_control:
|
||
|
index_var: idx
|
||
|
|
||
|
- name: Fill new mount points if exists
|
||
|
become: true
|
||
|
delegate_to: "{{ inventory_hostname }}"
|
||
|
synchronize:
|
||
|
mode: push
|
||
|
src: "{{ item.item }}/"
|
||
|
dest: "/tmp{{ item.item }}/"
|
||
|
times: yes
|
||
|
perms: yes
|
||
|
owner: yes
|
||
|
group: yes
|
||
|
links: yes
|
||
|
recursive: yes
|
||
|
with_items: "{{ mountPoints.results }}"
|
||
|
when: item.stat.exists
|
||
|
|
||
|
|