16 Commits

Author SHA1 Message Date
Larry Smith Jr
25dc548acb Merge pull request #18 from mrlesmithjr/fix-travis-testing
Fix travis testing
2018-12-05 09:24:37 -05:00
Larry Smith Jr
b3ef85d4f7 Added skip codes for ansible-lint 2018-12-05 08:39:10 -05:00
Larry Smith Jr
9f4afa7afb Fixing Travis testing and yamllint issues 2018-12-05 08:00:13 -05:00
Larry Smith Jr
5603c5f6b0 Added Travis testing and hooks for galaxy 2018-12-05 07:51:31 -05:00
Larry Smith Jr
118ec79cb0 Merge pull request #17 from stackhpc/no-filesystem
Support not formatting volumes.
2018-11-01 07:57:26 -04:00
Mark Goddard
563aa1effb Fix indentation 2018-10-31 11:42:20 +00:00
Mark Goddard
4a58cb36cf Update tasks/manage_lvm.yml
Co-Authored-By: oneswig <stig.github@telfer.org>
2018-10-31 11:16:27 +00:00
Stig Telfer
a0c784797f Support not formatting volumes.
Logic to make the filesystem attribute optional, in situations where
we do not want the volumes formatted.
2018-10-31 10:16:44 +01:00
Larry Smith Jr
51b79c5e71 Merge pull request #13 from davidcaste/feat/add-opts-mopts
Add opts and mopts support
2018-03-23 21:55:56 -04:00
David Castellanos
66368de1d3 Add opts and mopts support 2017-12-18 00:55:32 +01:00
Larry Smith Jr
075acb3484 Merge pull request #11 from mrlesmithjr/enhancement/#10
Addresses issue #10
2017-06-11 14:58:21 -04:00
Larry Smith Jr
386cc28bdb Addresses issue #10
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
2017-06-11 14:57:53 -04:00
Larry Smith Jr
26ed7d826c Merge pull request #9 from mrlesmithjr/fixes/issue#8
Fixes issue #8
2017-05-05 13:12:57 +00:00
Larry Smith Jr
0d255cb5ce Fixes issue #8
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
2017-05-05 09:12:25 -04:00
Larry Smith Jr
9844b5fd47 Merge pull request #7 from StefanHeimberg/feature/btrfs_support
added support for btrfs
2017-04-05 19:38:23 -04:00
Stefan Heimberg
f2d06d0d46 added support for btrfs 2017-04-06 00:25:55 +02:00
23 changed files with 630 additions and 283 deletions

0
.gitignore vendored Normal file
View File

61
.travis.yml Normal file
View File

@@ -0,0 +1,61 @@
---
language: python
python: "2.7"
# Use the new container infrastructure
sudo: required
services:
- docker
env:
- distribution: centos
init: /usr/lib/systemd/systemd
version: 7
- distribution: fedora
init: /usr/lib/systemd/systemd
version: 26
- distribution: fedora
init: /usr/lib/systemd/systemd
version: 25
- distribution: fedora
init: /usr/lib/systemd/systemd
version: 24
- distribution: ubuntu
init: /lib/systemd/systemd
version: bionic
- distribution: ubuntu
init: /lib/systemd/systemd
version: xenial
- distribution: ubuntu
init: /sbin/init
version: trusty
- distribution: debian
init: /lib/systemd/systemd
version: stretch
- distribution: debian
init: /lib/systemd/systemd
version: jessie
before_install:
- 'sudo pip install yamllint'
- yamllint -c .yamllint.yml .
- 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'
script:
- container_id=$(mktemp)
- role_name="ansible-manage-lvm"
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/${role_name}:ro ${distribution}-${version}:ansible ${init} > "${container_id}"'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-lint -c /.ansible-lint /etc/ansible/roles/${role_name}/tests/test.yml'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml --syntax-check'
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml'
- >
sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/${role_name}/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- 'sudo docker rm -f "$(cat ${container_id})"'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

58
.yamllint.yml Normal file
View File

