1
votes

I have created an Ansible playbook, which performs the following tasks:

  1. Create an EBS volume.
  2. Attach the volume to an existing EC2 instance.
  3. Mount the volume in the instance.

    - name: Creating a Volume
      hosts: all
      sudo: yes
      tasks:
    
    - name: Creating a Volume
      ec2_vol:
        aws_access_key: "{{ lookup('env', 'AWS_ACCESS_KEY_ID') }}"
        aws_secret_key: "{{ lookup('env', 'AWS_SECRET_ACCESS_KEY') }}"
        instance: 'i-7edebfdb'
        volume_size: 5
        device_name: /dev/xvdf
        region: 'ap-northeast-1'
        volume_type: gp2
      register: ec2_vol
    
     - name: Printing the volume information
       debug: var=ec2_vol
    
     - name: mounting the volume
       mount: name=/mnt fstype=ext4 state=mounted src=/dev/xvdf
    

But when I executed the playbook, received the following error.

failed: [172.30.1.237] => {"failed": true}
msg: Error mounting /mnt: mount: wrong fs type, bad option, bad superblock on /dev/xvdf,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

When I perfromed fdisk -l I can see the volume. But it is not mounted.

In dmesg there is can see the error message Can't find ext4 filesystem

How to resolve this issue.

1

1 Answers

3
votes

According to your logs, The error clearly mentions there is no file system on Volume. That means you are not formatting (Creating a filesystem) on EBS Volume.

Please include a task to format the Volume with a supported/required filesystem type before you mount.

Hope it helps.