cancel
Showing results for 
Search instead for 
Did you mean: 
khokha
Flight Engineer
Flight Engineer
  • 2,068 Views

Hi,

how can i create lv using ansible in rhel9 i know how to do this using roles but i was wondering if there is any way other than using roles.

Thanks

Tags (4)
1 Solution

Accepted Solutions
Chetan_Tiwary_
Community Manager
Community Manager
  • 2,050 Views

Hello @khokha !

As @TM mentioned , you need to use the ingredients modules for creating a LVM one by one :

1. parted  to create partition with flags : [lvm]

2. lvg to create vol group.

3. lvol to create lv 

4. file to create the mount point 

5. filesystem to format the LVM with filesystem

6. mount to mount the LVM to the directory

Refer the lvol module here : https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html 

lvg module : https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html 

View solution in original post

Tags (4)
8 Replies
TM
Flight Engineer Flight Engineer
Flight Engineer
  • 2,056 Views

Hello,

You can still use the ansible.builtin.command module.
But you might need to take extra steps and actions to ensure idempotency and "changed" status.

Regards,

Tshimanga

Chetan_Tiwary_
Community Manager
Community Manager
  • 2,051 Views

Hello @khokha !

As @TM mentioned , you need to use the ingredients modules for creating a LVM one by one :

1. parted  to create partition with flags : [lvm]

2. lvg to create vol group.

3. lvol to create lv 

4. file to create the mount point 

5. filesystem to format the LVM with filesystem

6. mount to mount the LVM to the directory

Refer the lvol module here : https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html 

lvg module : https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html 

Tags (4)
khokha
Flight Engineer
Flight Engineer
  • 1,948 Views

Hi @Chetan_Tiwary_ 

I'm having know problem with artifacts of lv , lets say that i want to create lv:lv1 if vg:vg1 exists , how can i write that in terms of ansible_facts?

 i tried in the lab environment ansible_lvm['vgs'] it worked but on my personal lab it doesn't work.

another one, lets say if i want to format the lv:lv1 with xfs only if lv1 exists, how can i write this too in terms of ansible_facts?

Thanks in advance

melnajim
Flight Engineer
Flight Engineer
  • 1,408 Views
Could you verify your modules it’s installed
0 Kudos
bongoDB9
Mission Specialist
Mission Specialist
  • 2,033 Views

Hello!

Does EX294 allow the usage of the community.general?

Chetan_Tiwary_
Community Manager
Community Manager
  • 1,374 Views

Whatever you need for the exam will be provided - donot worry about it. 

  • 2,016 Views

Hello,

Certainly! To create a Logical Volume (LV) in RHEL 9 using Ansible without using roles, you can utilize the Ansible module called "lvol." This module allows you to define LV properties in your playbook directly, avoiding the need for roles. Simply specify the LV details like name, size, and VG (Volume Group) in your playbook's tasks. 

Regards,

Lily

melnajim
Flight Engineer
Flight Engineer
  • 1,413 Views
You can see ansible-doc module name
0 Kudos
Join the discussion
You must log in to join this conversation.