Some days back, I gave some explanations about LVM such as creations of LVM partitions and a detailed analogy of the LVM structure as well as tips for using PVMOVE. We can also automate such task using the power of Ansible. Cool isn’t it?
So, I have my two hosts Ansible1 and Ansible2. Ansible1 is the controller and has Ansible installed and Ansible2 is the hosts that the disk will be added to the LVM.
1. Here is the status of the disk of Ansible2 where a disk /dev/sdc has been added
2. I have now added a disk of 1GB from the VirtualBox settings. You can refer to the past article on LVM how to add the disk. As we can see on the screenshot below it shows the disk sdc with the size 1GB added on the machine Ansible2 which I have formatted as LVM
4. Lets now get into the controller machine – Ansible1 and prepare our Playbook. You can view it on my Git account here. The aim is to get a 500Mb from the /dev/sdc1 to create a new VG called vgdata in the LV called lvdisk.
5. Here is the output
Articles on LVM
- Managing LVM with PVMOVE – Part1
- Managing LVM with PVMOVE – Part2
- Add an extend disk on VirtualBox through LVM
- Move your /home to a new LVM partition
Articles on Ansible
- Some fun with Ansible Playbooks
- Getting started with Ansible deployment
- Update Glibc and restart BIND with Ansible