47 Commits

Author SHA1 Message Date
Larry Smith Jr
9eca9e391b Merge pull request #43 from mrlesmithjr/issue-42
Issue 42
2020-04-27 11:58:16 -04:00
Larry Smith Jr
881d5d77fa Fixing syntax issue for wantlist 2020-04-27 11:26:18 -04:00
Larry Smith Jr
89360e3ffe Trying to fix the subelements lookup for a single element
This addresses #42. Will need to do some validation testing, etc.
2020-04-27 11:16:02 -04:00
Larry Smith Jr
5267237c5e Merge pull request #41 from OsgiliathEnterprise/master
Fix xfs package installation win centos environment | travis-molecule-kvm tests
2020-04-26 01:20:28 -04:00
Charlie Mordant
eda544042a Merge pull request #10 from Tcharl/id2
remove unused molecule env property
2020-04-24 17:23:27 +02:00
Charlie Mordant
c6a7034e4b remove unused molecule env property 2020-04-24 17:22:07 +02:00
Charlie Mordant
816d44a6a1 Merge pull request #9 from Tcharl/id2
add molecule tests, fix xfs installation
2020-04-23 19:52:08 +02:00
Charlie Mordant
883055c33f lint 2020-04-23 19:38:35 +02:00
Charlie Mordant
4697b37377 Merge pull request #8 from Tcharl/master
enable molecule tests
2020-04-23 19:36:15 +02:00
Charlie Mordant
325c2d6240 install xfs 2020-04-23 19:25:09 +02:00
Larry Smith Jr
7d3e90f9e8 Merge pull request #40 from Tcharl/id2
use xfs_info on mountpoint instead of lvm
2020-04-21 23:06:35 -04:00
Charlie Mordant
db21878de4 Merge pull request #4 from Tcharl/id2
Id2
2020-04-21 19:06:23 +02:00
Charlie Mordant
4a1177e420 use xfs_info on mountpoint instead of lvm 2020-04-21 19:01:29 +02:00
Larry Smith Jr
45315cf2df Merge pull request #36 from mrlesmithjr/issue-35
Only doing a Molecule lint at this time
2020-04-19 09:57:52 -04:00
Larry Smith Jr
7fd5a8eec9 Only doing a Molecule lint at this time 2020-04-19 01:59:29 -04:00
Larry Smith Jr
c17a76f9cb Merge pull request #34 from mrlesmithjr/issue-33
Added Python requirements for testing, etc.
2020-04-19 01:46:51 -04:00
Larry Smith Jr
7e2a076b0a Added Python requirements for testing, etc.
Closes #33
2020-04-19 01:44:38 -04:00
Larry Smith Jr
4267de6416 Merge pull request #32 from OsgiliathEnterprise/id2
XFS support
2020-04-19 01:31:11 -04:00
Charlie Mordant
d3256a3a5a Merge pull request #3 from Tcharl/id2
code smells
2020-04-17 13:13:37 +02:00
Charlie Mordant
f1a9284396 Merge pull request #5 from Tcharl/id2
remove unwanted files
2020-04-17 13:13:04 +02:00
Charlie Mordant
dadb9f24f7 remove unwanted files 2020-04-17 13:12:06 +02:00
Charlie Mordant
8666645760 Merge pull request #4 from Tcharl/id2
code smells
2020-04-17 12:58:10 +02:00
Charlie Mordant
2f63eab727 code smells 2020-04-17 12:56:31 +02:00
Charlie Mordant
6c13d12494 Merge pull request #2 from Tcharl/id2
typo in check
2020-04-15 19:09:33 +02:00
Charlie Mordant
050f8a56f1 typo in check 2020-04-15 19:08:34 +02:00
Charlie Mordant
dc1ad5a6f8 Merge pull request #1 from Tcharl/id2
avoid reexecution of xfs creation
2020-04-15 19:01:39 +02:00
Charlie Mordant
1a648317c7 Merge pull request #3 from OsgiliathEnterprise/id2
makes xfs mountpoint repeatable
2020-04-15 18:54:40 +02:00
Charlie Mordant
b955a6f073 remove unwanted newline 2020-04-15 18:54:17 +02:00
Charlie Mordant
f81937e9d8 makes xfs mountpoint repeatable 2020-04-15 18:52:52 +02:00
Charlie Mordant
c3fea6e456 Merge pull request #2 from OsgiliathEnterprise/id2
mistake on remove volume
2020-04-15 17:36:01 +02:00
Charlie Mordant
1c3818e5d0 mistake on remove volume 2020-04-15 17:34:53 +02:00
Charlie Mordant
12c4dad6e0 Merge pull request #1 from OsgiliathEnterprise/id2
Xfs support
2020-04-15 17:14:12 +02:00
Charlie Mordant
47f8dae16a github action lint 2020-04-15 17:13:38 +02:00
Charlie Mordant
96fa78d6d0 remove deprecated machines 2020-04-15 17:07:33 +02:00
Charlie Mordant
17e8ec1058 configured molecule and fix xfs on centos 2020-04-15 16:56:18 +02:00
Charlie Mordant
ba5d929fce use dots instead of carets 2020-04-15 15:14:30 +02:00
Charlie Mordant
ea9109220b molecule test and idempotence 2020-04-15 14:33:41 +02:00
Larry Smith Jr
fe860566ba Merge pull request #27 from smutel/bug-resize-xfs
bug: Resize XFS parts is not working
2019-11-18 00:31:27 -05:00
Samuel Mutel
d8b3a4e932 bug: Resize XFS parts is not working 2019-10-14 12:21:03 +02:00
Larry Smith Jr
fc49e1d7b1 Merge pull request #25 from emper0r/patch-1
Update debian.yml
2019-06-27 07:38:12 -04:00
Tony Peña
b15ecea51d Update debian.yml
Since ansible 2.8.0 must be change way using dict
2019-06-26 14:56:13 +02:00
Larry Smith Jr
092546c501 Merge pull request #24 from mikap83/patch-1
issue #23: extra parenthesis
2019-04-08 08:31:45 -04:00
Michele Caputo
9788ee5df6 issue #23: extra parenthesis 2019-04-08 14:16:04 +02:00
faisalnizam
0f428a0e40 FIX LINT FOR BUILD
FIX LINT FOR BUILD
2019-04-03 08:36:49 -04:00
faisalnizam
8957630c04 Adding SWAP FileSystem Exception
Adding Check for SWAP Filesystem if defined skip 
1. SKIP New Filesystem Creation 
2. SKIP mountpoint check
2019-04-03 08:36:49 -04:00
Larry Smith Jr
bd866078da Merge pull request #22 from mrlesmithjr/issue#21
Resolves #21
2019-04-03 08:34:36 -04:00
Larry Smith Jr
183087e767 Resolves #21 2019-04-02 08:03:42 -04:00
27 changed files with 924 additions and 407 deletions

