storage.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ---
  2. - name: Ensure Apache Storage Configuration
  3. hosts: webservers
  4. vars_files:
  5. - storage_vars.yml
  6. tasks:
  7. - name: correct partitions in /dev/vdb
  8. parted:
  9. device: /dev/vdb
  10. state: present
  11. number: "{{ item.number }}"
  12. part_start: "{{ item.start }}"
  13. part_end: "{{ item.end }}"
  14. loop: "{{ partitions }}"
  15. - name: Ensure Volume Groups Exist
  16. lvg:
  17. vg: "{{ item.name }}"
  18. pvs: "{{ item.devices }}"
  19. loop: "{{ volume_groups }}"
  20. - name: Create each Logical Volume (LV) if needed
  21. lvol:
  22. vg: "{{ item.vgroup }}"
  23. lv: "{{ item.name }}"
  24. size: "{{ item.size }}"
  25. loop: "{{ logical_volumes }}"
  26. when: item.name not in ansible_lvm["lvs"]
  27. - name: Ensure XFS Filesystem exists on each LV
  28. filesystem:
  29. dev: "/dev/{{item.vgroup }}/{{ item.name }}"
  30. fstype: xfs
  31. loop: "{{ logical_volumes }}"
  32. - name: Ensure the correct capacity for each LV
  33. lvol:
  34. vg: "{{ item.vgroup }}"
  35. lv: "{{ item.name }}"
  36. size: "{{ item.size }}"
  37. resizefs: yes
  38. force: yes
  39. loop: "{{ logical_volumes }}"
  40. - name: Each Logical Volume is mounted
  41. mount:
  42. path: "{{ item.mount_path }}"
  43. src: "/dev/{{ item.vgroup }}/{{ item.name}}"
  44. fstype: xfs
  45. opts: noatime
  46. state: mounted
  47. loop: "{{ logical_volumes }}"