first commit
This commit is contained in:
commit
d1d99b2f17
|
@ -0,0 +1,72 @@
|
|||
Role Name
|
||||
=========
|
||||
|
||||
Role to manage LVM Groups/Logical Volumes. Can be used to create, extend or resize LVM.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Devices/disks to be part of the LVM setup must be identified prior to using this role. Ensure that you select the correct devices/disks.
|
||||
|
||||
##### Creating LVM
|
||||
###### /dev/sda5
|
||||
|
||||
##### Extending LVM
|
||||
###### Current disk /dev/sda5
|
||||
###### New Disk /dev/sdb
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
````
|
||||
---
|
||||
# defaults file for ansible-manage-lvm
|
||||
create_lvm: false #defines if lvm should be created when adding additional disks...should be defined in host_vars/host (do not set extend or resize to true)
|
||||
create_lvname: test-lv #define lvm name when adding additional disks...should be defined in host_vars/host
|
||||
create_lvsize: 100%FREE #defines the lvm lv size --- (10G) - would create new lvm with 10Gigabytes -- (512) - would create new lvm with 512m
|
||||
create_vgname: test-vg #defines the lvm vg name to create...
|
||||
extend_lvm: false #defines if lvm vg should be extended (do not set create to true)...should be defined in host_vars/host
|
||||
extend_lvname: test-lv #defines the lvm lv name to extend...should be defined in host_vars/host
|
||||
extend_vgname: test-vg #defines the lvm vg name to extend...should be defined in host_vars/host
|
||||
lvextend_options: '-L+10G' #defines the options to pass to lvextend --- ('-L+10G') - would increase by 10GB whereas ('-l +100%FREE') would increase to full capacity
|
||||
lvm_current_disk: /dev/sda5 #defines the disk currently configured for lvm...should be defined in host_vars/host
|
||||
lvm_extend_disks: '{{ lvm_current_disk }},{{ lvm_new_disk }}' #defines the disks to extend in lvm group...should be defined in host_vars/host
|
||||
lvm_filesystem: ext4 #defines the filesystem type to create when configuring lvm ( ext3, ext4, xfs, etc. )...should be defined in host_vars/host
|
||||
lvm_new_disk: /dev/sdb #defines the new disk being added to volume group...should be defined in host_vars/host
|
||||
lvm_new_mntp: /mnt/test #defines the desired mount point to be created and new logical volume to be mounted to...should be defined in host_vars/host
|
||||
resize_lvm: false #set to true if resizing the logical volume (do not set create to true)...should be defined in host_vars/host
|
||||
resize_lvname: test-lv #defines the logical volume name to resize...should be defined in host_vars/host
|
||||
resize_vgname: test-vg #defines the volume group name to resize...should be defined in host_vars/host
|
||||
````
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
#### Galaxy
|
||||
-----------
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: mrlesmithjr.manage-lvm }
|
||||
#### GitHub
|
||||
-----------
|
||||
- hosts: servers
|
||||
roles:
|
||||
- ansible-manage-lvm
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Larry Smith Jr.
|
||||
- @mrlesmithjr
|
||||
- http://everythingshouldbevirtual.com
|
||||
- mrlesmithjr [at] gmail.com
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
# defaults file for ansible-manage-lvm
|
||||
create_lvm: false #defines if lvm should be created when adding additional disks...should be defined in host_vars/host (do not set extend or resize to true)
|
||||
create_lvname: test-lv #define lvm name when adding additional disks...should be defined in host_vars/host
|
||||
create_lvsize: 100%FREE #defines the lvm lv size --- (10G) - would create new lvm with 10Gigabytes -- (512) - would create new lvm with 512m
|
||||
create_vgname: test-vg #defines the lvm vg name to create...
|
||||
extend_lvm: false #defines if lvm vg should be extended (do not set create to true)...should be defined in host_vars/host
|
||||
extend_lvname: test-lv #defines the lvm lv name to extend...should be defined in host_vars/host
|
||||
extend_vgname: test-vg #defines the lvm vg name to extend...should be defined in host_vars/host
|
||||
lvextend_options: '-L+10G' #defines the options to pass to lvextend --- ('-L+10G') - would increase by 10GB whereas ('-l +100%FREE') would increase to full capacity
|
||||
lvm_current_disk: /dev/sda5 #defines the disk currently configured for lvm...should be defined in host_vars/host
|
||||
lvm_extend_disks: '{{ lvm_current_disk }},{{ lvm_new_disk }}' #defines the disks to extend in lvm group...should be defined in host_vars/host
|
||||
lvm_filesystem: ext4 #defines the filesystem type to create when configuring lvm ( ext3, ext4, xfs, etc. )...should be defined in host_vars/host
|
||||
lvm_new_disk: /dev/sdb #defines the new disk being added to volume group...should be defined in host_vars/host
|
||||
lvm_new_mntp: /mnt/test #defines the desired mount point to be created and new logical volume to be mounted to...should be defined in host_vars/host
|
||||
resize_lvm: false #set to true if resizing the logical volume (do not set create to true)...should be defined in host_vars/host
|
||||
resize_lvname: test-lv #defines the logical volume name to resize...should be defined in host_vars/host
|
||||
resize_vgname: test-vg #defines the volume group name to resize...should be defined in host_vars/host
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# handlers file for ansible-manage-lvm
|
|
@ -0,0 +1,139 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description:
|
||||
company: your company (optional)
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
# Some suggested licenses:
|
||||
# - BSD (default)
|
||||
# - MIT
|
||||
# - GPLv2
|
||||
# - GPLv3
|
||||
# - Apache
|
||||
# - CC-BY
|
||||
license: license (GPLv2, CC-BY, etc)
|
||||
min_ansible_version: 1.2
|
||||
#
|
||||
# Below are all platforms currently available. Just uncomment
|
||||
# the ones that apply to your role. If you don't see your
|
||||
# platform on this list, let us know and we'll get it added!
|
||||
#
|
||||
#platforms:
|
||||
#- name: EL
|
||||
# versions:
|
||||
# - all
|
||||
# - 5
|
||||
# - 6
|
||||
# - 7
|
||||
#- name: GenericUNIX
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 16
|
||||
# - 17
|
||||
# - 18
|
||||
# - 19
|
||||
# - 20
|
||||
# - 21
|
||||
# - 22
|
||||
#- name: Windows
|
||||
# versions:
|
||||
# - all
|
||||
# - 2012R2
|
||||
#- name: SmartOS
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: opensuse
|
||||
# versions:
|
||||
# - all
|
||||
# - 12.1
|
||||
# - 12.2
|
||||
# - 12.3
|
||||
# - 13.1
|
||||
# - 13.2
|
||||
#- name: Amazon
|
||||
# versions:
|
||||
# - all
|
||||
# - 2013.03
|
||||
# - 2013.09
|
||||
#- name: GenericBSD
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: FreeBSD
|
||||
# versions:
|
||||
# - all
|
||||
# - 8.0
|
||||
# - 8.1
|
||||
# - 8.2
|
||||
# - 8.3
|
||||
# - 8.4
|
||||
# - 9.0
|
||||
# - 9.1
|
||||
# - 9.1
|
||||
# - 9.2
|
||||
#- name: Ubuntu
|
||||
# versions:
|
||||
# - all
|
||||
# - lucid
|
||||
# - maverick
|
||||
# - natty
|
||||
# - oneiric
|
||||
# - precise
|
||||
# - quantal
|
||||
# - raring
|
||||
# - saucy
|
||||
# - trusty
|
||||
# - utopic
|
||||
# - vivid
|
||||
#- name: SLES
|
||||
# versions:
|
||||
# - all
|
||||
# - 10SP3
|
||||
# - 10SP4
|
||||
# - 11
|
||||
# - 11SP1
|
||||
# - 11SP2
|
||||
# - 11SP3
|
||||
#- name: GenericLinux
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: Debian
|
||||
# versions:
|
||||
# - all
|
||||
# - etch
|
||||
# - jessie
|
||||
# - lenny
|
||||
# - squeeze
|
||||
# - wheezy
|
||||
#
|
||||
# Below are all categories currently available. Just as with
|
||||
# the platforms above, uncomment those that apply to your role.
|
||||
#
|
||||
#categories:
|
||||
#- cloud
|
||||
#- cloud:ec2
|
||||
#- cloud:gce
|
||||
#- cloud:rax
|
||||
#- clustering
|
||||
#- database
|
||||
#- database:nosql
|
||||
#- database:sql
|
||||
#- development
|
||||
#- monitoring
|
||||
#- networking
|
||||
#- packaging
|
||||
#- system
|
||||
#- web
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line.
|
||||
# Be sure to remove the '[]' above if you add dependencies
|
||||
# to this list.
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: centos | installing lvm2
|
||||
yum:
|
||||
name: system-storage-manager
|
||||
state: present
|
||||
|
||||
- name: centos | installing sg3_utils
|
||||
yum:
|
||||
name: sg3_utils
|
||||
state: present
|
||||
|
||||
- name: centos | checking for scsi devices
|
||||
shell: sg_scan
|
||||
register: scsi_devices
|
||||
changed_when: False
|
||||
|
||||
- name: centos | rescanning for new disks
|
||||
command: /usr/bin/rescan-scsi-bus.sh
|
||||
changed_when: False
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- name: create_lvm | creating new LVM volume group
|
||||
lvg:
|
||||
vg: "{{ create_vgname }}"
|
||||
pvs: "{{ lvm_new_disk }}"
|
||||
state: present
|
||||
|
||||
- name: create_lvm | creating new LVM logical volume
|
||||
lvol:
|
||||
vg: "{{ create_vgname }}"
|
||||
lv: "{{ create_lvname }}"
|
||||
size: "{{ create_lvsize }}"
|
||||
|
||||
- name: create_lvm | creating new filesystem on new LVM logical volume
|
||||
filesystem:
|
||||
fstype: "{{ lvm_filesystem }}"
|
||||
dev: "/dev/{{ create_vgname }}/{{ create_lvname }}"
|
||||
|
||||
- name: create_lvm | mounting new filesystem
|
||||
mount:
|
||||
name: "{{ lvm_new_mntp }}"
|
||||
src: "/dev/{{ create_vgname }}/{{ create_lvname }}"
|
||||
fstype: "{{ lvm_filesystem }}"
|
||||
state: mounted
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
- name: debian | installing pre-reqs
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- lvm2
|
||||
- scsitools
|
||||
- xfsprogs
|
||||
|
||||
- name: debian | checking for scsi devices
|
||||
shell: sg_scan
|
||||
register: scsi_devices
|
||||
changed_when: False
|
||||
|
||||
- name: debian | rescanning for new disks added
|
||||
command: /sbin/rescan-scsi-bus
|
||||
changed_when: False
|
||||
when: scsi_devices.stdout != ""
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- name: extend_lvm | extending existing LVM volume group
|
||||
lvg:
|
||||
vg: "{{ extend_vgname }}"
|
||||
pvs: "{{ lvm_extend_disks }}"
|
||||
|
||||
- name: extend_lvm | extending existing filesystem
|
||||
command: lvextend {{ lvextend_options }} /dev/{{ extend_vgname }}/{{ extend_lvname }}
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
# tasks file for ansible-manage-lvm
|
||||
- include: debian.yml
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- include: centos.yml
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- include: create_lvm.yml
|
||||
when: create_lvm is defined and create_lvm
|
||||
|
||||
- include: extend_lvm.yml
|
||||
when: extend_lvm is defined and extend_lvm
|
||||
|
||||
- include: resize_lvm.yml
|
||||
when: resize_lvm is defined and resize_lvm
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- name: resize_lvm | resizing filesystem
|
||||
command: resize2fs /dev/{{ resize_vgname }}/{{ resize_lvname }}
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
# vars file for ansible-manage-lvm
|
Loading…
Reference in New Issue