Ansible 101: Configuration LVM on Linux !!!
How to Configure LVM on Linux by Ansible:
1- Install ansible on Centos:
[root@cloud ~]# yum install -y ansible
2- create inventory hosts:
[root@cloud ~]# vim /etc/ansible/hosts
[vmware]
192.168.17.20
Note: We need Create LVM on one machine. can add any IPs of machines in hosts file
3- Create YAML file:
[root@cloud ansible]# vim /etc/ansible/lvm.yaml
#########
---
- hosts: vmware
user: root
tasks:
- name: vgcreate
lvg:
vg: vgdata
pvs: /dev/sdb1
- name: lvcreate
lvol:
vg: vgdata
lv: dataone
size: 1500M
- name: create file system
filesystem:
fstype: ext4
dev: /dev/vgdata/dataone
- name: mount logical volume
mount:
name: /lvdata
src: /dev/vgdata/dataone
fstype: ext4
state: mounted
4- Run YAML file by ansible:
[root@cloud ansible]# ansible-playbook -s lvm.yaml
On target machine:
Display Volume Group:
Display Physical Volume:
Display Logical Volume:
--------------------------------------------------------------------------------------------------------------------Good Luck https://www.linkedin.com/in/ahmedms/
Comments
Post a Comment