41
.github/workflows/molecule.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
---
# This is a basic workflow to help you get started with Actions
name: Molecule
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
branches:
- master
- tags/*
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: install lint prerequisite
run: |
sudo apt -y install python3-setuptools ansible-lint
- name: Install molecule
run: |
sudo apt update
sudo apt -y install python3-setuptools python3 python3-pip docker vagrant
sudo pip3 install wheel
sudo pip3 install molecule testinfra yamllint ansible-lint flake8 molecule-vagrant
- name: molecule lint
run: |
molecule lint

3
.gitignore vendored
View File

@@ -0,0 +1,3 @@
.idea
**/__pycache__
venv/

View File

@@ -1,61 +1,30 @@
---
dist: bionic
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
python:
- "3.8"
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'
- |
sudo apt -y install bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev
- |
wget https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
sudo apt -y install ./vagrant_2.2.7_x86_64.deb
sudo vagrant plugin install vagrant-libvirt
- |
sudo apt-get -y purge python3-openssl && sudo apt-get -y autoremove
sudo apt-get update && sudo apt-get install -y ca-certificates curl gcc iproute2 python3 python3-dev sudo
curl -skL https://bootstrap.pypa.io/get-pip.py | sudo -H python3
sudo pip3 install wheel
sudo pip3 install netaddr python-vagrant yamllint testinfra flake8
sudo pip3 install ansible ansible-lint
sudo pip3 install -I molecule molecule-vagrant
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})"'
- |
sudo molecule test --scenario-name kvm
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -1,58 +1,36 @@
---
extends: default
# Based on ansible-lint config
extends: default
ignore: |
venv/
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
max-spaces-inside: 1
level: error
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
max-spaces-inside: 1
level: error
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
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable

