61 Commits

Author SHA1 Message Date
Larry Smith Jr
ea2e60f043 Merge pull request #96 from mnasiadka/ansible_facts_distribution
Change ansible_distribution usage to ansible_facts
2022-10-19 15:13:46 -04:00
Michal Nasiadka
a28791cc48 Change ansible_distribution usage to ansible_facts
Closes #95
2022-10-13 15:55:07 +02:00
Larry Smith Jr
ca903442c8 Merge pull request #89 from msielicki/master
skip resizing swap filesystem
2022-05-30 09:01:51 -04:00
Larry Smith Jr
9e69c74f71 Merge pull request #91 from msielicki/fix_for_debian_testing
fix for debian testing / sid
2022-05-30 09:01:41 -04:00
Mariusz Sielicki
e9ff7e3faf fix for debian testing / sid 2022-05-27 18:23:17 +02:00
Mariusz Sielicki
84bfdf54ad skip resizing swap filesystem 2022-05-27 17:56:09 +02:00
Larry Smith Jr
376f2ce641 Merge pull request #86 from smutel/FixIssue85
Add variable rescan_scsi_command
2022-04-26 09:30:50 -04:00
Samuel Mutel
6e74c9714e enh: Add variable rescan_scsi_command 2022-04-11 13:49:46 +02:00
Larry Smith Jr
1f966d2ea1 Merge pull request #81 from christian7007/master 2022-01-13 08:39:41 -05:00
Christian González
71a3930e5b Fix syntax error on tasks/centos.yml 2022-01-13 10:50:13 +01:00
Larry Smith Jr
263c8d2b3f Merge pull request #73 from mnasiadka/mnasiadka/nvme_only
centos: Skip SCSI tasks on NVMe only hosts
2022-01-04 14:47:16 -05:00
Michal Nasiadka
0bfd390ace centos: Skip SCSI tasks on NVMe only hosts 2021-12-10 15:01:59 +01:00
Larry Smith Jr
71bc56d733 Merge pull request #70 from cityofships/optimize
CentOS: Optimise package installs
2021-11-22 15:12:41 -05:00
Larry Smith Jr
59ca2aae95 Pythonr reqs exported after #69 2021-11-22 14:29:40 -05:00
Piotr Parczewski
cb3a75c984 CentOS: Optimise package installs 2021-11-22 20:27:27 +01:00
Larry Smith Jr
fae4332de8 Merge pull request #69 from mrlesmithjr/dependabot/pip/ansible-4.2.0
Bump ansible from 2.9.7 to 4.2.0
2021-11-22 14:23:45 -05:00
Larry Smith Jr
3ea52cdda8 Merge pull request #76 from mrlesmithjr:mrlesmithjr/issue75_Add-Ansible-Galaxy-release-workflow
Add Ansible Galaxy release workflow
2021-11-22 14:19:00 -05:00
Larry Smith Jr
2d020f26d8 Add Ansible Galaxy release workflow
Fixes #75
2021-11-22 14:16:03 -05:00
dependabot[bot]
558cd7460e Bump ansible from 2.9.7 to 4.2.0
Bumps [ansible](https://github.com/ansible/ansible) from 2.9.7 to 4.2.0.
- [Release notes](https://github.com/ansible/ansible/releases)
- [Commits](https://github.com/ansible/ansible/commits)

---
updated-dependencies:
- dependency-name: ansible
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-22 19:15:36 +00:00
Larry Smith Jr
3b00335935 Merge pull request #72 from mrlesmithjr/mrlesmithjr/issue71_Fix-Galaxy-meta-info 2021-11-22 14:12:18 -05:00
Larry Smith Jr
ac014a161e Fix Python version 2021-11-22 14:00:46 -05:00
Larry Smith Jr
9446ef21d6 Fix Galaxy meta info
Fixes #71
2021-11-22 13:56:40 -05:00
Larry Smith Jr
97300430ad Fix Galaxy meta info
Fixes #71
2021-11-22 08:48:18 -05:00
Larry Smith Jr
73db3c747c Merge pull request #68 from stackhpc/ansible-facts
Use ansible_facts to reference facts
2021-07-26 14:25:57 -04:00
Mark Goddard
73b6bce608 Use ansible_facts to reference facts
By default, Ansible injects a variable for every fact, prefixed with
ansible_. This can result in a large number of variables for each host,
which at scale can incur a performance penalty. Ansible provides a
configuration option [0] that can be set to False to prevent this
injection of facts. In this case, facts should be referenced via
ansible_facts.<fact>.

This change updates all references to Ansible facts from using
individual fact variables to using the items in the
ansible_facts dictionary. This allows users to disable fact variable
injection in their Ansible configuration, which may provide some
performance improvement.

[0] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars
2021-05-13 17:21:42 +01:00
Larry Smith Jr
098bd79154 Merge pull request #64 from mrlesmithjr/issue-63-Add_Probot_configs_for_new_apps
Closes Add Probot configs for new apps #63
2021-04-23 20:58:39 -04:00
Larry Smith Jr
fddf9804dd Closes Add Probot configs for new apps #63 2021-04-23 20:56:44 -04:00
Larry Smith Jr
506da4707e Create stale.yml 2021-04-23 00:20:15 -04:00
Larry Smith Jr
773ce28061 Merge pull request #57 from Roxyrob/issue-51-nvme
mitigation for aws ec2 nvme random device name assignment + scsi device rescan + auto pvresize + skip scsi if scsi adapter not installed
2021-04-18 08:49:45 -04:00
Roxyrob
1bb56066fe * Doc: set subfile task comments 2021-03-19 19:28:54 +01:00
Roxyrob
cb792e59a6 * Refactor: aws code in its own tasks file to mitigate concerns about performance at scale 2021-03-18 15:38:22 +01:00
Roxyrob
48e3be3c5c * Refactor: task comment review 2021-03-17 13:46:10 +01:00
Roxyrob
2492c96566 * Fix: allow automatic pvresize also for ansible ersion 2.10 or above without new lvg collection version installed 2021-03-17 10:01:24 +01:00
Roxyrob
e4bc8a9e9b * Fix: lint 2021-03-17 01:40:26 +01:00
Roxyrob
1d57a469b0 * Fix: pvresize waiting for new collection lvg native support 2021-03-17 01:29:14 +01:00
Roxyrob
19e56ac7d8 * Fix: improve centos7/8 recognize scsi disk resize without reboot 2021-03-17 01:24:15 +01:00
Roxyrob
5c3e601078 * Fix: lint 2021-03-17 01:13:53 +01:00
Roxyrob
535b410363 * Fix: follow best practice for pipe in shell command 2021-03-16 23:24:24 +01:00
Roxyrob
f87c42a8c5 * Fix: remove too many blank lines (molecule) 2021-03-16 20:28:13 +01:00
Roxyrob
34e4f08c31 * New: support mitigation for aws ec2 nvme random device name assignment 2021-03-16 19:41:37 +01:00
Larry Smith Jr
f1a54639c6 Merge pull request #48 from Tcharl/rebased
XFS resize
2020-06-07 20:05:35 -04:00
Larry Smith Jr
88489df0ac Merge pull request #45 from OsgiliathEnterprise/master
Allow to define only volume groups
2020-06-07 20:05:22 -04:00
Charlie Mordant
b288695b9a lint 2020-06-07 17:25:33 +02:00
Charlie Mordant
ed0eb14ce8 xfs resize 2020-06-07 17:17:48 +02:00
Charlie Mordant
9c04be9046 Merge pull request #14 from OsgiliathEnterprise/rebased
Rebased from upstream
2020-05-15 00:03:37 +02:00
Charlie Mordant
96fd3b2b06 rebase done 2020-05-14 23:46:35 +02:00
Charlie Mordant
15b2b7b4e0 rebased mrjsmith 2020-05-14 23:43:59 +02:00
Charlie Mordant
79f4787208 Merge pull request #13 from Tcharl/master
Merge pull request #5 from Tcharl/id2
2020-05-11 18:44:01 +02:00
Charlie Mordant
94582de25d use symbolic links instead of replicating files 2020-05-11 17:38:02 +02:00
Charlie Mordant
6ee72799b4 improve tests 2020-05-11 17:09:58 +02:00
Charlie Mordant
69e25effd4 improve tests 2020-05-11 16:56:04 +02:00
Charlie Mordant
62fc5a5e2b testing singl lv and only vg 2020-05-11 16:35:31 +02:00
Charlie Mordant
c40f9b7d03 testing singl lv and only vg 2020-05-11 16:35:00 +02:00
Charlie Mordant
0621cadde8 avoid error when lv not defined 2020-05-11 14:36:04 +02:00
Charlie Mordant
b7cef8e323 avoid error when lv not defined 2020-05-11 14:26:48 +02:00
Charlie Mordant
59ffcfac4a avoid error when lv not defined 2020-05-11 14:23:32 +02:00
Charlie Mordant
976ff31d00 avoid error when lv not defined 2020-05-11 14:21:02 +02:00
Charlie Mordant
78205e51cb Merge pull request #12 from Tcharl/id2
rename manage_lvm.yml due to recursive parsing error
2020-05-11 13:53:03 +02:00
Charlie Mordant
b731c20100 rename manage_lvm.yml due to recursive parsing error 2020-05-11 13:51:45 +02:00
Charlie Mordant
f2df804926 Merge pull request #11 from OsgiliathEnterprise/id2
Id2
2020-05-11 13:39:16 +02:00
Charlie Mordant
1e997a3e80 Merge pull request #5 from Tcharl/id2
xfs support on centos
2020-04-23 19:56:02 +02:00
41 changed files with 2852 additions and 174 deletions

1
.ansible-lint Normal file
View File

@@ -0,0 +1 @@
skip_list: []

3
.flake8 Normal file
View File

@@ -0,0 +1,3 @@
[flake8]
exclude = .venv/
max-line-length = 88

14
.github/config.yml vendored Normal file
View File

@@ -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

32
.github/release-drafter.yml vendored Normal file
View File

@@ -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

10
.github/settings.yml vendored Normal file
View File

@@ -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

17
.github/stale.yml vendored Normal file
View File

@@ -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

View File

@@ -1,41 +1,46 @@
---
# 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:
branches-ignore:
- main
- master
pull_request:
branches:
- develop
- main
- 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
runs-on: macos-10.15
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version: [3.8]
# 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
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
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
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: molecule lint
run: |
molecule lint

17
.github/workflows/release-drafter.yml vendored Normal file
View File

@@ -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 }}

34
.github/workflows/release-galaxy.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
---
name: Ansible Galaxy
on:
push:
branches:
- main
- master
release:
types:
- published
jobs:
galaxy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
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: Trigger a new import on Galaxy.
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)