@@ -0,0 +1,58 @@
---
extends: default
rules:
braces:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0
# Keeping 0 min-spaces to not error on empty collection definitions
min-spaces-inside: 0
# Allowing one space inside braces to improve code readability
max-spaces-inside: 1
brackets:
# Defaults
# min-spaces-inside: 0
# max-spaces-inside: 0
# Keeping 0 min-spaces to not error on empty collection definitions
min-spaces-inside: 0
# Allowing one space inside braces to improve code readability
max-spaces-inside: 1
colons:
# Defaults
# max-spaces-before: 0
# max-spaces-after: 1
max-spaces-before: 0
# Allowing more than one space for code readability
max-spaces-after: -1
comments:
# Defaults
# level: warning
# require-starting-space: true
# min-spaces-from-content: 2
# Disabling to allow for code comment blocks and #!/usr/bin/ansible-playbook
require-starting-space: false
indentation:
# Defaults
# spaces: consistent
# indent-sequences: true
# check-multi-line-strings: false
# Requiring 2 space indentation
spaces: 2
# Requiring consistent indentation within a file, either indented or not
indent-sequences: consistent
# Disabling due to copious amounts of long lines in the code which would
# require a code style change to resolve
line-length: disable
truthy: disable

188
README.md
View File

@@ -1,89 +1,135 @@
Role Name
=========
# Role Name
Role to manage LVM Groups/Logical Volumes. Can be used to create, extend or resize LVM Groups and volumes.
An [Ansible] role to manage LVM Groups/Logical Volumes.
Requirements
------------
> NOTE: Can be used to create, extend or resize LVM Groups and volumes.
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.
##### To only create an LVM VG w/out creating LVM LVOLS...define lvname w/ var as None as in the below example.
## Requirements
Role Variables
--------------
Devices/disks to be members of the LVM setup **must be** identified prior to
using this role.
````
> NOTE: Ensure that you select the correct devices/disks.
>
> NOTE: To create an LVM VG w/out creating LVM LVOLS...define lvname w/ var as
> `None` as in the below example.
## Role Variables
```yaml
---
# defaults file for ansible-manage-lvm
lvm_groups:
- vgname: ubuntu-vg
disks: /dev/sda5,/dev/sdc,/dev/sdd #for multiple disks...../dev/sdb,/dev/sdc
create: true #defines if VG should exist or be removed....true or false
lvnames:
- lvname: swap_1
size: 5g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: swap #defines filesystem to format lvol as
mount: false #defines if filesystem should be mounted
mntp: [] #defines mountpoint for lvol
- lvname: root
size: 40g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true
mntp: / #defines mountpoint for lvol
- vgname: test-vg
disks: /dev/sdb #for multiple disks...../dev/sdb,/dev/sdc
create: true #defines if VG should exist or be removed....true or false
lvnames:
- lvname: test_1
size: 5g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true #defines if filesystem should be mounted
mntp: /mnt/test_1 #defines mountpoint for lvol
- lvname: test_2
size: 10g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true
mntp: /mnt/test_2 #defines mountpoint for lvol
# - vgname: cinder-volumes
# disks: /dev/cciss/c0d1 #for multiple disks...../dev/sdb,/dev/sdc
# create: true #defines if VG should exist or be removed....true or false
# lvnames:
# - None #set to None to only create LVM VG w/out creating LVM LVOLS...
manage_lvm: false #defines if LVM will be managed by role....default is false to ensure nothing is changed by accident.
````
lvm_groups: []
# - vgname: ubuntu-vg
# disks:
# - /dev/sda5
# - /dev/sdc
# - /dev/sdd
# # defines if VG should exist or be removed
# # true or false
# create: true
# lvnames:
# - lvname: swap_1
# # Define size of lvol
# # 100%FREE, 10g, 1024 (megabytes by default)
# size: 5g
# # Defines additional lvcreate options (e.g. stripes, stripesize, etc)
# opts: ''
# # Defines if lvol should exist or be removed
# # true or false
# create: true
# # Defines filesystem to format lvol as
# filesystem: swap
# # Defines if filesystem should be mounted
# mount: false
# # Defines mountpoint for lvol
# mntp: []
# # Defines additional mount options (e.g. noatime, noexec, etc)
# mopts: ''
# - lvname: root
# size: 40g
# create: true
# filesystem: ext4
# mount: true
# mntp: /
# - vgname: test-vg
# disks:
# - /dev/sdb
# create: true
# lvnames:
# - lvname: test_1
# size: 5g
# create: true
# filesystem: ext4
# mount: true
# mntp: /mnt/test_1
# - lvname: test_2
# size: 10g
# create: true
# filesystem: ext4
# mount: true
# mntp: /mnt/test_2
# - vgname: cinder-volumes
# disks:
# - /dev/cciss/c0d1
# create: true
# lvnames:
# # Set to None to only create LVM VG w/out creating LVM LVOLS
# - None
Dependencies
------------
# Defines if LVM will be managed by role
# default is false to ensure nothing is changed by accident.
manage_lvm: false
```
## Dependencies
None
Example Playbook
----------------
## Example Playbook
#### Galaxy
-----------
- hosts: servers
roles:
- mrlesmithjr.manage-lvm
#### GitHub
-----------
- hosts: servers
roles:
- ansible-manage-lvm
```yaml
---
- hosts: test-nodes
vars:
lvm_groups:
- vgname: test-vg
disks:
- /dev/sdb
- /dev/sdc
create: true
lvnames:
- lvname: test_1
size: 5g
create: true
filesystem: ext4
mount: true
mntp: /mnt/test_1
- lvname: test_2
size: 10g
create: true
filesystem: ext4
mount: true
mntp: /mnt/test_2
manage_lvm: true
pri_domain_name: 'test.vagrant.local'
roles:
- role: ansible-manage-lvm
tasks:
```
License
-------
## License
BSD
Author Information
------------------
## Author Information
Larry Smith Jr.
- @mrlesmithjr
- http://everythingshouldbevirtual.com
- mrlesmithjr [at] gmail.com
- [@mrlesmithjr]
- <http://everythingshouldbevirtual.com>
- mrlesmithjr [at] gmail.com
[@mrlesmithjr]: https://www.twitter.com/mrlesmithjr
[ansible]: https://www.ansible.com

