Skip to content
Snippets Groups Projects

Add force option to format

Closed Pullyvan Krishnamoorthy requested to merge addForceOptionToFormat into master
1 file
+ 54
0
Compare changes
  • Side-by-side
  • Inline
tasks/centos.yml 0 → 100644
+ 54
0
---
# tasks file for mount_hdd2
- name: "Check if {{ dev }} exists"
stat:
path: "{{ dev }}"
register: hdd2
- name: install parted
become: yes
yum:
state: latest
pkg:
- parted.x86_64
- parted-devel.x86_64
- name: Create a new partition on hdd2
become: yes
parted:
name: home
part_type: primary
label: gpt
number: 1
device: /dev/nvme0n1
state: present
- name: Get System Details
stat: path={{ dev }}
register: check_mount
when: hdd2.stat.exists == False
- name: Check the type of filesystem if its data we need to format
shell: file -s {{ dev }}
register: fs
when: hdd2.stat.exists == False
- name: setting facts
set_fact:
format_fs: true
when: "'{{ dev }}: data' in fs.stdout"
- name: Format filesystem
filesystem: fstype={{ fstype }} dev={{ dev }}
- name: Mount filesystem
mount:
fstype: "{{ fstype }}"
src: "{{ dev }}"
name: "{{ mount }}"
opts: "{{ opts }}"
state: "{{ state }}"
register: mount_info
Loading