{"id":16777310,"url":"https://github.com/githubixx/ansible-role-lvm","last_synced_at":"2026-03-01T01:33:35.883Z","repository":{"id":46119922,"uuid":"397703606","full_name":"githubixx/ansible-role-lvm","owner":"githubixx","description":"Ansible role to manage Linux Logical Volume Manager resources","archived":false,"fork":false,"pushed_at":"2024-04-25T21:07:07.000Z","size":44,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-02T22:20:27.594Z","etag":null,"topics":["ansible","ansible-role","linux","logical-volume-management","logical-volumes","lv","lvm","vg","volume-group"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/githubixx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-18T18:46:02.000Z","updated_at":"2025-08-19T09:40:25.000Z","dependencies_parsed_at":"2024-10-28T16:37:11.163Z","dependency_job_id":"72d8cf6c-fd89-49e2-8927-36cff6e380e7","html_url":"https://github.com/githubixx/ansible-role-lvm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/githubixx/ansible-role-lvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubixx%2Fansible-role-lvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubixx%2Fansible-role-lvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubixx%2Fansible-role-lvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubixx%2Fansible-role-lvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/githubixx","download_url":"https://codeload.github.com/githubixx/ansible-role-lvm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubixx%2Fansible-role-lvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29957377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T22:53:01.873Z","status":"ssl_error","status_checked_at":"2026-02-28T22:52:50.699Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","linux","logical-volume-management","logical-volumes","lv","lvm","vg","volume-group"],"created_at":"2024-10-13T07:24:21.038Z","updated_at":"2026-03-01T01:33:35.855Z","avatar_url":"https://github.com/githubixx.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nCopyright (C) 2021-2024 Robert Wimmer\nSPDX-License-Identifier: GPL-3.0-or-later\n--\u003e\n\n# ansible-role-lvm\n\nThis Ansible roles installs Linux Logical Volume Manager (LVM) resources like `Volume Groups` (VG), `Logical Volumes` (LV) and handles `filesystems` creation and `mountpoints`.\n\n## Changelog\n\nsee [CHANGELOG](https://github.com/githubixx/ansible-role-lvm/blob/master/CHANGELOG.md)\n\n## Role Variables\n\nBy default no LVM resources are created. See examples below. The `lvm_vgs` key is the entrypoint for all LVM resources that should be created.\n\n```yaml\nlvm_vgs: []\n```\n\nFirst a few examples about creating LVM resources (how deletion is handled see further down below).\n\nCreate a volume group (VG) called `test-vg-01` which uses device `/dev/vdb` as physical volume:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n```\n\nAll three parameters are required! [vgname](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-vg) is the name of the Volume Group. [pvs](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-pvs) is a list of comma-separated devices to use as physical devices in this volume group. [state](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-state) controls if the volume group exists.  \nTo delete a VG you need to specify `state: absent` and also `force: true`. In contrast to the `force` parameter of the [community.general.lvg](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html) module `force: true` won't delete VGs that still contains (a) logical volume(s)! This is to make it harder to delete data by accident.\n\nCreate a volume group (VG) called `test-vg-01` which uses devices `/dev/vdb` and `/dev/vdc` as physical volumes:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb,/dev/vdc\n    state: present\n```\n\nCurrently the following additional [community.general.lvg](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html) parameters are supported:\n\n- [vg_options](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-vg_options)\n- [pesize](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-pesize)\n- [pv_options](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html#parameter-pv_options)\n\nAs previous example but also create a logical volume `test-lv-01` and allocate `10%` of the available VG space:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n    lvm_lvs:\n      - lvname: test-lv-01\n        size: 10%VG\n        state: present\n```\n\nAll logical volumes a volume group contains are listed under `lvm_lvs` key. `lvname`, `size` and `state` parameters are required! [lvname](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-lv) is the name of the logical volume. [size](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-size) specifies the size of the logical volume, according to `lvcreate(8) --size`, by default in megabytes or optionally with one of [bBsSkKmMgGtTpPeE] units; or according to `lvcreate(8) --extents` as a percentage of [VG|PVS|FREE]; Float values must begin with a digit. [state](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-state) controls if the logical volume exists. To delete a LV you need to specify `state: absent` and also `force: true`.\n\nCurrently also the following additional [community.general.lvol](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameters) parameters are supported:\n\n- [active](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-active)\n- [opts](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-opts)\n- [pvs](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-pvs)\n- [thinpool](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#parameter-thinpool)\n\nAs previous example but also create a `ext4` filesystem using logical volume `test-lv-01` as device for the filesystem:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n    lvm_lvs:\n      - lvname: test-lv-01\n        size: 10%VG\n        state: present\n        fs:\n          type: ext4\n          state: present\n```\n\nThe `fs` key specifies that the logical volume should contain a filesystem. [type](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html#parameter-fstype) specifies the filesystem that should be used. `state: present` specifies that the filesystem is created if it doesn't already exist. In case of `state: absent` filesystem signatures on the device are wiped if it contains a filesystem (as known by `blkid`). When `state: absent`, all other options but the device are ignored, and the module doesn't fail if the device doesn't actually exist. In case of `state: absent` also `force: true` is needed otherwise the filesystem won't be touched. In contrast to the [force](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html#parameter-force) parameter of the [community.general.filesystem](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html) module `force: true` won't override an existing filesystem. You really need to wipe the old one first to be able to create an new filesystem! Again this is to avoid deletion by accident.\n\nAs previous example but also create a directory `/mnt1` and mount the `ext4` filesystem there. This also creates an entry in `/etc/fstab` (by default).\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n    lvm_lvs:\n      - lvname: test-lv-01\n        size: 10%VG\n        state: present\n        fs:\n          type: ext4\n          state: present\n          mountpoint:\n            state: mounted\n            path:\n              name: /mnt1\n```\n\nThe `mountpoint` key handles mountpoint related actions. [state](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state) has the same options as the [ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html) module provides like `mounted`, `absent`, `present`, `unmounted` and `remounted` (also see [state](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-state)). `state` and `path.name` are required. `path.name` specifies the name of the directory the mountpoint should be mounted. If the directory doesn't exists already it will be created. For further options see next example.\n\nAs previous example but the filesystem now gets an label `mnt1`. Also the filesystem gets mounted at `/mnt1` with the `noatime` filesystem option. Also the filesystem gets mounted by using the `mnt1` label as mentioned (`src: LABEL=mnt1`). The `owner` and `group` of the `/mnt1` directory will be `vagrant` and the directory permissions will be `0750`:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n    lvm_lvs:\n      - lvname: test-lv-01\n        size: 10%VG\n        state: present\n        fs:\n          type: ext4\n          opts: -L mnt1\n          state: present\n          mountpoint:\n            opts: noatime\n            state: mounted\n            src: LABEL=mnt1\n            path:\n              name: /mnt1\n              mode: '0750'\n              owner: vagrant\n              group: vagrant\n```\n\nBy default `mountpoint.src` is `/dev/ + vgname + / + lvname`. In the example above `LABEL=mnt1` was used. In `opts: -L mnt` the option was provided to create a filesystem with that label. So that one can be used later for `mountpoint.src`.\n\n`mountpoint` supports the following additional parameters:\n\n- [opts](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-opts)\n- [backup](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-backup)\n- [dump](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-dump)\n- [passno](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-passno)\n- [fstab](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html#parameter-fstab)\n\nCreate two volume groups (VG) called `test-vg-01` and `test-vg-02` which uses device `/dev/vdb` and `/dev/vdc` respectively as physical volumes:\n\n```yaml\nlvm_vgs:\n  - vgname: test-vg-01\n    pvs: /dev/vdb\n    state: present\n  - vgname: test-vg-02\n    pvs: /dev/vdc\n    state: present\n```\n\nHere is an example to unmount a mountpoint and delete its entry from `/etc/fstab`:\n\n```yaml\nmountpoint:\n  state: absent\n  path:\n    name: /vg01lv01\n```\n\nThis of course only works if the mountpoint isn't used by a program or service.\n\nAs deleting filesystems, logical volumes (LV) and volume groups (VG) potentially can destroy your data extra caution should be taken! In this case specifying `state: absent` to delete such a resource isn't enough. `force: true` is also needed. Of course deleting a volume group that still contains a logical volume will fail. Also deleting a logical volume with a filesystem with `state: present` will fail.\n\nThe following example will unmount the specified mountpoint (`/vg02lv01`) and delete its entry from `/etc/fstab`, will wipe the `ext4`  filesystem, deletes the logical volume (`vg02lv01`) and finally deletes the volume group (`vg02`) (in that order):\n\n```yaml\nlvm_vgs:\n  - vgname: vg02\n    pvs: /dev/vdc\n    state: absent\n    force: true\n    lvm_lvs:\n      - lvname: vg02lv01\n        size: 10%VG\n        state: absent\n        force: true\n        fs:\n          type: ext4\n          state: absent\n          force: true\n          mountpoint:\n            state: absent\n            path:\n              name: /vg02lv01\n```\n\nTo be able to create filesystems additional packages are needed. For `ext(2|3|4)` you need `e2fsprogs` package installed e.g. So depending which filesystem you want to setup you may need to install additional package(s) or remove package(s) not needed from the list. Of course you can add whatever packages you want to install to the list\n\nBy default only tools needed for `ext(2|3|4)` or `xfs` are installed. For other filesystems you may need `btrfsprogs/btrfs-progs`, `dosfstools`, `f2fs-tools` or `reiserfsprogs` e.g.:\n\n```yaml\n# Additional packages for SuSE compatible OSes\nadditional_packages_suse:\n  - e2fsprogs\n  - xfsprogs\n\n# Additional packages for Debian compatible OSes\nadditional_packages_debian:\n  - e2fsprogs\n  - xfsprogs\n\n# Additional packages for Redhat compatible OSes\nadditional_packages_redhat:\n  - e2fsprogs\n  - xfsprogs\n\n# Additional packages for Archlinux compatible OSes\nadditional_packages_arch:\n  - e2fsprogs\n  - xfsprogs\n```\n\nIn general most options of the following modules are supported:\n\n[community.general.lvg](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html)  \n[community.general.lvol](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html)  \n[community.general.filesystem](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html)  \n[ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html)  \n\n## Dependencies\n\nThis role depends on a few Ansible modules:\n\n[community.general.lvg](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html)  \n[community.general.lvol](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html)  \n[community.general.filesystem](https://docs.ansible.com/ansible/latest/collections/community/general/filesystem_module.html)  \n[ansible.posix.mount](https://docs.ansible.com/ansible/latest/collections/ansible/posix/mount_module.html)  \n\n## TODO\n\nCurrently the following features are not implemented:\n\n- Volume Group resize  \n- Logical Volume shrink  \n- Logical Volume snapshot  \n- Logical Volume/Filesystem resize  \n\n## Example Playbook\n\n### Example 1 (without role tag)\n\n```yaml\n- hosts: your-host\n  roles:\n    - githubixx.lvm\n```\n\n### Example 2 (assign tag to role)\n\n```yaml\n-\n  hosts: your-host\n  roles:\n    -\n      role: githubixx.lvm\n      tags: role-lvm\n```\n\n## More examples\n\nThere are a few more examples used for testing this role. See [molecule](https://github.com/githubixx/ansible-role-lvm/tree/master/molecule) directories.\n\n## Testing\n\nThis role has a small test setup that is created using [Molecule](https://github.com/ansible-community/molecule), libvirt (vagrant-libvirt) and QEMU/KVM. Please see my blog post [Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM](https://www.tauceti.blog/posts/testing-ansible-roles-with-molecule-libvirt-vagrant-qemu-kvm/) how to setup. The test configuration is [here](https://github.com/githubixx/ansible-role-lvm/tree/master/molecule/kvm).\n\nAfterwards molecule can be executed:\n\n```bash\nmolecule converge -s kvm\n```\n\nThis will setup quite a few virtual machines (VM) with different supported Linux operating systems and creates various LVM resources.\n\nTo clean up run\n\n```bash\nmolecule destroy -s kvm\n```\n\n## License\n\n[GNU General Public License v3.0 or later](https://spdx.org/licenses/GPL-3.0-or-later.html)\n\n## Author Information\n\n[http://www.tauceti.blog](http://www.tauceti.blog)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubixx%2Fansible-role-lvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithubixx%2Fansible-role-lvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubixx%2Fansible-role-lvm/lists"}