View File

@@ -1,41 +1,63 @@
---
# defaults file for ansible-manage-lvm
lvm_groups:
- vgname: ubuntu-vg
disks: /dev/sda5,/dev/sdc,/dev/sdd #for multiple disks...../dev/sdb,/dev/sdc
create: true #defines if VG should exist or be removed....true or false
lvnames:
- lvname: swap_1
size: 5g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: swap #defines filesystem to format lvol as
mount: false #defines if filesystem should be mounted
mntp: [] #defines mountpoint for lvol
- lvname: root
size: 40g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true
mntp: / #defines mountpoint for lvol
- vgname: test-vg
disks: /dev/sdb #for multiple disks...../dev/sdb,/dev/sdc
create: true #defines if VG should exist or be removed....true or false
lvnames:
- lvname: test_1
size: 5g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true #defines if filesystem should be mounted
mntp: /mnt/test_1 #defines mountpoint for lvol
- lvname: test_2
size: 10g #define size of lvol...100%FREE, 10g, 1024 (megabytes by default)
create: true #defines if lvol should exist or be removed...true or false
filesystem: ext4 #defines filesystem to format lvol as
mount: true
mntp: /mnt/test_2 #defines mountpoint for lvol
# - vgname: cinder-volumes
# disks: /dev/cciss/c0d1 #for multiple disks...../dev/sdb,/dev/sdc
# create: true #defines if VG should exist or be removed....true or false
# lvnames:
# - None #set to None to only create LVM VG w/out creating LVM LVOLS...
manage_lvm: false #defines if LVM will be managed by role....default is false to ensure nothing is changed by accident.
lvm_groups: []
# - vgname: ubuntu-vg
# disks:
# - /dev/sda5
# - /dev/sdc
# - /dev/sdd
# # defines if VG should exist or be removed
# # true or false
# create: true
# lvnames:
# - lvname: swap_1
# # Define size of lvol
# # 100%FREE, 10g, 1024 (megabytes by default)
# size: 5g
# # Defines additional lvcreate options (e.g. stripes, stripesize, etc)
# opts: ''
# # Defines if lvol should exist or be removed
# # true or false
# create: true
# # Defines filesystem to format lvol as
# filesystem: swap
# # Defines if filesystem should be mounted
# mount: false
# # Defines mountpoint for lvol
# mntp: []
# # Defines additional mount options (e.g. noatime, noexec, etc)
# mopts: ''
# - lvname: root
# size: 40g
# create: true
# filesystem: ext4
# mount: true
# mntp: /
# - vgname: test-vg
# disks:
# - /dev/sdb
# create: true
# lvnames:
# - lvname: test_1
# size: 5g
# create: true
# filesystem: ext4
# mount: true
# mntp: /mnt/test_1
# - lvname: test_2
# size: 10g
# create: true
# filesystem: ext4
# mount: true
# mntp: /mnt/test_2
# - vgname: cinder-volumes
# disks:
# - /dev/cciss/c0d1
# create: true
# lvnames:
# # Set to None to only create LVM VG w/out creating LVM LVOLS
# - None
# Defines if LVM will be managed by role
# default is false to ensure nothing is changed by accident.
manage_lvm: false