View File

@@ -1,19 +1,278 @@
# Change Log
commit 7e2a076b0a8155015fd21502db860fa89a2114b3
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Sun Apr 19 01:44:38 2020 -0400
## [Unreleased](https://github.com/mrlesmithjr/ansible-manage-lvm/tree/HEAD)
Added Python requirements for testing, etc.
Closes #33
[Full Changelog](https://github.com/mrlesmithjr/ansible-manage-lvm/compare/v0.1.0...HEAD)
commit dadb9f24f7ebc2752e6495c4c3569bdee5e0cc68
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Fri Apr 17 13:12:06 2020 +0200
**Closed issues:**
remove unwanted files
- Role fails on CentOS due to system-storage-manager package [\#2](https://github.com/mrlesmithjr/ansible-manage-lvm/issues/2)
commit 2f63eab727cf7b0b389d0d0cc1a1c7236b71f839
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Fri Apr 17 12:56:31 2020 +0200
## [v0.1.0](https://github.com/mrlesmithjr/ansible-manage-lvm/tree/v0.1.0) (2016-09-30)
**Merged pull requests:**
code smells
- Replace system-storage-manager with lvm2 in centos [\#3](https://github.com/mrlesmithjr/ansible-manage-lvm/pull/3) ([rohitkothari](https://github.com/rohitkothari))
- Add xfs\_growfs for xfs systemfile type. [\#1](https://github.com/mrlesmithjr/ansible-manage-lvm/pull/1) ([olo-dw](https://github.com/olo-dw))
commit 050f8a56f10d81f7827be53b8c769b1aa5021c00
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 19:08:34 2020 +0200
typo in check
commit b955a6f073b91773f5f90da878268e74872a99e9
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 18:54:17 2020 +0200
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
remove unwanted newline
commit f81937e9d82bc48f2ee03f6ff462c32bca3da8f0
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 18:52:52 2020 +0200
makes xfs mountpoint repeatable
commit 1c3818e5d06887c01dc0a4b88a39c0561a446300
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 17:34:53 2020 +0200
mistake on remove volume
commit 47f8dae16a096050dccbb8d161f4a18946a6ae73
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 17:13:38 2020 +0200
github action lint
commit 96fa78d6d099d0a48642d377d3e7f30a0c554bdf
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 17:07:33 2020 +0200
remove deprecated machines
commit 17e8ec1058c5cb66b21b15a8d3912ac9980508a9
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 16:56:18 2020 +0200
configured molecule and fix xfs on centos
commit ba5d929fce982af9baa44cfe8ad0b3079133f444
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 15:14:30 2020 +0200
use dots instead of carets
commit ea9109220bb268b5f14e75e38d9fb32c2d79bae5
Author: Charlie Mordant <cmordant1@gmail.com>
Date: Wed Apr 15 14:33:41 2020 +0200
molecule test and idempotence
commit d8b3a4e93257dfeb79bc8d4ef349acb53f0019dc
Author: Samuel Mutel <smu-dw@deveryware.net>
Date: Mon Oct 14 12:21:03 2019 +0200
bug: Resize XFS parts is not working
commit b15ecea51d0045a89aae24e4b0c108b35f060b2c
Author: Tony Peña <emperor.cu@gmail.com>
Date: Wed Jun 26 14:56:13 2019 +0200
Update debian.yml
Since ansible 2.8.0 must be change way using dict
commit 9788ee5df68798ad94f11c8133b1d62ff409d0e8
Author: Michele Caputo <mikap83@gmail.com>
Date: Mon Apr 8 14:16:04 2019 +0200
issue #23: extra parenthesis
commit 0f428a0e40d71aea410fbc1aa329203c0b4f15cd
Author: faisalnizam <faisal@logiik.com>
Date: Tue Mar 26 10:48:45 2019 +0400
FIX LINT FOR BUILD
FIX LINT FOR BUILD
commit 8957630c04b8befa99c08ed667e43d95198202ce
Author: faisalnizam <faisal@logiik.com>
Date: Tue Mar 26 10:40:11 2019 +0400
Adding SWAP FileSystem Exception
Adding Check for SWAP Filesystem if defined skip
1. SKIP New Filesystem Creation
2. SKIP mountpoint check
commit 183087e767cbce08ce2da1a3b04f47d3fc03a7e6
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Apr 2 08:03:42 2019 -0400
Resolves #21
commit b3ef85d4f738597260d9db0d90e84d0f8721259a
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Wed Dec 5 08:39:10 2018 -0500
Added skip codes for ansible-lint
commit 9f4afa7afb3fedc270c44ff1fa357da4b87845c0
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Wed Dec 5 08:00:13 2018 -0500
Fixing Travis testing and yamllint issues
commit 5603c5f6b0899a1b2cdeeeb3c035eb6249e96fa7
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Wed Dec 5 07:51:31 2018 -0500
Added Travis testing and hooks for galaxy
commit 563aa1effba936340cbaad9766a49f570292edee
Author: Mark Goddard <mark@stackhpc.com>
Date: Wed Oct 31 11:42:20 2018 +0000
Fix indentation
commit 4a58cb36cf6d4dd4bb23e86972658be508cca082
Author: Mark Goddard <mark@stackhpc.com>
Date: Wed Oct 31 11:16:27 2018 +0000
Update tasks/manage_lvm.yml
Co-Authored-By: oneswig <stig.github@telfer.org>
commit a0c784797f538fc5393d75589ac48e86c51e88db
Author: Stig Telfer <stig@stackhpc.com>
Date: Wed Oct 31 10:16:44 2018 +0100
Support not formatting volumes.
Logic to make the filesystem attribute optional, in situations where
we do not want the volumes formatted.
commit 66368de1d3d2b6712cbf66fc3dd0962705bf86f9
Author: David Castellanos <dcastellanos@fintonic.com>
Date: Mon Dec 18 00:33:45 2017 +0100
Add opts and mopts support
commit 386cc28bdb58886ed492d3438c9cb088d36de161
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Sun Jun 11 14:57:53 2017 -0400
Addresses issue #10
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
commit 0d255cb5ce9e6016a503203c2ed39a70fb0ccd9c
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Fri May 5 09:12:25 2017 -0400
Fixes issue #8
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
commit f2d06d0d46086da0191b4dbde0d420e709e3ea01
Author: Stefan Heimberg <kontakt@stefanheimberg.ch>
Date: Thu Apr 6 00:25:55 2017 +0200
added support for btrfs
commit 7749d0c62a6e1539aff94c57fd2c0eeaf43dd1a0
Author: Kevin Loveland <kevin.loveland@gmail.com>
Date: Fri Nov 18 10:26:16 2016 -0800
Fixed issue with idempotency of lvol module. See ansible-module-extras issue #428
commit 3ad965237280d534f0aab0027f9ef61701354e8b
Author: Kevin Loveland <kevin.loveland@gmail.com>
Date: Thu Nov 17 15:17:26 2016 -0800
Changes to adjust to removal of bare vars in Ansible 2.2
commit a82877c290cfe0b62eda90d8874b8e2b62402946
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Sun Oct 2 09:58:47 2016 -0400
First commit of CHANGELOG
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
commit 99366fa547faccb0359dd8d3b19cec802640eb95
Author: Rohit Kothari <rohietkothari@gmail.com>
Date: Thu Sep 29 17:59:19 2016 -0700
Replace system-storage-manager with lvm2 in centos
commit ca1535d774b4e3310fc993841f1f99400612c7a5
Author: Olivier LOCARD <olivier.locard@deveryware.com>
Date: Fri Sep 23 16:21:07 2016 +0200
Add xfs_growfs for xfs systemfile type.
commit bb87fa8dbff5df50ed376db74a6d2b95f64fd745
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Nov 3 10:39:58 2015 -0500
updated vars and conditionals
commit 49b20e2e4a80581f1c53559ff4073b3384eae28c
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Nov 3 10:24:54 2015 -0500
updated when conditions
commit 0232734bed92e976376d4c9f2550b515f72f3d54
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Nov 3 10:22:09 2015 -0500
updated tasks to only work when lvnames is defined
commit 9f592112095208843da1fd69a658bd49c163a7bb
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Nov 3 09:37:38 2015 -0500
updated vars and meta
commit 686455514d8bc0da70b3440dbc5afe669188d333
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Tue Nov 3 09:22:00 2015 -0500
cleaned up and fixed all tasks including swap
commit 9f5c61e25599a130e1625e879438561cc1f6a437
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Mon Nov 2 23:38:38 2015 -0500
added new task
commit a5103ff6396138f531cf8457f16706b6fc90d1d1
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Mon Nov 2 23:38:23 2015 -0500
changing role tasks and vars
commit c776e9f339f0bcfe987aa571d29411ac44a29526
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Mon Nov 2 21:50:07 2015 -0500
updated meta
commit 46e0fd1fc2477693fc66aa4b38ac7bde19087047
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Mon Nov 2 21:23:59 2015 -0500
updated meta
commit d1d99b2f17d3bc46a479af5d01a976686429b7ce
Author: Larry Smith Jr <mrlesmithjr@gmail.com>
Date: Mon Nov 2 21:23:03 2015 -0500
first commit

View File

@@ -1,62 +1,62 @@
---
# defaults file for ansible-manage-lvm
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
# - 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.

View File

@@ -3,22 +3,27 @@ galaxy_info:
author: Larry Smith Jr.
description: Role to manage LVM Groups/Logical Volumes. Can be used to create, extend or resize LVM.
license: license (GPLv2, CC-BY, etc)
license: MIT
min_ansible_version: 1.2
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- precise
- trusty
- name: Debian
versions:
- jessie
- wheezy
- name: fedora
versions:
- 31
categories:
- system
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- precise
- trusty
- name: Debian
versions:
- jessie
- wheezy
galaxy_tags:
- system
- lvm
dependencies: []

View File

@@ -0,0 +1,29 @@
---
- name: Converge
hosts: all
vars:
lvm_groups:
- vgname: my_vg
disks:
- /dev/sdb1
create: true
lvnames:
- lvname: my_lv
size: 40%VG
opts: "--wipesignatures y"
create: true
filesystem: ext4
mount: true
mntp: "/var/lib/mountpoint"
- lvname: my_lv2
size: 20%VG
opts: "--wipesignatures y"
mount: true
create: true
filesystem: xfs
mntp: "/var/lib/mountpoint2"
manage_lvm: true
tasks:
- name: "Include lvm"
include_role:
name: "ansible-manage-lvm"

View File

@@ -0,0 +1,25 @@
---
driver:
name: vagrant
provider:
name: virtualbox
lint: yamllint . && flake8 && ansible-lint
platforms:
- name: Fedora-Molecule-LVM
box: fedora/31-cloud-base
cpu: 2
memory: 2048
provider_override_args:
- "persistent_storage.enabled = true"
- "persistent_storage.location = 'molecule-lvm.vdi'"
- "persistent_storage.size = 100"
- "persistent_storage.mount = false"
- "persistent_storage.diskdevice = '/dev/sdb'"
provisioner:
name: ansible
verifier:
name: testinfra
env:
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
options:
v: 1

View File

@@ -0,0 +1,21 @@
"""PyTest Fixtures."""
from __future__ import absolute_import
import os
import pytest
def pytest_runtest_setup(item):
"""Run tests only when under molecule with testinfra installed."""
try:
import testinfra
except ImportError:
pytest.skip("Test requires testinfra", allow_module_level=True)
if "MOLECULE_INVENTORY_FILE" in os.environ:
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ["MOLECULE_INVENTORY_FILE"]
).get_hosts("all")
else:
pytest.skip(
"Test should run only from inside molecule.",
allow_module_level=True
)

View File

@@ -0,0 +1,26 @@
"""Role testing files using testinfra."""
def test_lvm_package_shall_be_installed(host):
assert host.package("lvm2").is_installed
def test_non_persistent_volume_group_is_created(host):
command = """sudo vgdisplay | grep -c 'my_vg'"""
cmd = host.run(command)
assert '1' in cmd.stdout
def test_mylv_logical_volume_is_created(host):
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
| grep -c 'my_lv'"""
cmd = host.run(command)
assert int(cmd.stdout.rstrip()) >= 1
def test_volume_is_mounted(host):
host.file("/var/lib/mountpoint").mode == 0o731
def test_volume2_is_mounted(host):
host.file("/var/lib/mountpoint2").mode == 0o731

29
molecule/kvm/converge.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- name: Converge
hosts: all
vars:
lvm_groups:
- vgname: my_vg
disks:
- /dev/vdb
create: true
lvnames:
- lvname: my_lv
size: 40%VG
opts: "--wipesignatures y"
create: true
filesystem: ext4
mount: true
mntp: "/var/lib/mountpoint"
- lvname: my_lv2
size: 20%VG
opts: "--wipesignatures y"
mount: true
create: true
filesystem: xfs
mntp: "/var/lib/mountpoint2"
manage_lvm: true
tasks:
- name: "Include lvm"
include_role:
name: "ansible-manage-lvm"

29
molecule/kvm/molecule.yml Normal file
View File

@@ -0,0 +1,29 @@
---
driver:
name: vagrant
provider:
name: libvirt
lint: yamllint . && flake8 && ansible-lint
platforms:
- name: Fedora-Molecule-Volumes-KVM
box: fedora/31-cloud-base
cpu: 2
memory: 2048
provider_raw_config_args:
- "storage :file, :size => '1G', :device => 'vdb'"
provisioner:
name: ansible
config_options:
defaults:
forks: 20
ssh_connection:
pipelining: true
ssh_args: -o ControlMaster=auto -o ControlPersist=600s
verifier:
name: testinfra
env:
PYTHONWARNINGS: "ignore:.*U.*mode is deprecated:DeprecationWarning"
options:
v: 1
scenario:
name: kvm

1
molecule/kvm/tests Symbolic link
View File

@@ -0,0 +1 @@
../default/tests

66
requirements-dev.txt Normal file
View File

@@ -0,0 +1,66 @@
ansible==2.9.7
ansible-lint==4.2.0
arrow==0.15.5
attrs==19.3.0
bcrypt==3.1.7
binaryornot==0.4.4
Cerberus==1.3.2
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.1
click-completion==0.5.2
click-help-colors==0.8
colorama==0.4.3
cookiecutter==1.7.0
cryptography==2.9
distro==1.5.0
docker==4.2.0
entrypoints==0.3
fasteners==0.15
flake8==3.7.9
future==0.18.2
idna==2.9
importlib-metadata==1.6.0
Jinja2==2.11.2
jinja2-time==0.2.0
MarkupSafe==1.1.1
mccabe==0.6.1
molecule==3.0.3
molecule-vagrant==0.2
monotonic==1.5
more-itertools==8.2.0
packaging==20.3
paramiko==2.7.1
pathspec==0.8.0
pexpect==4.8.0
pluggy==0.13.1
poyo==0.5.0
ptyprocess==0.6.0
py==1.8.1
pycodestyle==2.5.0
pycparser==2.20
pyflakes==2.1.1
PyNaCl==1.3.0
pyparsing==2.4.7
pytest==5.4.1
python-dateutil==2.8.1
python-gilt==1.2.3
python-vagrant==0.5.15
PyYAML==5.3.1
requests==2.23.0
ruamel.yaml==0.16.10
ruamel.yaml.clib==0.2.0
selinux==0.2.1
sh==1.12.14
shellingham==1.3.2
six==1.14.0
tabulate==0.8.7
testinfra==5.0.0
tree-format==0.1.2
urllib3==1.25.9
wcwidth==0.1.9
websocket-client==0.57.0
whichcraft==0.6.1
yamllint==1.23.0
zipp==3.1.0

7
requirements.txt Normal file
View File

@@ -0,0 +1,7 @@
ansible-lint==4.2.0
docker==4.2.0
flake8==3.7.9
molecule-vagrant==0.2
molecule==3.0.3
testinfra==5.0.0
yamllint==1.23.0

View File

@@ -1,23 +1,53 @@
---
- name: centos | installing lvm2
yum:
package:
name: "lvm2"
state: "present"
become: true
- name: centos | installing sg3_utils
yum:
package:
name: "sg3_utils"
state: "present"
become: true
- name: "debug lvg"
debug:
var: lv
verbosity: 3
loop: "{{ lookup('subelements', lvm_groups, 'lvnames', {'skip_missing': True, 'wantlist': True}) }}"
loop_control:
loop_var: lv
- name: centos | install xfs tools
package:
name: "xfsprogs"
state: "present"
become: true
loop: "{{ lookup('subelements', lvm_groups, 'lvnames', {'skip_missing': True, 'wantlist': True}) }}"
loop_control:
loop_var: lv
when: >
(
(lv.1 is defined and lv.1 != 'None') and
(
lv.1.filesystem is defined and
lv.1.filesystem == "xfs"
)
and
(
lv.1.create is defined and
lv.1.create
)
)
- name: centos | checking for scsi devices
shell: "sg_scan"
command: "sg_scan"
become: true
register: "scsi_devices"
changed_when: False
changed_when: false
- name: centos | rescanning for new disks
command: "/usr/bin/rescan-scsi-bus.sh"
become: true
changed_when: False
changed_when: false

110
tasks/create_fs.yml Normal file
View File

@@ -0,0 +1,110 @@
---
- name: manage_lvm | unmounting filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem | default(omit) }}"
state: "absent"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when: >
(lv is defined and
lv != 'None') and
(lv.create is defined and
not lv.create and
lv.filesystem != "swap")
- name: manage_lvm | creating new filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
resizefs: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when: >
(
(vg.create is defined and
vg.create) and
(lv is defined and
lv != 'None') and
(lv.create is defined and
lv.create) and
(
lv.filesystem is defined and
lv.filesystem != 'None' and
lv.filesystem != 'xfs'
)
)
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: lvm | check already converted
# at least xfs is executed twice if the partition has changed in the meantime
# then it tries to recreate the fs on the mounted fs which indeed fails...
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
become: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
register: mountedxfs
ignore_errors: true
changed_when: no
when: >
(
(lv is defined and lv != 'None') and
(
lv.filesystem is defined and
lv.filesystem == "xfs"
)
and
(
lv.create is defined and
lv.create
)
)
- name: manage_lvm | creating new xfs filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when: >
(
mountedxfs is failed and
(vg.create is defined and
vg.create) and
(lv is defined and
lv != 'None') and
(lv.create is defined and
lv.create) and
(
lv.filesystem is defined and
lv.filesystem == 'xfs'
)
)
- name: manage_lvm | mounting new filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem }}"
state: "mounted"
opts: "{{ lv.mopts | default('defaults') }}"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when: >
((vg.create is defined and
vg.create) and
lv != 'None' and
(lv.create is defined and
lv.create) and
(lv.mount is defined and
lv.mount))

35
tasks/create_lv.yml Normal file
View File

@@ -0,0 +1,35 @@
---
- name: "debug vg"
debug:
var: vg
verbosity: 2
- name: "debug lvm"
loop: "{{ vg.lvnames }}"
debug:
var: lv
verbosity: 1
loop_control:
loop_var: lv
- name: manage_lvm | creating new LVM logical volume(s)
lvol:
vg: "{{ vg.vgname }}"
lv: "{{ lv.lvname }}"
size: "{{ lv.size }}"
shrink: no
opts: "{{ lv.opts | default('') }}"
state: "present"
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when: >
(
(vg.create is defined
and vg.create) and
(lv is defined and
lv != 'None') and
(lv.create is defined and
lv.create)
)

12
tasks/create_vg.yml Normal file
View File

@@ -0,0 +1,12 @@
---
- name: manage_lvm | creating new LVM volume group(s)
lvg:
vg: "{{ item.vgname }}"
pvs: "{{ item.disks | join(',') }}"
state: "present"
become: true
loop: "{{ lvm_groups }}"
when: >
item.create is defined and
item.create

View File

@@ -1,22 +1,40 @@
---
- name: debian | installing pre-reqs
apt:
name: "{{ item }}"
package:
name:
- lvm2
- scsitools
state: "present"
become: true
with_items:
- lvm2
- scsitools
- xfsprogs
- name: debian | install xfs tools
package:
name: "xfsprogs"
state: "present"
become: yes
loop: "{{ lvm_groups|subelements('lvnames') }}"
when: >
(
(item.1 is defined and item.1 != 'None') and
(
item.1.filesystem is defined and
item.1.filesystem == "xfs"
)
and
(
item.1.create is defined and
item.1.create
)
)
- name: debian | checking for scsi devices
shell: "sg_scan"
command: "sg_scan"
become: true
register: "scsi_devices"
changed_when: False
changed_when: false
- name: debian | rescanning for new disks added
command: "/sbin/rescan-scsi-bus"
become: true
changed_when: False
when: scsi_devices['stdout'] != ""
changed_when: false
when: scsi_devices['stdout'] | length

View File

@@ -1,12 +1,12 @@
---
# tasks file for ansible-manage-lvm
- include: debian.yml
- include_tasks: debian.yml
when: ansible_os_family == "Debian"
- include: centos.yml
- include_tasks: centos.yml
when: ansible_os_family == "RedHat"
- include: manage_lvm.yml
- include_tasks: manage_lvm.yml
when: >
manage_lvm and
lvm_groups is defined
manage_lvm and
lvm_groups is defined

View File

@@ -1,162 +1,40 @@
---
- name: manage_lvm | creating new LVM volume group(s)
lvg:
vg: "{{ item['vgname'] }}"
pvs: "{{ item['disks']|join(',') }}"
state: "present"
become: true
with_items: "{{ lvm_groups }}"
when: >
(item['create'] is defined and
item['create'])
- name: manage_lvm | manage physical volume group creation
include_tasks: create_vg.yml
- name: manage_lvm | creating new LVM logical volume(s)
lvol:
vg: "{{ item[0]['vgname'] }}"
lv: "{{ item[1]['lvname'] }}"
size: "{{ item[1]['size'] }}"
shrink: no
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']))
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
include_tasks: create_lv.yml
loop: "{{ lvm_groups }}"
loop_control:
loop_var: vg
- 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
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]['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"
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']))
- name: manage_lvm | resizing filesystem
command: resize2fs /dev/{{ item[0]['vgname'] }}/{{ item[1]['lvname'] }}
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
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'] }}
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
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"
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
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'] | 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'])
- name: manage_lvm | loop over logical volume group(s) to create filesystems
include_tasks: create_fs.yml
loop: "{{ lvm_groups }}"
loop_control:
loop_var: vg
- name: manage_lvm | Removing LVM logical volume(s)
lvol:
vg: "{{ item[0]['vgname'] }}"
lv: "{{ item[1]['lvname'] }}"
vg: "{{ item.0.vgname }}"
lv: "{{ item.1.lvname }}"
state: "absent"
force: yes
become: true
with_subelements:
- "{{ lvm_groups }}"
- lvnames
loop: "{{ lvm_groups|subelements('lvnames') }}"
when: >
(item[1] is defined and
item[1] != 'None') and
(item[1]['create'] is defined and
not item[1]['create'])
(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']|join(',') }}"
vg: "{{ item.vgname }}"
pvs: "{{ item.disks | join(',') }}"
state: "absent"
become: true
with_items: "{{ lvm_groups }}"
loop: "{{ lvm_groups }}"
when: >
item['create'] is defined and
not item['create']
item.create is defined and
not item.create

View File

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

View File

@@ -1,14 +0,0 @@
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

@@ -1,26 +0,0 @@
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

@@ -1,14 +0,0 @@
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 /