73 lines
1.7 KiB
YAML
73 lines
1.7 KiB
YAML
---
|
|
- name: Prepare 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:
|
|
ds: "{{ lookup('env', 'disk') }}"
|
|
vg: "{{ lookup('env', 'vgname') }}"
|
|
lv: "{{ lookup('env', 'lvname') }}"
|
|
fs: "{{ lookup('env', 'fstype') }}"
|
|
sz: "{{ lookup('env', 'size') }}"
|
|
mp: "{{ lookup('env', 'mountp') }}"
|
|
|
|
tasks:
|
|
|
|
- name: Create the volume group.
|
|
lvg:
|
|
pvs: "{{ ds }}"
|
|
vg: "{{ vg }}"
|
|
pesize: "16"
|
|
pv_options: '-Z y'
|
|
force: no
|
|
state: present
|
|
|
|
- name: Create logical volume
|
|
lvol:
|
|
vg: "{{ vg }}"
|
|
lv: "{{ lv }}"
|
|
size: "{{ sz }}"
|
|
active: yes
|
|
force: no
|
|
state: present
|
|
|
|
- name: Create filesystem
|
|
filesystem:
|
|
fstype: "ext4"
|
|
dev: "/dev/{{ vg }}/{{ lv }}"
|
|
opts: -cc
|
|
|
|
- name: Create temporary mount points
|
|
file:
|
|
path: "/tmp{{ mp }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Mount fs in temporary mount points
|
|
command: mount /dev/"{{ vg }}"/"{{ lv }}" "/tmp{{ mp }}"
|
|
|
|
- name: Configure filesystems create entry in fstab
|
|
mount:
|
|
path: "{{ mp }}"
|
|
src: /dev/{{ vg }}/{{ lv }}
|
|
state: present
|
|
fstype: "{{ fs }}"
|
|
|
|
- name: Fill new mount points if exists
|
|
become: true
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
synchronize:
|
|
mode: push
|
|
src: "{{ mp }}/"
|
|
dest: "/tmp{{ mp }}/"
|
|
times: yes
|
|
perms: yes
|
|
owner: yes
|
|
group: yes
|
|
links: yes
|
|
recursive: yes |