2
.gitignore vendored
View File

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

View File

@@ -26,5 +26,7 @@ before_install:
script:
- |
sudo molecule test --scenario-name kvm
sudo molecule test --scenario-name kvmsinglelv
sudo molecule test --scenario-name kvmonlyvg
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -3,7 +3,7 @@
extends: default
ignore: |
venv/
.venv/
rules:
braces:

View File

@@ -61,3 +61,17 @@ lvm_groups: []
# Defines if LVM will be managed by role
# default is false to ensure nothing is changed by accident.
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'
### auto pvresize (waiting until ansible 2.10 or above as collections have new lvg with integrated pvresize)
### waiting for new module in collection set to true or run pvresize manually on remote systems
### https://docs.ansible.com/ansible/3/collections/community/general/lvg_module.html
###
pvresize_to_max: false

View File

@@ -2,6 +2,8 @@
galaxy_info:
author: Larry Smith Jr.
description: Ansible role to manage(create, extend, resize) LVM Groups/Logical Volumes.
namespace: mrlesmithjr
role_name: manage-lvm
license: MIT
min_ansible_version: 1.2

View File

@@ -15,7 +15,7 @@
filesystem: ext4
mount: true
mntp: "/var/lib/mountpoint"
- lvname: my_lv2
- lvname: my_lw
size: 20%VG
opts: "--wipesignatures y"
mount: true

