Hi All,
Looking for some help with looping while creating multiple filesystems with
different sizes and mount points.
There are too many volumes, filesystems and mount points that need to be
created for one vol group. The file becomes too big so want some help with
looping.
test_lvm.yml
- name: Creating new LVM volume group
sudo: yes
lvg:
vg: "{{lvm_volume_group}}"
pvs: "{{lvm_physical_volumes}}"
state: present
when: lvm_create
- name: Creating new LVM logical volume
sudo: yes
lvol:
vg: "{{lvm_volume_group}}"
lv: "{{item.v1}}"
size: "{{item.s1}}"
shrink: "{{item.shrink}}"
with_items: "{{lvm_logical_volumes}}"
when: lvm_create
- name: Creating new filesystem on new LVM logical volume
sudo: yes
filesystem:
fstype: "{{item.filesystem}}"
dev: "/dev/{{lvm_volume_group}}/{{item.volume}}"
with_items: "{{lvm_logical_volumes}}"
when: lvm_create
- name: Mounting new filesystem
sudo: yes
mount:
name: "{{item.mount_path}}"
src: "/dev/{{lvm_volume_group}}/{{item.volume}}"
fstype: "{{item.filesystem}}"
opts: "{{item.mount_opts | default('defaults')}}"
state: "mounted"
with_items: "{{lvm_logical_volumes}}"
when: lvm_create
main.yml
lvm_physical_volumes: "/dev/sdc,/dev/sdd"
lvm_volume_group: "dataVG"
lvm_logical_volumes:
- v1: data1lv
filesystem: xfs
m1: "/data1"
s1: "1"
mount_opts: noatime
- v2: data2lv
filesystem: xfs
m2: "/data2"
s1: "1"
mount_opts: noatime
- v3: data3lv
filesystem: xfs
m3: "/data3"
s1: "1"
mount_opts: noatime
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ca67aa3b-4301-443d-bb69-330b4e6b3536%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.