# please help me to create a swap partition using ansible

**URL:** <https://forum.ansible.com/t/please-help-me-to-create-a-swap-partition-using-ansible/28090>\
**Category:** Ansible Project\
**Created:** [July 19, 2018, 11:00am UTC](https://forum.ansible.com/t/please-help-me-to-create-a-swap-partition-using-ansible/28090 "2018-07-19T11:00:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jobin\_A\_T\_A\_T](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jobin\_A\_T\_A\_T](https://forum.ansible.com/u/Jobin_A_T_A_T)\
**Post date:** [July 19, 2018, 11:00am UTC](https://forum.ansible.com/t/please-help-me-to-create-a-swap-partition-using-ansible/28090/1 "2018-07-19T11:00:40Z")

</div>

hello all iam trying to create the swap partition using

- name: creating lvm partition  
parted:  
device: /dev/sdb  
number: 1  
flags: [swap]  
state: present  
part\_end: 1GiB

but i didn’t get the exact flag name is that any other method for creating it

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 20, 2018, 8:04am UTC](https://forum.ansible.com/t/please-help-me-to-create-a-swap-partition-using-ansible/28090/2 "2018-07-20T08:04:34Z")

</div>

flag swap is something completely different and not what you are after.

After looking at the code I see that you cant create a partition with type set to swap/82 with the parted module.  
So your option is to do it with commands using command/shell module.

---

<div class="post-metadata">

**Author:** ![Jobin\_A\_T\_A\_T](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@Jobin\_A\_T\_A\_T](https://forum.ansible.com/u/Jobin_A_T_A_T)\
**Post date:** [July 21, 2018, 10:09am UTC](https://forum.ansible.com/t/please-help-me-to-create-a-swap-partition-using-ansible/28090/3 "2018-07-21T10:09:39Z")

</div>

thank you sir