View File

@@ -3,7 +3,10 @@ driver:
name: vagrant
provider:
name: virtualbox
lint: yamllint . && flake8 && ansible-lint
lint: |
yamllint .
ansible-lint
flake8
platforms:
- name: CentOS-Molecule-LVM
box: mrlesmithjr/centos7

View File

@@ -18,6 +18,13 @@ def test_mylv_logical_volume_is_created(host):
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

View File

@@ -15,7 +15,7 @@
filesystem: ext4
mount: true
mntp: "/var/lib/mountpoint"
- lvname: my_lv2
- lvname: my_lw
size: 20%VG
opts: "--wipesignatures y"
mount: true

View File

@@ -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"
include_role:
name: "ansible-manage-lvm"

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: kvmonlyvg

View File

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

View File

@@ -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

View File

@@ -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"
include_role:
name: "ansible-manage-lvm"

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: kvmsinglelv

View File

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

View File

@@ -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

2174
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

30
pyproject.toml Normal file
View File

@@ -0,0 +1,30 @@
[tool.poetry]
name = "ansible-manage-lvm"
version = "0.1.0"
description = ""
authors = ["Larry Smith Jr. <mrlesmithjr@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.10"
ansible = "4.2.0"
[tool.poetry.dev-dependencies]
bandit = "^1.7.1"
black = "^21.11b1"
flake8 = "^4.0.1"
mypy = "^0.910"
poetry = "^1.1.11"
pylint = "^2.11.1"
ansible-lint = "4.2.0"
yamllint = "1.23.0"
mkdocs = "^1.2.3"
autopep8 = "^1.6.0"
pycodestyle = "^2.8.0"
pip-tools = "^6.4.0"
molecule = "3.0.3"
molecule-vagrant = "0.2"
pre-commit = "^2.15.0"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

View File

@@ -1,66 +1,114 @@
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
ansible-core==2.11.6; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
ansible-lint==4.2.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
ansible==4.2.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
arrow==1.2.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
astroid==2.8.6; python_version >= "3.6" and python_version < "4.0"
autopep8==1.6.0
backports.entry-points-selectable==1.1.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "2.7"
bandit==1.7.1; python_version >= "3.5"
bcrypt==3.2.0; python_version >= "3.6"
binaryornot==0.4.4; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
black==21.11b1; python_full_version >= "3.6.2"
cachecontrol==0.12.10; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
cachy==0.3.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
cerberus==1.3.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
certifi==2021.10.8; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
cffi==1.15.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
cfgv==3.3.1; python_full_version >= "3.6.1"
chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
charset-normalizer==2.0.7; python_full_version >= "3.6.0" and python_version >= "3"
cleo==0.8.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
click-completion==0.5.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
click-help-colors==0.9.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
click==8.0.3; python_version >= "3.6" and python_full_version >= "3.6.2" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6")
clikit==0.6.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
colorama==0.4.4; platform_system == "Windows" and python_version >= "3.6" and python_full_version >= "3.6.2" and python_version < "4.0" and sys_platform == "win32" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6")
cookiecutter==1.7.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
crashtest==0.3.1; python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0")
cryptography==36.0.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") and sys_platform == "linux" or python_full_version >= "3.5.0" and python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") and sys_platform == "linux"
distlib==0.3.3; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
distro==1.6.0; python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "linux" or python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "linux2" or sys_platform == "linux" and python_version >= "3.6" and python_full_version >= "3.4.0" or sys_platform == "linux2" and python_version >= "3.6" and python_full_version >= "3.4.0"
fasteners==0.16.3; python_version >= "3.6"
filelock==3.4.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
flake8==4.0.1; python_version >= "3.6"
ghp-import==2.0.2; python_version >= "3.6"
gitdb==4.0.9; python_version >= "3.7"
gitpython==3.1.24; python_version >= "3.7"
html5lib==1.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
identify==2.4.0; python_full_version >= "3.6.1"
idna==3.3; python_version >= "3.5" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.5"
importlib-metadata==4.8.2; python_version >= "3.6"
isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0" and python_version >= "3.6"
jeepney==0.7.1; python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") and sys_platform == "linux"
jinja2-time==0.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
jinja2==3.0.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
keyring==21.8.0; python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0")
lazy-object-proxy==1.6.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.0"
lockfile==0.12.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
markdown==3.3.6; python_version >= "3.6"
markupsafe==2.0.1; python_version >= "3.6"
mccabe==0.6.1; python_version >= "3.6" and python_version < "4.0"
mergedeep==1.3.4; python_version >= "3.6"
mkdocs==1.2.3; python_version >= "3.6"
molecule-vagrant==0.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
molecule==3.0.3; python_version >= "3.6"
msgpack==1.0.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
mypy-extensions==0.4.3; python_full_version >= "3.6.2" and python_version >= "3.5"
mypy==0.910; python_version >= "3.5"
nodeenv==1.6.0; python_full_version >= "3.6.1"
packaging==20.9; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
paramiko==2.8.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pastel==0.2.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pathspec==0.9.0; python_full_version >= "3.6.2" and python_version >= "3.6"
pbr==5.8.0; python_version >= "3.6"
pep517==0.12.0; python_version >= "3.6"
pexpect==4.8.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pip-tools==6.4.0; python_version >= "3.6"
pkginfo==1.8.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
platformdirs==2.4.0; python_version >= "3.6" and python_full_version >= "3.6.2" and python_version < "4.0" and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6")
pluggy==0.13.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
poetry-core==1.0.7; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
poetry==1.1.11; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
poyo==0.5.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pre-commit==2.15.0; python_full_version >= "3.6.1"
ptyprocess==0.7.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pycodestyle==2.8.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
pycparser==2.21; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pyflakes==2.4.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
pylev==1.4.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pylint==2.11.1; python_version >= "3.6" and python_version < "4.0"
pynacl==1.4.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
pyparsing==3.0.6; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
python-gilt==1.2.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
python-slugify==5.0.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
python-vagrant==0.5.15; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pywin32-ctypes==0.2.0; python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") and sys_platform == "win32"
pyyaml-env-tag==0.1; python_version >= "3.6"
pyyaml==5.4.1; python_full_version >= "3.6.1" and python_version >= "3.6" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0") and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")
regex==2021.11.10; python_full_version >= "3.6.2"
requests-toolbelt==0.9.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
requests==2.26.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6"
resolvelib==0.5.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
ruamel.yaml==0.17.17; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
secretstorage==3.3.1; python_version >= "3.6" and python_version < "4.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") and sys_platform == "linux"
selinux==0.2.1; python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "linux" or python_version >= "3.6" and python_full_version < "3.0.0" and sys_platform == "linux2" or sys_platform == "linux" and python_version >= "3.6" and python_full_version >= "3.5.0" or sys_platform == "linux2" and python_version >= "3.6" and python_full_version >= "3.5.0"
sh==1.14.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
shellingham==1.4.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_version >= "3.6" and python_full_version >= "3.5.0"
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
smmap==5.0.0; python_version >= "3.7"
stevedore==3.5.0; python_version >= "3.6"
tabulate==0.8.9; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
text-unidecode==1.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
toml==0.10.2; python_full_version >= "3.6.1" and python_version >= "3.6" and python_version < "4.0"
tomli==1.2.2; python_version >= "3.6" and python_full_version >= "3.6.2"
tomlkit==0.7.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
tree-format==0.1.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
typing-extensions==4.0.0
urllib3==1.26.7; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4"
virtualenv==20.10.0; python_full_version >= "3.6.1"
watchdog==2.1.6; python_version >= "3.6"
webencodings==0.5.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
wrapt==1.13.3; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.5.0"
yamllint==1.23.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
zipp==3.6.0; python_version >= "3.6"

