Saturday, April 3, 2021

Create Partition using Ansible

Description: Here I have explained, How to Create Partition, Format, and Mount using Ansible


Procedure:

  • Ansible uses Parted module to manage the partition. Below is the Yaml file to create a partition of 10GB on drive

### Create partition of 10 GB on /dev/xvdb device and mount on /mnt/storage --- - name: create partition hosts: web remote_user: root become: yes tasks: - name: Create a new ext4 primary partition parted: device: /dev/xvdb number: 1 state: present part_start: 2MiB part_end: 10GiB - name: Format the Disk filesystem: fstype: ext4 dev: /dev/xvdb1 - name: create the Directory file: path: /mnt/storage state: directory mode: '0755' - name: Mount Prtition mount: path: /mnt/storage src: /dev/xvdb1 fstype: ext4 state: mounted











  • Verify partition after run playbook


No comments:

Post a Comment