mirror of
https://github.com/mrlesmithjr/ansible-manage-lvm.git
synced 2026-09-06 15:38:11 +03:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b36f4779f | |||
| 164b50b083 | |||
| 7328da933e | |||
| af9951c5cd | |||
| 454649d90b | |||
| 12f7033566 | |||
| 9a5d1dfc15 | |||
| 2f56dc54ad | |||
| 9f6bac5d63 | |||
| 9ffff49ef8 | |||
| 113974cccc | |||
| 2c41273c9f | |||
| 6d0feecec7 | |||
| 416e840eea | |||
| 850d571313 | |||
| ff13947aaf | |||
| 26246c7160 | |||
| 5540f7fda5 | |||
| 433b7ca1a9 | |||
| 9404a780c5 | |||
| c0184492d5 | |||
| 60e08852ea | |||
| 42cc915582 | |||
| 49edca9134 | |||
| ee1e3d051b | |||
| 91f8cfca5d | |||
| 3ac9669088 | |||
| 4219da5423 | |||
| 683c617265 | |||
| b41ffc5e58 | |||
| 564d3d1f6f | |||
| 1d0fa70d66 | |||
| 8c3bca39ec | |||
| 4fbcf1cd19 | |||
| 11056e2e60 | |||
| 220de2d8ac | |||
| 3f3a7c7334 | |||
| f901fe42b3 | |||
| d27a3809d9 | |||
| 51b7015f9c | |||
| e35a250f7b | |||
| de0507269b | |||
| 1b7e7e6b1c | |||
| 84ba07bcaf | |||
| a623248cdf | |||
| 55b1745ac3 | |||
| c020c6ef2d | |||
| 47c980797d | |||
| d6dd5184f0 | |||
| 74e7ca5652 | |||
| 12346fa038 | |||
| 8dc044f7c2 | |||
| aa66814872 | |||
| 6e4f217d74 | |||
| 483ed18874 | |||
| ea2e60f043 | |||
| a28791cc48 | |||
| b5bf2d266c | |||
| ca903442c8 | |||
| 9e69c74f71 | |||
| e9ff7e3faf | |||
| 84bfdf54ad | |||
| 376f2ce641 | |||
| 6e74c9714e | |||
| 1f966d2ea1 | |||
| 71a3930e5b | |||
| 263c8d2b3f | |||
| 0bfd390ace | |||
| 71bc56d733 | |||
| 59ca2aae95 | |||
| cb3a75c984 | |||
| fae4332de8 | |||
| 3ea52cdda8 | |||
| 2d020f26d8 | |||
| 558cd7460e | |||
| 3b00335935 | |||
| ac014a161e | |||
| 9446ef21d6 | |||
| 97300430ad | |||
| 73db3c747c | |||
| 73b6bce608 | |||
| 098bd79154 | |||
| fddf9804dd | |||
| 506da4707e | |||
| 773ce28061 | |||
| 1bb56066fe | |||
| cb792e59a6 | |||
| 48e3be3c5c | |||
| 2492c96566 | |||
| e4bc8a9e9b | |||
| 1d57a469b0 | |||
| 19e56ac7d8 | |||
| 5c3e601078 | |||
| 535b410363 | |||
| f87c42a8c5 | |||
| 34e4f08c31 | |||
| f1a54639c6 | |||
| 88489df0ac | |||
| b288695b9a | |||
| ed0eb14ce8 | |||
| 9c04be9046 | |||
| 96fd3b2b06 | |||
| 15b2b7b4e0 | |||
| 9ead2c9b18 | |||
| 79f4787208 | |||
| 94582de25d | |||
| 6ee72799b4 | |||
| 69e25effd4 | |||
| 62fc5a5e2b | |||
| c40f9b7d03 | |||
| 0621cadde8 | |||
| b7cef8e323 | |||
| 59ffcfac4a | |||
| 976ff31d00 | |||
| 78205e51cb | |||
| b731c20100 | |||
| f2df804926 | |||
| 9f37fa3ed1 | |||
| c9a9e1660e | |||
| ec0737d26b | |||
| 52c0270a53 | |||
| 94be28c09b | |||
| a6b07da847 | |||
| 643c7b6ee1 | |||
| b7c3cf9f75 | |||
| e423ebd56b | |||
| 9eca9e391b | |||
| 881d5d77fa | |||
| 89360e3ffe | |||
| 5267237c5e | |||
| eda544042a | |||
| c6a7034e4b | |||
| 1e997a3e80 | |||
| 816d44a6a1 | |||
| 883055c33f | |||
| 4697b37377 | |||
| 325c2d6240 | |||
| 7d3e90f9e8 | |||
| db21878de4 | |||
| 4a1177e420 | |||
| 45315cf2df | |||
| 7fd5a8eec9 | |||
| c17a76f9cb | |||
| 7e2a076b0a | |||
| d3256a3a5a | |||
| 6c13d12494 | |||
| dc1ad5a6f8 | |||
| 1a648317c7 | |||
| c3fea6e456 | |||
| 12c4dad6e0 |
@@ -0,0 +1,3 @@
|
|||||||
|
skip_list:
|
||||||
|
- name[casing]
|
||||||
|
- role-name
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
github: mrlesmithjr
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Configuration for request-info - https://github.com/behaviorbot/request-info
|
||||||
|
|
||||||
|
# *Required* Comment to reply with
|
||||||
|
requestInfoReplyComment: >
|
||||||
|
We would appreciate it if you could provide us with more info about this issue/pr!
|
||||||
|
|
||||||
|
# *OPTIONAL* default titles to check against for lack of descriptiveness
|
||||||
|
# MUST BE ALL LOWERCASE
|
||||||
|
requestInfoDefaultTitles:
|
||||||
|
- update readme.md
|
||||||
|
- updates
|
||||||
|
|
||||||
|
# *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
|
||||||
|
requestInfoLabelToAdd: needs-more-info
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
groups:
|
||||||
|
github-actions:
|
||||||
|
patterns: ["*"]
|
||||||
|
labels: ["dependencies"]
|
||||||
|
commit-message:
|
||||||
|
prefix: "ci"
|
||||||
|
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
groups:
|
||||||
|
python-deps:
|
||||||
|
patterns: ["*"]
|
||||||
|
labels: ["dependencies"]
|
||||||
|
commit-message:
|
||||||
|
prefix: "chore"
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name-template: "v$RESOLVED_VERSION 🌈"
|
||||||
|
tag-template: "v$RESOLVED_VERSION"
|
||||||
|
categories:
|
||||||
|
- title: "🚀 Features"
|
||||||
|
labels:
|
||||||
|
- "feature"
|
||||||
|
- "enhancement"
|
||||||
|
- title: "🐛 Bug Fixes"
|
||||||
|
labels:
|
||||||
|
- "fix"
|
||||||
|
- "bugfix"
|
||||||
|
- "bug"
|
||||||
|
- title: "🧰 Maintenance"
|
||||||
|
label: "chore"
|
||||||
|
- title: "🧺 Miscellaneous" #Everything except ABAP
|
||||||
|
label: "misc"
|
||||||
|
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
|
||||||
|
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- "major"
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- "minor"
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- "patch"
|
||||||
|
default: patch
|
||||||
|
template: |
|
||||||
|
## Changes
|
||||||
|
$CHANGES
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
|
||||||
|
|
||||||
|
repository:
|
||||||
|
# See https://developer.github.com/v3/repos/#edit for all available settings.
|
||||||
|
|
||||||
|
# The name of the repository. Changing this will rename the repository
|
||||||
|
name: ansible-manage-lvm
|
||||||
|
|
||||||
|
# A short description of the repository that will show up on GitHub
|
||||||
|
description: Ansible role to manage LVM Groups/Logical Volumes
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Number of days of inactivity before an issue becomes stale
|
||||||
|
daysUntilStale: 60
|
||||||
|
# Number of days of inactivity before a stale issue is closed
|
||||||
|
daysUntilClose: 7
|
||||||
|
# Issues with these labels will never be considered stale
|
||||||
|
exemptLabels:
|
||||||
|
- pinned
|
||||||
|
- security
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: wontfix
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt -r requirements-dev.txt
|
||||||
|
- name: Check linting with pre-commit
|
||||||
|
run: pre-commit run --all-files
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
# 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 docker molecule testinfra yamllint ansible-lint flake8 molecule-vagrant
|
|
||||||
|
|
||||||
- name: molecule lint
|
|
||||||
run: |
|
|
||||||
molecule lint
|
|
||||||
|
|
||||||
molecule:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: "false"
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: configure keyboard layout
|
|
||||||
run: |
|
|
||||||
echo XKBLAYOUT='us' > /etc/default/keyboard
|
|
||||||
|
|
||||||
- name: install virtualization stack
|
|
||||||
env:
|
|
||||||
DEBIAN_FRONTEND: noninteractive
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt -y install cpu-checker
|
|
||||||
kvm-ok
|
|
||||||
# shit happens here, containerization sucks... that was worth the try
|
|
||||||
|
|
||||||
- name: install virtualization stack
|
|
||||||
env:
|
|
||||||
DEBIAN_FRONTEND: noninteractive
|
|
||||||
run: |
|
|
||||||
sudo apt -y install policycoreutils-python-utils qemu-kvm qemu-utils libvirt-clients libvirt-daemon-system bridge-utils python3-libvirt libnss-libvirt libguestfs-tools virtinst virt-top genisoimage libvirt-dev libvirt-bin
|
|
||||||
|
|
||||||
- name: install vagrant
|
|
||||||
env:
|
|
||||||
VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT: 1
|
|
||||||
run: |
|
|
||||||
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
|
|
||||||
vagrant plugin install vagrant-persistent-storage
|
|
||||||
vagrant plugin install vagrant-libvirt
|
|
||||||
sudo groupadd --system libvirt
|
|
||||||
sudo usermod -a -G libvirt $(whoami)
|
|
||||||
sudo /etc/init.d/libvirtd restart
|
|
||||||
|
|
||||||
- name: Install molecule
|
|
||||||
run: |
|
|
||||||
sudo apt -y install python3-setuptools
|
|
||||||
pip3 install molecule-vagrant wheel
|
|
||||||
|
|
||||||
- name: create molecule vm
|
|
||||||
env:
|
|
||||||
LC_ALL: C.UTF-8
|
|
||||||
LANG: C.UTF-8
|
|
||||||
run: |
|
|
||||||
molecule create --scenario-name kvm
|
|
||||||
|
|
||||||
- name: verify
|
|
||||||
run: |
|
|
||||||
molecule verify
|
|
||||||
|
|
||||||
- name: teardown
|
|
||||||
run: |
|
|
||||||
molecule destroy
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
# branches to consider in the event; optional, defaults to all
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Drafts your next Release notes as Pull Requests are merged into "master"
|
||||||
|
- uses: release-drafter/release-drafter@v5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
name: Ansible Galaxy
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
galaxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Install Ansible
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install ansible-core
|
||||||
|
|
||||||
|
- name: Trigger a new import on Galaxy
|
||||||
|
run: >-
|
||||||
|
ansible-galaxy role import
|
||||||
|
--api-key ${{ secrets.GALAXY_API_KEY }}
|
||||||
|
${{ github.repository_owner }}
|
||||||
|
${{ github.event.repository.name }}
|
||||||
|
|
||||||
+2
-1
@@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
.venv/
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: no-commit-to-branch
|
||||||
|
args: [--branch, develop, --branch, master, --branch, main]
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/ansible-community/ansible-lint
|
||||||
|
rev: v6.17.1
|
||||||
|
hooks:
|
||||||
|
- id: ansible-lint
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 23.3.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
language_version: python3
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 6.0.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
|
rev: v1.32.0
|
||||||
|
hooks:
|
||||||
|
- id: yamllint
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
---
|
|
||||||
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: ubuntu
|
|
||||||
init: /lib/systemd/systemd
|
|
||||||
version: bionic
|
|
||||||
- distribution: ubuntu
|
|
||||||
init: /lib/systemd/systemd
|
|
||||||
version: xenial
|
|
||||||
- distribution: debian
|
|
||||||
init: /lib/systemd/systemd
|
|
||||||
version: stretch
|
|
||||||
|
|
||||||
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/
|
|
||||||
+30
-52
@@ -1,58 +1,36 @@
|
|||||||
---
|
---
|
||||||
extends: default
|
# Based on ansible-lint config
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
ignore: |
|
||||||
|
.venv/
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
braces:
|
braces:
|
||||||
# Defaults
|
max-spaces-inside: 1
|
||||||
# min-spaces-inside: 0
|
level: error
|
||||||
# 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:
|
brackets:
|
||||||
# Defaults
|
max-spaces-inside: 1
|
||||||
# min-spaces-inside: 0
|
level: error
|
||||||
# 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:
|
colons:
|
||||||
# Defaults
|
max-spaces-after: -1
|
||||||
# max-spaces-before: 0
|
level: error
|
||||||
# max-spaces-after: 1
|
commas:
|
||||||
|
max-spaces-after: -1
|
||||||
max-spaces-before: 0
|
level: error
|
||||||
# Allowing more than one space for code readability
|
comments: disable
|
||||||
max-spaces-after: -1
|
comments-indentation: disable
|
||||||
|
document-start: disable
|
||||||
comments:
|
empty-lines:
|
||||||
# Defaults
|
max: 3
|
||||||
# level: warning
|
level: error
|
||||||
# require-starting-space: true
|
hyphens:
|
||||||
# min-spaces-from-content: 2
|
level: error
|
||||||
|
indentation: disable
|
||||||
# Disabling to allow for code comment blocks and #!/usr/bin/ansible-playbook
|
key-duplicates: enable
|
||||||
require-starting-space: false
|
line-length: disable
|
||||||
|
new-line-at-end-of-file: disable
|
||||||
indentation:
|
new-lines:
|
||||||
# Defaults
|
type: unix
|
||||||
# spaces: consistent
|
trailing-spaces: disable
|
||||||
# indent-sequences: true
|
truthy: disable
|
||||||
# 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
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
# Change Log
|
|
||||||
|
|
||||||
## [Unreleased](https://github.com/mrlesmithjr/ansible-manage-lvm/tree/HEAD)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/mrlesmithjr/ansible-manage-lvm/compare/v0.1.0...HEAD)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Role fails on CentOS due to system-storage-manager package [\#2](https://github.com/mrlesmithjr/ansible-manage-lvm/issues/2)
|
|
||||||
|
|
||||||
## [v0.1.0](https://github.com/mrlesmithjr/ansible-manage-lvm/tree/v0.1.0) (2016-09-30)
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- 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))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
|
||||||
@@ -1,135 +1,122 @@
|
|||||||
# Role Name
|
# ansible-manage-lvm
|
||||||
|
|
||||||
An [Ansible] role to manage LVM Groups/Logical Volumes.
|
An [Ansible](https://www.ansible.com) role to create, extend, and resize [LVM](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)) volume groups and logical volumes.
|
||||||
|
|
||||||
> NOTE: Can be used to create, extend or resize LVM Groups and volumes.
|
> Used by [OpenStack Kayobe](https://docs.openstack.org/kayobe/latest/) for LVM management.
|
||||||
|
|
||||||
|
## Ansible Galaxy
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-galaxy install mrlesmithjr.manage_lvm
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** As of December 2025, the canonical Galaxy name is `mrlesmithjr.manage_lvm` (underscore).
|
||||||
|
> Update any `requirements.yml` using the older hyphen-style name `mrlesmithjr.manage-lvm`.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Historical download statistics</summary>
|
||||||
|
|
||||||
|
| Role Name | Downloads (as of Dec 2025) |
|
||||||
|
|-----------|---------------------------|
|
||||||
|
| `mrlesmithjr.manage_lvm` | 697,492 |
|
||||||
|
| `mrlesmithjr.manage-lvm` | 494,517 |
|
||||||
|
| **Combined** | **1,192,009** |
|
||||||
|
|
||||||
|
Download counts reset when roles are re-imported to Galaxy. These figures represent actual historical usage.
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Supported Platforms
|
||||||
|
|
||||||
|
Any Linux distribution with LVM support, including:
|
||||||
|
|
||||||
|
| Platform | Versions |
|
||||||
|
|----------|----------|
|
||||||
|
| Ubuntu | 20.04, 22.04, 24.04 |
|
||||||
|
| Debian | 11, 12 |
|
||||||
|
| Rocky Linux / RHEL | 8, 9 |
|
||||||
|
| Fedora | 39+ |
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
Devices/disks to be members of the LVM setup **must be** identified prior to
|
- Unpartitioned disk devices to assign to volume groups
|
||||||
using this role.
|
- `lvm2` package (installed automatically by the role)
|
||||||
|
|
||||||
> NOTE: Ensure that you select the correct devices/disks.
|
## Important: Safety Default
|
||||||
>
|
|
||||||
> NOTE: To create an LVM VG w/out creating LVM LVOLS...define lvname w/ var as
|
|
||||||
> `None` as in the below example.
|
|
||||||
|
|
||||||
## Role Variables
|
`manage_lvm` defaults to `false`. **The role will not make any disk changes** unless you explicitly set:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
manage_lvm: true
|
||||||
# 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
|
|
||||||
|
|
||||||
# Defines if LVM will be managed by role
|
|
||||||
# default is false to ensure nothing is changed by accident.
|
|
||||||
manage_lvm: false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dependencies
|
This prevents accidental modifications on misconfigured runs.
|
||||||
|
|
||||||
None
|
## Quick Start
|
||||||
|
|
||||||
## Example Playbook
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
- hosts: test-nodes
|
- hosts: all
|
||||||
|
become: true
|
||||||
vars:
|
vars:
|
||||||
|
manage_lvm: true
|
||||||
lvm_groups:
|
lvm_groups:
|
||||||
- vgname: test-vg
|
- vgname: data-vg
|
||||||
disks:
|
disks:
|
||||||
- /dev/sdb
|
- /dev/sdb
|
||||||
- /dev/sdc
|
|
||||||
create: true
|
create: true
|
||||||
lvnames:
|
lvnames:
|
||||||
- lvname: test_1
|
- lvname: data
|
||||||
size: 5g
|
size: 100%FREE
|
||||||
create: true
|
create: true
|
||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
mount: true
|
mount: true
|
||||||
mntp: /mnt/test_1
|
mntp: /data
|
||||||
- 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:
|
roles:
|
||||||
- role: ansible-manage-lvm
|
- role: mrlesmithjr.manage_lvm
|
||||||
tasks:
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Key Variables
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `manage_lvm` | `false` | Master switch — must be `true` to make any changes |
|
||||||
|
| `lvm_groups` | `[]` | List of volume group definitions |
|
||||||
|
| `pvresize_to_max` | `false` | Resize all PVs to maximum available size |
|
||||||
|
|
||||||
|
### `lvm_groups` Structure
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
lvm_groups:
|
||||||
|
- vgname: my-vg # Volume group name
|
||||||
|
disks: # Physical volumes to assign
|
||||||
|
- /dev/sdb
|
||||||
|
- /dev/sdc
|
||||||
|
create: true # true = create, false = remove
|
||||||
|
pvresize: false # Resize PV to max size
|
||||||
|
lvnames:
|
||||||
|
- lvname: data # Logical volume name
|
||||||
|
size: 50g # Size: 10g | 1024 (MB) | 100%FREE
|
||||||
|
create: true # true = create, false = remove
|
||||||
|
filesystem: ext4 # ext4 | xfs | swap | etc.
|
||||||
|
mount: true # Mount after creation
|
||||||
|
mntp: /data # Mountpoint
|
||||||
|
mopts: noatime # Mount options (optional)
|
||||||
|
fsopts: # Filesystem creation options (optional)
|
||||||
|
```
|
||||||
|
|
||||||
|
See [defaults/main.yml](defaults/main.yml) for full examples including XFS, swap, and OpenStack Cinder volumes.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
BSD
|
MIT
|
||||||
|
|
||||||
## Author Information
|
## Support This Project
|
||||||
|
|
||||||
Larry Smith Jr.
|
This role has been downloaded over **1.1 million times** from Ansible Galaxy.
|
||||||
|
If your organization depends on it in production, consider
|
||||||
|
[sponsoring its maintenance](https://github.com/sponsors/mrlesmithjr).
|
||||||
|
Enterprise support tiers are available.
|
||||||
|
|
||||||
- [@mrlesmithjr]
|
## Author
|
||||||
- <http://everythingshouldbevirtual.com>
|
|
||||||
- mrlesmithjr [at] gmail.com
|
|
||||||
|
|
||||||
[@mrlesmithjr]: https://www.twitter.com/mrlesmithjr
|
Larry Smith Jr. — [everythingshouldbevirtual.com](http://everythingshouldbevirtual.com) · [mrlesmithjr@gmail.com](mailto:mrlesmithjr@gmail.com)
|
||||||
|
|
||||||
[ansible]: https://www.ansible.com
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ lvm_groups: []
|
|||||||
# # defines if VG should exist or be removed
|
# # defines if VG should exist or be removed
|
||||||
# # true or false
|
# # true or false
|
||||||
# create: true
|
# create: true
|
||||||
|
# # defines if PV should be resized to max size
|
||||||
|
# pvresize: false
|
||||||
# lvnames:
|
# lvnames:
|
||||||
# - lvname: swap_1
|
# - lvname: swap_1
|
||||||
# # Define size of lvol
|
# # Define size of lvol
|
||||||
@@ -31,6 +33,8 @@ lvm_groups: []
|
|||||||
# size: 40g
|
# size: 40g
|
||||||
# create: true
|
# create: true
|
||||||
# filesystem: ext4
|
# filesystem: ext4
|
||||||
|
# # Defines options passed to the filesystem creation command
|
||||||
|
# fsopts:
|
||||||
# mount: true
|
# mount: true
|
||||||
# mntp: /
|
# mntp: /
|
||||||
# - vgname: test-vg
|
# - vgname: test-vg
|
||||||
@@ -57,7 +61,32 @@ lvm_groups: []
|
|||||||
# lvnames:
|
# lvnames:
|
||||||
# # Set to None to only create LVM VG w/out creating LVM LVOLS
|
# # Set to None to only create LVM VG w/out creating LVM LVOLS
|
||||||
# - None
|
# - None
|
||||||
|
# # Using fsopts to create a docker compatible xfs volume
|
||||||
|
# - vgname: docker-volumes
|
||||||
|
# disks:
|
||||||
|
# - /dev/vdc
|
||||||
|
# - /dev/vdd
|
||||||
|
# create: true
|
||||||
|
# lvnames:
|
||||||
|
# - lvname: docker_1
|
||||||
|
# size: 100%FREE
|
||||||
|
# create: true
|
||||||
|
# filesystem: xfs
|
||||||
|
# fsopts: -n ftype=1
|
||||||
|
# mount: true
|
||||||
|
# mntp: /var/lib/docker
|
||||||
|
|
||||||
# Defines if LVM will be managed by role
|
# Defines if LVM will be managed by role
|
||||||
# default is false to ensure nothing is changed by accident.
|
# default is false to ensure nothing is changed by accident.
|
||||||
manage_lvm: false
|
manage_lvm: false
|
||||||
|
|
||||||
|
### nvme to scsi device name map binary helper
|
||||||
|
ebsnvme_binary_helper_ver: '0.1.3'
|
||||||
|
ebsnvme_binary_helper_tmp: '/tmp'
|
||||||
|
ebsnvme_binary_helper_path: '/sbin/go-ebsnvme'
|
||||||
|
|
||||||
|
### nvme to scsi device name map script helper
|
||||||
|
ebsnvme_scrip_helper_path: '/usr/local/bin/ebsnvme-id'
|
||||||
|
|
||||||
|
### resize all pv's to max size
|
||||||
|
pvresize_to_max: false
|
||||||
|
|||||||
+11
-9
@@ -1,24 +1,26 @@
|
|||||||
---
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Larry Smith Jr.
|
author: Larry Smith Jr.
|
||||||
description: Role to manage LVM Groups/Logical Volumes. Can be used to create, extend or resize LVM.
|
description: Ansible role to manage(create, extend, resize) LVM Groups/Logical Volumes.
|
||||||
|
namespace: mrlesmithjr
|
||||||
|
role_name: manage-lvm
|
||||||
|
|
||||||
license: MIT
|
license: MIT
|
||||||
min_ansible_version: 1.2
|
min_ansible_version: "1.2"
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
- 6
|
- all
|
||||||
- 7
|
- name: Fedora
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- precise
|
- all
|
||||||
- trusty
|
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- jessie
|
- all
|
||||||
- wheezy
|
|
||||||
|
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- system
|
- system
|
||||||
|
- lvm
|
||||||
dependencies: []
|
dependencies: []
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
filesystem: ext4
|
filesystem: ext4
|
||||||
mount: true
|
mount: true
|
||||||
mntp: "/var/lib/mountpoint"
|
mntp: "/var/lib/mountpoint"
|
||||||
- lvname: my_lv2
|
- lvname: my_lw
|
||||||
size: 20%VG
|
size: 20%VG
|
||||||
opts: "--wipesignatures y"
|
opts: "--wipesignatures y"
|
||||||
mount: true
|
mount: true
|
||||||
@@ -23,8 +23,7 @@
|
|||||||
filesystem: xfs
|
filesystem: xfs
|
||||||
mntp: "/var/lib/mountpoint2"
|
mntp: "/var/lib/mountpoint2"
|
||||||
manage_lvm: true
|
manage_lvm: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: "Include lvm"
|
- name: "Include lvm"
|
||||||
include_role:
|
ansible.builtin.include_role:
|
||||||
name: "ansible-manage-lvm"
|
name: "ansible-manage-lvm"
|
||||||
|
|||||||
@@ -3,22 +3,37 @@ driver:
|
|||||||
name: vagrant
|
name: vagrant
|
||||||
provider:
|
provider:
|
||||||
name: virtualbox
|
name: virtualbox
|
||||||
lint: yamllint . && flake8 && ansible-lint --exclude=meta
|
lint: |
|
||||||
|
yamllint .
|
||||||
|
ansible-lint
|
||||||
|
flake8
|
||||||
platforms:
|
platforms:
|
||||||
- name: Fedora-Molecule-LVM
|
- name: CentOS-Molecule-LVM
|
||||||
box: bento/fedora-31
|
box: mrlesmithjr/centos7
|
||||||
# box-url: ${platform_root}/packer/bento/builds/fedora-31-x86_64.virtualbox.box
|
|
||||||
provider_override_args:
|
provider_override_args:
|
||||||
- "persistent_storage.enabled = true"
|
- "persistent_storage.enabled = true"
|
||||||
- "persistent_storage.location = 'molecule-lvm.vdi'"
|
- "persistent_storage.location = 'centos-molecule-lvm.vdi'"
|
||||||
|
- "persistent_storage.size = 100"
|
||||||
|
- "persistent_storage.mount = false"
|
||||||
|
- "persistent_storage.diskdevice = '/dev/sdb'"
|
||||||
|
- name: Fedora-Molecule-LVM
|
||||||
|
box: mrlesmithjr/fedora31
|
||||||
|
provider_override_args:
|
||||||
|
- "persistent_storage.enabled = true"
|
||||||
|
- "persistent_storage.location = 'fedora-molecule-lvm.vdi'"
|
||||||
|
- "persistent_storage.size = 100"
|
||||||
|
- "persistent_storage.mount = false"
|
||||||
|
- "persistent_storage.diskdevice = '/dev/sdb'"
|
||||||
|
- name: Ubuntu-Molecule-LVM
|
||||||
|
box: mrlesmithjr/bionic64
|
||||||
|
provider_override_args:
|
||||||
|
- "persistent_storage.enabled = true"
|
||||||
|
- "persistent_storage.location = 'ubuntu-molecule-lvm.vdi'"
|
||||||
- "persistent_storage.size = 100"
|
- "persistent_storage.size = 100"
|
||||||
- "persistent_storage.mount = false"
|
- "persistent_storage.mount = false"
|
||||||
- "persistent_storage.diskdevice = '/dev/sdb'"
|
- "persistent_storage.diskdevice = '/dev/sdb'"
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
inventory:
|
|
||||||
group_vars:
|
|
||||||
lvm:
|
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: testinfra
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -16,6 +16,5 @@ def pytest_runtest_setup(item):
|
|||||||
).get_hosts("all")
|
).get_hosts("all")
|
||||||
else:
|
else:
|
||||||
pytest.skip(
|
pytest.skip(
|
||||||
"Test should run only from inside molecule.",
|
"Test should run only from inside molecule.", allow_module_level=True
|
||||||
allow_module_level=True
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ def test_lvm_package_shall_be_installed(host):
|
|||||||
def test_non_persistent_volume_group_is_created(host):
|
def test_non_persistent_volume_group_is_created(host):
|
||||||
command = """sudo vgdisplay | grep -c 'my_vg'"""
|
command = """sudo vgdisplay | grep -c 'my_vg'"""
|
||||||
cmd = host.run(command)
|
cmd = host.run(command)
|
||||||
assert '1' in cmd.stdout
|
assert "1" in cmd.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_mylv_logical_volume_is_created(host):
|
def test_mylv_logical_volume_is_created(host):
|
||||||
@@ -18,6 +18,13 @@ def test_mylv_logical_volume_is_created(host):
|
|||||||
assert int(cmd.stdout.rstrip()) >= 1
|
assert int(cmd.stdout.rstrip()) >= 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_mylv_logical_volume2_is_created(host):
|
||||||
|
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
|
||||||
|
| grep -c 'my_lw'"""
|
||||||
|
cmd = host.run(command)
|
||||||
|
assert int(cmd.stdout.rstrip()) >= 1
|
||||||
|
|
||||||
|
|
||||||
def test_volume_is_mounted(host):
|
def test_volume_is_mounted(host):
|
||||||
host.file("/var/lib/mountpoint").mode == 0o731
|
host.file("/var/lib/mountpoint").mode == 0o731
|
||||||
|
|
||||||
|
|||||||
@@ -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_lw
|
||||||
|
size: 20%VG
|
||||||
|
opts: "--wipesignatures y"
|
||||||
|
mount: true
|
||||||
|
create: true
|
||||||
|
filesystem: xfs
|
||||||
|
mntp: "/var/lib/mountpoint2"
|
||||||
|
manage_lvm: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include lvm"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "ansible-manage-lvm"
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"""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
|
||||||
|
)
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
"""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_mylv_logical_volume2_is_created(host):
|
||||||
|
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
|
||||||
|
| grep -c 'my_lw'"""
|
||||||
|
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
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
lvm_groups:
|
||||||
|
- vgname: my_vg
|
||||||
|
disks:
|
||||||
|
- /dev/vdb
|
||||||
|
create: true
|
||||||
|
manage_lvm: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include lvm"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "ansible-manage-lvm"
|
||||||
@@ -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: kvmonlyvg
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"""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
|
||||||
|
)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
"""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
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
- 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"
|
||||||
|
manage_lvm: true
|
||||||
|
tasks:
|
||||||
|
- name: "Include lvm"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: "ansible-manage-lvm"
|
||||||
@@ -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: kvmsinglelv
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"""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
|
||||||
|
)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
"""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
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
- name: Example playbook
|
||||||
|
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
|
||||||
|
tasks:
|
||||||
|
- name: Include lvm
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: ansible-manage-lvm
|
||||||
Generated
+1546
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "ansible-manage-lvm"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["Larry Smith Jr. <mrlesmithjr@gmail.com>"]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = ">=3.9,<4.0"
|
||||||
|
ansible = "8.5.0"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
ansible-lint = "6.8.7"
|
||||||
|
black = "^22.10.0"
|
||||||
|
pylint = "^2.15.7"
|
||||||
|
flake8 = "^6.0.0"
|
||||||
|
cookiecutter = "^2.1.1"
|
||||||
|
pre-commit = "^2.20.0"
|
||||||
|
molecule-plugins = {extras = ["vagrant"], version = "^23.4.1"}
|
||||||
|
molecule = {extras = ["docker"], version = "^5.0.1"}
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
ansible-compat==3.0.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
ansible-core==2.13.10 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
ansible-lint==6.8.7 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
ansible==6.6.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
arrow==1.2.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
astroid==2.15.5 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
attrs==23.1.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
binaryornot==0.4.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
black==22.12.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
bracex==2.3.post1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
certifi==2023.5.7 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
cffi==1.15.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
cfgv==3.3.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
chardet==5.1.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
charset-normalizer==3.1.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
click-help-colors==0.9.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
click==8.1.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
colorama==0.4.6 ; python_version >= "3.9" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows"
|
||||||
|
cookiecutter==2.1.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
cryptography==46.0.6 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
dill==0.3.6 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
distlib==0.3.6 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
enrich==1.2.7 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
filelock==3.12.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
flake8==6.0.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
identify==2.5.24 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
idna==3.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
isort==5.12.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
jinja2-time==0.2.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
jinja2==3.1.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
jsonschema==4.17.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
lazy-object-proxy==1.9.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
mccabe==0.7.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
molecule-plugins[vagrant]==23.4.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
molecule==5.0.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
molecule[docker]==5.0.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
mypy-extensions==0.4.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
nodeenv==1.8.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
packaging==23.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pathspec==0.11.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
platformdirs==2.6.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pluggy==0.13.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pre-commit==2.21.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pycodestyle==2.10.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pycparser==2.21 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pyflakes==3.0.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pygments==2.20.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pylint==2.17.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pyrsistent==0.19.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
python-slugify==8.0.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
python-vagrant==1.0.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pyyaml==5.4.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
requests==2.31.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
resolvelib==0.5.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
rich==13.4.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
ruamel-yaml-clib==0.2.7 ; platform_python_implementation == "CPython" and python_version < "3.12" and python_version >= "3.9"
|
||||||
|
ruamel-yaml==0.17.31 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
setuptools==67.8.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
six==1.16.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
subprocess-tee==0.4.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
text-unidecode==1.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
tomli==1.2.3 ; python_version >= "3.9" and python_full_version < "3.11.0a7"
|
||||||
|
tomlkit==0.11.8 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
typing-extensions==4.6.3 ; python_version >= "3.9" and python_version < "3.11"
|
||||||
|
urllib3==1.26.16 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
virtualenv==20.21.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
wcmatch==8.4.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
wrapt==1.15.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
yamllint==1.32.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
ansible-core==2.13.10 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
ansible==6.6.0 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
cffi==1.15.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
cryptography==46.0.6 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
jinja2==3.1.2 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
packaging==23.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pycparser==2.21 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
pyyaml==5.4.1 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
|
resolvelib==0.5.4 ; python_version >= "3.9" and python_version < "4.0"
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#!/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
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
---
|
||||||
|
- name: amazon | check for nvme devices
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -o pipefail
|
||||||
|
cat /proc/partitions | awk '{print $4}' | grep -q nvme. ; echo $?
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
register: blkdev_nvme
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: amazon | check for amazon ebs devices
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -o pipefail
|
||||||
|
lsblk -O -J | grep -qi "amazon elastic block store" ; echo $?
|
||||||
|
register: blkdev_awsebs
|
||||||
|
changed_when: false
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
|
|
||||||
|
- name: amazon | set flag for nvme subsystem
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
device_is_nvme: "{{ true if (blkdev_nvme.stdout == '0') else false }}"
|
||||||
|
|
||||||
|
- name: amazon | set flag for aws ebs devices
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
device_is_awsebs: "{{ true if (blkdev_awsebs.stdout == '0') else false }}"
|
||||||
|
|
||||||
|
- name: Block to map renamed ec2 ebs nvmeXnY devices to their original sdX/xvdX names
|
||||||
|
when: device_is_nvme and device_is_awsebs|bool
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
|
- name: amazon | download nvme mapping binary helper
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ ebsnvme_binary_helper_url }}"
|
||||||
|
dest: "{{ ebsnvme_binary_helper_tmp }}/"
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: amazon | extract binary helper
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
src: "{{ ebsnvme_binary_helper_tmp }}/{{ ebsnvme_binary_helper_file }}"
|
||||||
|
dest: "{{ ebsnvme_binary_helper_tmp }}/"
|
||||||
|
remote_src: yes
|
||||||
|
mode: 0755
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: amazon | copy binary helper
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ ebsnvme_binary_helper_tmp }}/go-ebsnvme"
|
||||||
|
dest: "{{ ebsnvme_binary_helper_path }}"
|
||||||
|
mode: a+x
|
||||||
|
remote_src: yes
|
||||||
|
|
||||||
|
- name: amazon | template script helper
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "ebsnvme-id.j2"
|
||||||
|
dest: "{{ ebsnvme_scrip_helper_path }}"
|
||||||
|
mode: a+x
|
||||||
|
|
||||||
|
- name: amazon | template udev rule
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "70-ec2-nvme-devices.rules.j2"
|
||||||
|
dest: "/etc/udev/rules.d/70-ec2-nvme-devices.rules"
|
||||||
|
mode: 0755
|
||||||
|
register: udev_rule
|
||||||
|
|
||||||
|
- name: amazon | reload and trigger udev rules # noqa no-changed-when no-handler
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: udevadm control --reload-rules && udevadm trigger
|
||||||
|
when: udev_rule.changed
|
||||||
+60
-33
@@ -1,43 +1,70 @@
|
|||||||
---
|
---
|
||||||
- name: centos | installing lvm2
|
- name: centos | installing lvm2 and sg3_utils
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: "lvm2"
|
name:
|
||||||
state: "present"
|
- lvm2
|
||||||
|
- sg3_utils
|
||||||
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: centos | installing sg3_utils
|
- name: Specific tasks for Amazon EC2
|
||||||
package:
|
ansible.builtin.include_tasks: amazon.yml
|
||||||
name: "sg3_utils"
|
when: ansible_facts.system_vendor == 'Amazon EC2'
|
||||||
state: "present"
|
|
||||||
become: true
|
- name: centos | debug lvg
|
||||||
|
ansible.builtin.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
|
- name: centos | install xfs tools
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: "xfsprogs"
|
name: "xfsprogs"
|
||||||
state: "present"
|
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: centos | checking for scsi devices
|
|
||||||
command: "sg_scan"
|
|
||||||
become: true
|
become: true
|
||||||
register: "scsi_devices"
|
loop: "{{ lookup('subelements', lvm_groups, 'lvnames', {'skip_missing': True}, wantlist=True) }}"
|
||||||
changed_when: False
|
loop_control:
|
||||||
|
loop_var: lv
|
||||||
|
when:
|
||||||
|
- lv.1 is defined
|
||||||
|
- lv.1 != "None"
|
||||||
|
- lv.1.filesystem is defined
|
||||||
|
- lv.1.filesystem == "xfs"
|
||||||
|
- lv.1.create is defined
|
||||||
|
- lv.1.create|bool
|
||||||
|
|
||||||
- name: centos | rescanning for new disks
|
- name: centos | check for scsi adapters
|
||||||
command: "/usr/bin/rescan-scsi-bus.sh"
|
ansible.builtin.find:
|
||||||
|
paths: "/sys/class/scsi_host"
|
||||||
|
file_type: any
|
||||||
become: true
|
become: true
|
||||||
changed_when: False
|
register: scsi_adapters
|
||||||
|
|
||||||
|
- name: centos | Check for new disks
|
||||||
|
when: scsi_adapters.matched > 0
|
||||||
|
block:
|
||||||
|
- name: centos | installing sg3_utils
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: sg3_utils
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: centos | checking for scsi devices
|
||||||
|
ansible.builtin.command: sg_scan
|
||||||
|
become: true
|
||||||
|
register: scsi_devices
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: centos | rescanning for new disks
|
||||||
|
ansible.builtin.command: "{{ rescan_scsi_command }}"
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
||||||
|
when: scsi_devices.stdout|length > 0
|
||||||
|
|
||||||
|
- name: centos | rescanning for resized disks
|
||||||
|
ansible.builtin.command: "{{ rescan_scsi_command }} -s"
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
||||||
|
when: scsi_devices.stdout|length > 0
|
||||||
|
|||||||
+77
-90
@@ -1,110 +1,97 @@
|
|||||||
---
|
---
|
||||||
- name: manage_lvm | unmounting filesystem(s)
|
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
|
||||||
mount:
|
- name: create_fs | 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...
|
||||||
|
ansible.builtin.shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
|
||||||
|
become: true
|
||||||
|
register: mountedxfs
|
||||||
|
ignore_errors: true
|
||||||
|
changed_when: false
|
||||||
|
when:
|
||||||
|
- lv is defined and lv != 'None'
|
||||||
|
- lv.filesystem is defined
|
||||||
|
- lv.filesystem == "xfs"
|
||||||
|
- lv.create is defined
|
||||||
|
- lv.create|bool
|
||||||
|
|
||||||
|
- name: create_fs | unmounting filesystem(s)
|
||||||
|
ansible.posix.mount:
|
||||||
path: "{{ lv.mntp }}"
|
path: "{{ lv.mntp }}"
|
||||||
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
||||||
fstype: "{{ lv.filesystem | default(omit) }}"
|
fstype: "{{ lv.filesystem | default(omit) }}"
|
||||||
state: "absent"
|
state: absent
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ vg.lvnames }}"
|
when:
|
||||||
loop_control:
|
- lv is defined
|
||||||
loop_var: lv
|
- lv != 'None'
|
||||||
when: >
|
- lv.create is defined
|
||||||
(lv is defined and
|
- not lv.create|bool
|
||||||
lv != 'None') and
|
- lv.filesystem != "swap"
|
||||||
(lv.create is defined and
|
|
||||||
not lv.create and
|
|
||||||
lv.filesystem != "swap")
|
|
||||||
|
|
||||||
- name: manage_lvm | creating new filesystem on new LVM logical volume(s)
|
- name: create_fs | creating new filesystem on new LVM logical volume(s)
|
||||||
filesystem:
|
community.general.filesystem:
|
||||||
fstype: "{{ lv.filesystem }}"
|
fstype: "{{ lv.filesystem }}"
|
||||||
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
||||||
resizefs: yes
|
resizefs: yes
|
||||||
loop: "{{ vg.lvnames }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: lv
|
|
||||||
become: true
|
become: true
|
||||||
when: >
|
when:
|
||||||
(
|
- vg.create is defined
|
||||||
(vg.create is defined and
|
- vg.create|bool
|
||||||
vg.create) and
|
- lv is defined
|
||||||
(lv is defined and
|
- lv != 'None'
|
||||||
lv != 'None') and
|
- lv.create is defined
|
||||||
(lv.create is defined and
|
- lv.create|bool
|
||||||
lv.create) and
|
- lv.filesystem is defined
|
||||||
(
|
- lv.filesystem != 'None'
|
||||||
lv.filesystem is defined and
|
- lv.filesystem != 'swap'
|
||||||
lv.filesystem != 'None' and
|
- lv.filesystem != 'xfs'
|
||||||
lv.filesystem != 'xfs'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
|
|
||||||
|
|
||||||
- name: lvm | check already converted
|
- name: create_fs | creating new xfs filesystem on new LVM logical volume(s)
|
||||||
# at least xfs is executed twice if the partition has changed in the meantime
|
community.general.filesystem:
|
||||||
# then it tries to recreate the fs on the mounted fs which indeed fails...
|
|
||||||
shell: "xfs_info /dev/{{ vg.vgname }}/{{ lv.lvname }} | 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 }}"
|
fstype: "{{ lv.filesystem }}"
|
||||||
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
||||||
loop: "{{ vg.lvnames }}"
|
opts: "{{ lv.fsopts | default(omit) }}"
|
||||||
loop_control:
|
|
||||||
loop_var: lv
|
|
||||||
become: true
|
become: true
|
||||||
when: >
|
when:
|
||||||
(
|
- mountedxfs is failed
|
||||||
mountedxfs is failed and
|
- vg.create is defined
|
||||||
(vg.create is defined and
|
- vg.create|bool
|
||||||
vg.create) and
|
- lv is defined
|
||||||
(lv is defined and
|
- lv != 'None'
|
||||||
lv != 'None') and
|
- lv.create is defined
|
||||||
(lv.create is defined and
|
- lv.create|bool
|
||||||
lv.create) and
|
- lv.filesystem is defined
|
||||||
(
|
- lv.filesystem == 'xfs'
|
||||||
lv.filesystem is defined and
|
|
||||||
lv.filesystem == 'xfs'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
- name: manage_lvm | mounting new filesystem(s)
|
- name: create_fs | mounting new filesystem(s)
|
||||||
mount:
|
ansible.posix.mount:
|
||||||
path: "{{ lv.mntp }}"
|
path: "{{ lv.mntp }}"
|
||||||
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
|
||||||
fstype: "{{ lv.filesystem }}"
|
fstype: "{{ lv.filesystem }}"
|
||||||
state: "mounted"
|
state: mounted
|
||||||
opts: "{{ lv.mopts | default('defaults') }}"
|
opts: "{{ lv.mopts | default('defaults') }}"
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ vg.lvnames }}"
|
when:
|
||||||
loop_control:
|
- vg.create is defined
|
||||||
loop_var: lv
|
- vg.create|bool
|
||||||
when: >
|
- lv is defined
|
||||||
((vg.create is defined and
|
- lv != 'None'
|
||||||
vg.create) and
|
- lv.create is defined
|
||||||
lv != 'None' and
|
- lv.create|bool
|
||||||
(lv.create is defined and
|
- lv.mount is defined
|
||||||
lv.create) and
|
- lv.mount|bool
|
||||||
(lv.mount is defined and
|
|
||||||
lv.mount))
|
- name: create_fs | resizing xfs filesystem on new LVM logical volume(s) # noqa no-changed-when
|
||||||
|
ansible.builtin.command: "xfs_growfs {{ lv.mntp }}"
|
||||||
|
become: true
|
||||||
|
when:
|
||||||
|
- vg.create is defined
|
||||||
|
- vg.create|bool
|
||||||
|
- lv is defined
|
||||||
|
- lv != 'None'
|
||||||
|
- lv.create is defined
|
||||||
|
- lv.create|bool
|
||||||
|
- lv.filesystem is defined
|
||||||
|
- lv.filesystem == 'xfs'
|
||||||
|
- lvchanged.changed
|
||||||
|
|||||||
+23
-23
@@ -1,30 +1,30 @@
|
|||||||
---
|
---
|
||||||
- debug: var=vg
|
- name: create_lv | Display Volume Group
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: vg
|
||||||
|
verbosity: 2
|
||||||
|
|
||||||
- name: "debug lvm"
|
- name: create_lv | creating new LVM logical volume(s)
|
||||||
loop: "{{ vg.lvnames }}"
|
community.general.lvol:
|
||||||
debug: var=lv
|
|
||||||
loop_control:
|
|
||||||
loop_var: lv
|
|
||||||
|
|
||||||
- name: manage_lvm | creating new LVM logical volume(s)
|
|
||||||
lvol:
|
|
||||||
vg: "{{ vg.vgname }}"
|
vg: "{{ vg.vgname }}"
|
||||||
lv: "{{ lv.lvname }}"
|
lv: "{{ lv.lvname }}"
|
||||||
size: "{{ lv.size }}"
|
size: "{{ lv.size }}"
|
||||||
shrink: no
|
shrink: false
|
||||||
opts: "{{ lv.opts | default('') }}"
|
opts: "{{ lv.opts | default('') }}"
|
||||||
state: "present"
|
state: present
|
||||||
loop: "{{ vg.lvnames }}"
|
|
||||||
loop_control:
|
|
||||||
loop_var: lv
|
|
||||||
become: true
|
become: true
|
||||||
when: >
|
register: lvchanged
|
||||||
(
|
when:
|
||||||
(vg.create is defined
|
- vg.create is defined
|
||||||
and vg.create) and
|
- vg.create|bool
|
||||||
(lv is defined and
|
- lv is defined
|
||||||
lv != 'None') and
|
- lv != 'None'
|
||||||
(lv.create is defined and
|
- lv.create is defined
|
||||||
lv.create)
|
- lv.create|bool
|
||||||
)
|
|
||||||
|
- name: create_lv | debug changed attribute
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: lvchanged
|
||||||
|
|
||||||
|
- name: create_lv | configuring FS
|
||||||
|
ansible.builtin.include_tasks: create_fs.yml
|
||||||
|
|||||||
+15
-10
@@ -1,12 +1,17 @@
|
|||||||
---
|
---
|
||||||
|
- name: create_vg | creating new LVM volume group(s)
|
||||||
- name: manage_lvm | creating new LVM volume group(s)
|
community.general.lvg:
|
||||||
lvg:
|
vg: "{{ vg.vgname }}"
|
||||||
vg: "{{ item.vgname }}"
|
pvs: "{{ vg.disks | join(',') }}"
|
||||||
pvs: "{{ item.disks | join(',') }}"
|
state: present
|
||||||
state: "present"
|
pvresize: "{{ vg.pvresize | default(pvresize_to_max) }}"
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ lvm_groups }}"
|
when:
|
||||||
when: >
|
- vg.create is defined
|
||||||
item.create is defined and
|
- vg.create|bool
|
||||||
item.create
|
|
||||||
|
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
|
||||||
|
ansible.builtin.include_tasks: create_lv.yml
|
||||||
|
loop: "{{ vg.lvnames | default([]) }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: lv
|
||||||
|
|||||||
+24
-24
@@ -1,40 +1,40 @@
|
|||||||
---
|
---
|
||||||
|
- name: debian | Updating Apt Cache
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: debian | installing pre-reqs
|
- name: debian | installing pre-reqs
|
||||||
package:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- lvm2
|
- lvm2
|
||||||
- scsitools
|
- scsitools
|
||||||
state: "present"
|
state: present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: debian | install xfs tools
|
- name: debian | install xfs tools
|
||||||
package:
|
ansible.builtin.apt:
|
||||||
name: "xfsprogs"
|
name: xfsprogs
|
||||||
state: "present"
|
state: present
|
||||||
become: yes
|
become: true
|
||||||
loop: "{{ lvm_groups|subelements('lvnames') }}"
|
loop: "{{ lvm_groups | subelements('lvnames') }}"
|
||||||
when: >
|
when:
|
||||||
(
|
- item.1 is defined
|
||||||
(item.1 is defined and item.1 != 'None') and
|
- item.1 != 'None'
|
||||||
(
|
- item.1.filesystem is defined
|
||||||
item.1.filesystem is defined and
|
- item.1.filesystem == "xfs"
|
||||||
item.1.filesystem == "xfs"
|
- item.1.create is defined
|
||||||
)
|
- item.1.create|bool
|
||||||
and
|
|
||||||
(
|
|
||||||
item.1.create is defined and
|
|
||||||
item.1.create
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
- name: debian | checking for scsi devices
|
- name: debian | checking for scsi devices
|
||||||
command: "sg_scan"
|
ansible.builtin.command: sg_scan
|
||||||
become: true
|
become: true
|
||||||
register: "scsi_devices"
|
register: scsi_devices
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: debian | rescanning for new disks added
|
- name: debian | rescanning for new disks added
|
||||||
command: "/sbin/rescan-scsi-bus"
|
ansible.builtin.command: "{{ rescan_scsi_command }}"
|
||||||
become: true
|
become: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: scsi_devices['stdout'] | length
|
when: scsi_devices['stdout'] | length > 0
|
||||||
|
|||||||
+19
-8
@@ -1,12 +1,23 @@
|
|||||||
---
|
---
|
||||||
# tasks file for ansible-manage-lvm
|
# tasks file for ansible-manage-lvm
|
||||||
- include_tasks: debian.yml
|
- name: Set rescan_scsi_command for old debian version
|
||||||
when: ansible_os_family == "Debian"
|
ansible.builtin.set_fact:
|
||||||
|
rescan_scsi_command: "/sbin/rescan-scsi-bus"
|
||||||
|
when:
|
||||||
|
- ansible_facts.distribution | replace(' ','') | lower == 'debian'
|
||||||
|
- ansible_facts.distribution_release not in ('bookworm', 'sid')
|
||||||
|
- ansible_facts.distribution_major_version is version(10, '<=')
|
||||||
|
|
||||||
- include_tasks: centos.yml
|
- name: Debian specific tasks
|
||||||
when: ansible_os_family == "RedHat"
|
ansible.builtin.include_tasks: debian.yml
|
||||||
|
when: ansible_facts.os_family == "Debian"
|
||||||
|
|
||||||
- include_tasks: manage_lvm.yml
|
- name: RHEL specific tasks
|
||||||
when: >
|
ansible.builtin.include_tasks: centos.yml
|
||||||
manage_lvm and
|
when: ansible_facts.os_family == "RedHat"
|
||||||
lvm_groups is defined
|
|
||||||
|
- name: Manage LVM
|
||||||
|
ansible.builtin.include_tasks: manage_lvm.yml
|
||||||
|
when:
|
||||||
|
- lvm_groups is defined
|
||||||
|
- manage_lvm|bool
|
||||||
|
|||||||
+15
-24
@@ -1,40 +1,31 @@
|
|||||||
---
|
---
|
||||||
- name: manage_lvm | manage physical volume group creation
|
- name: manage_lvm | manage physical volume group creation
|
||||||
include_tasks: create_vg.yml
|
ansible.builtin.include_tasks: create_vg.yml
|
||||||
|
|
||||||
- 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 | loop over logical volume group(s) to create filesystems
|
|
||||||
include_tasks: create_fs.yml
|
|
||||||
loop: "{{ lvm_groups }}"
|
loop: "{{ lvm_groups }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: vg
|
loop_var: vg
|
||||||
|
|
||||||
- name: manage_lvm | Removing LVM logical volume(s)
|
- name: manage_lvm | Removing LVM logical volume(s)
|
||||||
lvol:
|
community.general.lvol:
|
||||||
vg: "{{ item.0.vgname }}"
|
vg: "{{ item.0.vgname }}"
|
||||||
lv: "{{ item.1.lvname }}"
|
lv: "{{ item.1.lvname }}"
|
||||||
state: "absent"
|
state: absent
|
||||||
force: yes
|
force: true
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ lvm_groups|subelements('lvnames') }}"
|
loop: "{{ lvm_groups | subelements('lvnames', {'skip_missing': true}) }}"
|
||||||
when: >
|
when:
|
||||||
(item.1 is defined and
|
- item.1 is defined
|
||||||
item.1 != 'None') and
|
- item.1 != 'None'
|
||||||
(item.1.create is defined and
|
- item.1.create is defined
|
||||||
not item.1.create)
|
- not item.1.create|bool
|
||||||
|
|
||||||
- name: manage_lvm | Removing LVM volume group(s)
|
- name: manage_lvm | Removing LVM volume group(s)
|
||||||
lvg:
|
community.general.lvg:
|
||||||
vg: "{{ item.vgname }}"
|
vg: "{{ item.vgname }}"
|
||||||
pvs: "{{ item.disks | join(',') }}"
|
pvs: "{{ item.disks | join(',') }}"
|
||||||
state: "absent"
|
state: absent
|
||||||
become: true
|
become: true
|
||||||
loop: "{{ lvm_groups }}"
|
loop: "{{ lvm_groups }}"
|
||||||
when: >
|
when:
|
||||||
item.create is defined and
|
- item.create is defined
|
||||||
not item.create
|
- not item.create|bool
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# ebs nvme to scsi device naming mapping
|
||||||
|
KERNEL=="nvme[0-9]*n[0-9]*", ENV{DEVTYPE}=="disk", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM="{{ ebsnvme_scrip_helper_path }} /dev/%k", SYMLINK+="%c"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# This script uses go version of ebsnvme-id to provide
|
||||||
|
# SCSI Disk device name links for nvme devices
|
||||||
|
#
|
||||||
|
# links:
|
||||||
|
#
|
||||||
|
# https://www.logicworks.com/blog/2018/03/manage-aws-ebs-volumes-c5-m5-puppet-chef-ansible/
|
||||||
|
# https://github.com/mvisonneau/go-ebsnvme
|
||||||
|
# https://gist.github.com/lbernail/d851e5b06eb32180a4b8ead2ce4f45db
|
||||||
|
# and working forks like:
|
||||||
|
# (keenan-v1/ebsnvme-id) https://gist.github.com/keenan-v1/aee92cd7383ee02de2a817a004917a03
|
||||||
|
#
|
||||||
|
|
||||||
|
{{ ebsnvme_binary_helper_path }} -n $1 | awk -F '/' '{print $3}'
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
skip_list: ['305','503','602']
|
skip_list: ['305', '503', '602']
|
||||||
|
|||||||
+5
-4
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
- hosts: localhost
|
# - name: Test role
|
||||||
connection: local
|
# hosts: localhost
|
||||||
roles:
|
# connection: local
|
||||||
- ansible-manage-lvm
|
# roles:
|
||||||
|
# - role: ansible-manage-lvm
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
---
|
---
|
||||||
# vars file for ansible-manage-lvm
|
# vars file for ansible-manage-lvm
|
||||||
|
|
||||||
|
ebsnvme_binary_helper_file: go-ebsnvme_{{ ebsnvme_binary_helper_ver }}_linux_amd64.tar.gz
|
||||||
|
ebsnvme_binary_helper_url: https://github.com/mvisonneau/go-ebsnvme/releases/download/{{ ebsnvme_binary_helper_ver }}/{{ ebsnvme_binary_helper_file }}
|
||||||
|
|
||||||
|
rescan_scsi_command: "/usr/bin/rescan-scsi-bus.sh"
|
||||||
|
|||||||
Reference in New Issue
Block a user