View File

@@ -1,7 +1,11 @@
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
ansible-core==2.11.6; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
ansible==4.2.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
cffi==1.15.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
cryptography==36.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
jinja2==3.0.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
markupsafe==2.0.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
packaging==20.9; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
pycparser==2.21; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pyparsing==3.0.6; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
pyyaml==5.4.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
resolvelib==0.5.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"

70
tasks/amazon.yml Normal file
View File

@@ -0,0 +1,70 @@
---
- name: amazon | check for nvme devices
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
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
set_fact:
device_is_nvme: "{{ true if (blkdev_nvme.stdout == '0') else false }}"
- name: amazon | set flag for aws ebs devices
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
get_url:
url: "{{ ebsnvme_binary_helper_url }}"
dest: "{{ ebsnvme_binary_helper_tmp }}/"
changed_when: false
- name: amazon | extract binary helper
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
copy:
src: "{{ ebsnvme_binary_helper_tmp }}/go-ebsnvme"
dest: "{{ ebsnvme_binary_helper_path }}"
mode: a+x
remote_src: yes
- name: amazon | template script helper
template:
src: 'ebsnvme-id.j2'
dest: "{{ ebsnvme_scrip_helper_path }}"
mode: a+x
- name: amazon | template udev rule
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
shell:
cmd: udevadm control --reload-rules && udevadm trigger
when: udev_rule.changed

