cancel
Showing results for 
Search instead for 
Did you mean: 
khokha
Flight Engineer
Flight Engineer
  • 1,221 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_
Moderator
Moderator
  • 1,203 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
  • 1,209 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_
Moderator
Moderator
  • 1,204 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,101 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
  • 561 Views
Could you verify your modules it’s installed
0 Kudos
bongoDB9
Mission Specialist
Mission Specialist
  • 1,186 Views

Hello!

Does EX294 allow the usage of the community.general?

Chetan_Tiwary_
Moderator
Moderator
  • 527 Views

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

  • 1,169 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
  • 566 Views
You can see ansible-doc module name
0 Kudos
Join the discussion
You must log in to join this conversation.