View File

@@ -2,137 +2,23 @@
galaxy_info:
author: Larry Smith Jr.
description: Role to manage LVM Groups/Logical Volumes. Can be used to create, extend or resize LVM.
#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.
#
- name: Debian
versions:
- jessie
- wheezy
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.

17
setup_travis_tests.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
TAR_FILE="v1.6.0.tar.gz"
# Prompt for Ansible role name
read -p "Enter the Ansible role name: " input
# Update .travis.yml with Ansible role name
sed -i '' "s/replace_role/${input}/g" ".travis.yml"
# Update tests/test.yml with Ansible role name
sed -i '' "s/replace_role/${input}/g" "tests/test.yml"
# Cleanup
if [ -f $TAR_FILE ]; then
rm $TAR_FILE
fi

View File

@@ -1,19 +1,23 @@
---
- name: centos | installing lvm2
yum:
name: lvm2
state: present
name: "lvm2"
state: "present"
become: true
- name: centos | installing sg3_utils
yum:
name: sg3_utils
state: present
name: "sg3_utils"
state: "present"
become: true
- name: centos | checking for scsi devices
shell: sg_scan
register: scsi_devices
shell: "sg_scan"
become: true
register: "scsi_devices"
changed_when: False
- name: centos | rescanning for new disks
command: /usr/bin/rescan-scsi-bus.sh
command: "/usr/bin/rescan-scsi-bus.sh"
become: true
changed_when: False

View File

@@ -2,18 +2,21 @@
- name: debian | installing pre-reqs
apt:
name: "{{ item }}"
state: present
state: "present"
become: true
with_items:
- lvm2
- scsitools
- xfsprogs
- lvm2
- scsitools
- xfsprogs
- name: debian | checking for scsi devices
shell: sg_scan
register: scsi_devices
shell: "sg_scan"
become: true
register: "scsi_devices"
changed_when: False
- name: debian | rescanning for new disks added
command: /sbin/rescan-scsi-bus
command: "/sbin/rescan-scsi-bus"
become: true
changed_when: False
when: scsi_devices.stdout != ""
when: scsi_devices['stdout'] != ""

View File

@@ -7,4 +7,6 @@
when: ansible_os_family == "RedHat"
- include: manage_lvm.yml
when: manage_lvm is defined and manage_lvm
when: >
manage_lvm and
lvm_groups is defined

View File