View File

@@ -1,15 +1,14 @@
---
- name: centos | installing lvm2
- name: centos | installing lvm2 and sg3_utils
package:
name: lvm2
name:
- lvm2
- sg3_utils
state: present
become: true
- name: centos | installing sg3_utils
package:
name: sg3_utils
state: present
become: true
- include_tasks: amazon.yml
when: ansible_facts.system_vendor == 'Amazon EC2'
- name: centos | debug lvg
debug:
@@ -35,13 +34,36 @@
- lv.1.create is defined
- lv.1.create|bool
- name: centos | checking for scsi devices
command: sg_scan
- name: centos | check for scsi adapters
find:
paths: "/sys/class/scsi_host"
file_type: any
become: true
register: scsi_devices
changed_when: false
register: scsi_adapters
- name: centos | rescanning for new disks
command: /usr/bin/rescan-scsi-bus.sh
become: true
changed_when: false
- block:
- name: centos | installing sg3_utils
package:
name: sg3_utils
state: present
become: true
- name: centos | checking for scsi devices
command: sg_scan
become: true
register: scsi_devices
changed_when: false
- name: centos | rescanning for new disks
command: "{{ rescan_scsi_command }}"
become: true
changed_when: false
when: scsi_devices.stdout|length > 0
- name: centos | rescanning for resized disks
command: "{{ rescan_scsi_command }} -s"
become: true
changed_when: false
when: scsi_devices.stdout|length > 0
when: scsi_adapters.matched > 0

View File

@@ -1,4 +1,21 @@
---
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- 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...
shell: "xfs_info {{ lv.mntp }} | grep -c 'ftype=1'"
become: yes
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)
mount:
path: "{{ lv.mntp }}"
@@ -6,9 +23,6 @@
fstype: "{{ lv.filesystem | default(omit) }}"
state: absent
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when:
- lv is defined
- lv != 'None'
@@ -21,9 +35,6 @@
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
@@ -34,34 +45,13 @@
- lv.create|bool
- lv.filesystem is defined
- lv.filesystem != 'None'
- lv.filesystem != 'swap'
- lv.filesystem != 'xfs'
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- 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...
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: 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 | 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
@@ -82,14 +72,26 @@
state: mounted
opts: "{{ lv.mopts | default('defaults') }}"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when:
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.mount is defined
- lv.mount|bool
- name: create_fs | resizing xfs filesystem on new LVM logical volume(s)
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

View File

@@ -1,17 +1,10 @@
---
- name: create_lv | Display Volume Group
debug:
var: vg
verbosity: 2
- name: create_lv | debug lvm
loop: "{{ vg.lvnames }}"
debug:
var: lv
verbosity: 1
loop_control:
loop_var: lv
- name: create_lv | creating new LVM logical volume(s)
lvol:
vg: "{{ vg.vgname }}"
@@ -20,10 +13,8 @@
shrink: false
opts: "{{ lv.opts | default('') }}"
state: present
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
register: lvchanged
when:
- vg.create is defined
- vg.create|bool
@@ -31,3 +22,10 @@
- lv != 'None'
- lv.create is defined
- lv.create|bool
- name: create_lv | debug changed attribute
debug:
var: lvchanged
- name: create_lv | configuring FS
include_tasks: create_fs.yml