@@ -1,93 +1,162 @@
---
- name: manage_lvm | creating new LVM volume group(s)
lvg:
vg: "{{ item.vgname }}"
pvs: "{{ item.disks }}"
state: present
vg: "{{ item['vgname'] }}"
pvs: "{{ item['disks']|join(',') }}"
state: "present"
become: true
with_items: "{{ lvm_groups }}"
when: item.create is defined and item.create
when: >
(item['create'] is defined and
item['create'])
- name: manage_lvm | creating new LVM logical volume(s)
lvol:
vg: "{{ item.0.vgname }}"
lv: "{{ item.1.lvname }}"
size: "{{ item.1.size }}"
vg: "{{ item[0]['vgname'] }}"
lv: "{{ item[1]['lvname'] }}"
size: "{{ item[1]['size'] }}"
shrink: no
state: present
opts: "{{ item[1]['opts'] | default('') }}"
state: "present"
become: true
register: lvm
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: ( item.0.create is defined and item.0.create ) and ( item.1 is defined and item.1 != 'None' ) and ( item.1.create is defined and item.1.create )
when: >
((item[0]['create'] is defined
and item[0]['create']) and
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
item[1]['create']))
- name: manage_lvm | creating new filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ item.1.filesystem }}"
dev: "/dev/{{ item.0.vgname }}/{{ item.1.lvname }}"
# resizefs: yes #coming in 2.0 which will replace the resizing filesystem task below
fstype: "{{ item[1]['filesystem'] }}"
dev: "/dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}"
# resizefs: yes #coming in 2.0 which will replace the resizing filesystem task below
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: ( item.0.create is defined and item.0.create ) and ( item.1 is defined and item.1 != 'None' ) and ( item.1.create is defined and item.1.create )
when: >
((item[0]['create'] is defined and
item[0]['create']) and
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
item[1]['create']) and
(item[1]['filesystem'] is defined and
item[1]['filesystem'] != 'None'))
- name: manage_lvm | mounting new filesystem(s)
mount:
name: "{{ item.1.mntp }}"
src: "/dev/{{ item.0.vgname }}/{{ item.1.lvname }}"
fstype: "{{ item.1.filesystem }}"
state: mounted
name: "{{ item[1]['mntp'] }}"
src: "/dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}"
fstype: "{{ item[1]['filesystem'] }}"
state: "mounted"
opts: "{{ item[1]['mopts'] | default('defaults') }}"
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: ( item.0.create is defined and item.0.create ) and ( item.1 is defined and item.1 != 'None' ) and ( item.1.create is defined and item.1.create ) and ( item.1.mount is defined and item.1.mount )
when: >
((item[0]['create'] is defined and
item[0]['create']) and
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
item[1]['create']) and
(item[1]['mount'] is defined and
item[1]['mount']))
- name: manage_lvm | resizing filesystem
command: resize2fs /dev/{{ item.0.vgname }}/{{ item.1.lvname }}
command: resize2fs /dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: lvm.changed and item.1.filesystem != "swap" and item.1.filesystem != "xfs"
when: >
lvm['changed'] and
item[1]['filesystem'] is defined and
item[1]['filesystem'] != "None" and
item[1]['filesystem'] != "swap" and
item[1]['filesystem'] != "xfs" and
item[1]['filesystem'] != "btrfs"
- name: manage_lvm | resizing xfs
command: xfs_growfs -d /dev/{{ item.0.vgname }}/{{ item.1.lvname }}
command: xfs_growfs -d /dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: lvm.changed and item.1.filesystem == "xfs"
when: >
lvm['changed'] and
item[1]['filesystem'] is defined and
item[1]['filesystem'] == "xfs"
- name: manage_lvm | resizing swap
shell: "swapoff -a && mkswap /dev/{{ item.0.vgname }}/{{ item.1.lvname }} && swapon -va"
shell: "swapoff -a && mkswap /dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }} && swapon -va"
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: lvm.changed and item.1.filesystem == "swap"
when: >
lvm['changed'] and
item[1]['filesystem'] is defined and
item[1]['filesystem'] == "swap"
- name: manage_lvm | resizing btrfs
shell: "btrfs filesystem resize max {{ item[1]['mntp'] }}"
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: >
lvm['changed'] and
item[1]['filesystem'] is defined and
item[1]['filesystem'] == "btrfs"
- name: manage_lvm | unmounting filesystem(s)
mount:
name: "{{ item.1.mntp }}"
src: "/dev/{{ item.0.vgname }}/{{ item.1.lvname }}"
fstype: "{{ item.1.filesystem }}"
state: absent
name: "{{ item[1]['mntp'] }}"
src: "/dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}"
fstype: "{{ item[1]['filesystem'] | default(omit) }}"
state: "absent"
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: ( item.1 is defined and item.1 != 'None' ) and ( item.1.create is defined and not item.1.create )
when: >
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
not item[1]['create'])
- name: manage_lvm | Removing LVM logical volume(s)
lvol:
vg: "{{ item.0.vgname }}"
lv: "{{ item.1.lvname }}"
state: absent
vg: "{{ item[0]['vgname'] }}"
lv: "{{ item[1]['lvname'] }}"
state: "absent"
force: yes
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
when: ( item.1 is defined and item.1 != 'None' ) and ( item.1.create is defined and not item.1.create )
when: >
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
not item[1]['create'])
- name: manage_lvm | Removing LVM volume group(s)
lvg:
vg: "{{ item.vgname }}"
pvs: "{{ item.disks }}"
state: absent
vg: "{{ item['vgname'] }}"
pvs: "{{ item['disks']|join(',') }}"
state: "absent"
become: true
with_items: "{{ lvm_groups }}"
when: item.create is defined and not item.create
when: >
item['create'] is defined and
not item['create']