View File

@@ -1,11 +1,29 @@
---
- name: create_vg | creating new LVM volume group(s)
lvg:
vg: "{{ item.vgname }}"
pvs: "{{ item.disks | join(',') }}"
vg: "{{ vg.vgname }}"
pvs: "{{ vg.disks | join(',') }}"
state: present
become: true
loop: "{{ lvm_groups }}"
when:
- item.create is defined
- item.create|bool
- vg.create is defined
- vg.create|bool
### workaround: auto pvresize waiting for upgrade to new module supporting integrated pvresize
### ref: https://docs.ansible.com/ansible/3/collections/community/general/lvg_module.html
- name: create_vg | pvresize to max available free space
command: "pvresize {{ pv }}"
loop: "{{ vg.disks | default([]) }}"
loop_control:
loop_var: pv
changed_when: false
when:
- vg.create is defined
- vg.create|bool
- pvresize_to_max|bool
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
include_tasks: create_lv.yml
loop: "{{ vg.lvnames | default([]) }}"
loop_control:
loop_var: lv

View File

@@ -34,7 +34,7 @@
changed_when: false
- name: debian | rescanning for new disks added
command: /sbin/rescan-scsi-bus
command: "{{ rescan_scsi_command }}"
become: true
changed_when: false
when: scsi_devices['stdout'] | length

View File

@@ -1,10 +1,18 @@
---
# tasks file for ansible-manage-lvm
- name: Set rescan_scsi_command for old debian version
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: debian.yml
when: ansible_os_family == "Debian"
when: ansible_facts.os_family == "Debian"
- include_tasks: centos.yml
when: ansible_os_family == "RedHat"
when: ansible_facts.os_family == "RedHat"
- include_tasks: manage_lvm.yml
when:

View File

@@ -1,15 +1,6 @@
---
- name: manage_lvm | manage physical volume group creation
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_control:
loop_var: vg
@@ -21,7 +12,7 @@
state: absent
force: true
become: true
loop: "{{ lvm_groups|subelements('lvnames') }}"
loop: "{{ lvm_groups|subelements('lvnames', {'skip_missing': true}) }}"
when:
- item.1 is defined
- item.1 != 'None'

View File

@@ -0,0 +1,3 @@
# 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"

15
templates/ebsnvme-id.j2 Normal file
View File

@@ -0,0 +1,15 @@
#!/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}'

View File

@@ -1,2 +1,7 @@
---
# 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"