1
tests/.ansible-lint Normal file
View File

@@ -0,0 +1 @@
skip_list: ['305','503']

27
tests/Dockerfile.centos-7 Normal file
View File

@@ -0,0 +1,27 @@
FROM centos:7
ENV container=docker
RUN yum -y install epel-release && \
yum -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-pip python-setuptools python-virtualenv \
redhat-rpm-config && \
yum -y group install "Development Tools"
# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@@ -0,0 +1,14 @@
FROM debian:jessie
ENV container=docker
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip setuptools && \
pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /

View File

@@ -0,0 +1,13 @@
FROM debian:stretch
ENV container=docker
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv systemd && \
rm -rf /var/lib/apt/lists/*
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /

View File

@@ -0,0 +1,26 @@
FROM fedora:24
ENV container=docker
RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"
# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@@ -0,0 +1,26 @@
FROM fedora:25
ENV container=docker
RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"
# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@@ -0,0 +1,26 @@
FROM fedora:26
ENV container=docker
RUN dnf -y install gmp-devel libffi-devel openssl-devel python-crypto \
python-devel python-dnf python-pip python-setuptools python-virtualenv \
redhat-rpm-config systemd && \
dnf -y group install "C Development Tools and Libraries"
# Install systemd -- See https://hub.docker.com/_/centos/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@@ -0,0 +1,13 @@
FROM ubuntu:bionic
ENV container=docker
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv systemd && \
rm -rf /var/lib/apt/lists/*
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /

View File

@@ -0,0 +1,14 @@
FROM ubuntu:trusty
ENV container=docker
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv && \
rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade pip setuptools && \
pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /

View File

@@ -0,0 +1,13 @@
FROM ubuntu:xenial
ENV container=docker
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential libffi-dev \
libssl-dev python-dev python-minimal python-pip python-setuptools \
python-virtualenv && \
rm -rf /var/lib/apt/lists/*
RUN pip install enum34 ipaddress wheel && \
pip install ansible ansible-lint
COPY .ansible-lint /

1
tests/inventory Normal file
View File

@@ -0,0 +1 @@
localhost

5
tests/test.yml Normal file
View File

@@ -0,0 +1,5 @@
---
- hosts: localhost
connection: local
roles:
- ansible-manage-lvm