Issue 1:
Likely caused by #20655.

ISSUE TYPE

Bug Report

COMPONENT NAME

filesystem

ANSIBLE VERSION

ansible 2.3.0
config file = /opt/ansible/ansible.cfg
configured module search path = Default w/o overrides

CONFIGURATION (default)

OS / ENVIRONMENT

CentOS Linux release 7.3.1611 (Core)

SUMMARY

The filesystem module is used in this case to create an ext4 filesystem on a block device previously created with LVM using the 'lvg' and 'lvol' Ansible modules. When the module queries the target block device for its size, the module returns an exception instead of creating the filesystem (if the filesystem does not exist) or returning no change (if the filesystem already exists).

STEPS TO REPRODUCE

Consider the following task:

- name: create {{ volumes_fstype }} filesystems on LVM logical volumes
filesystem:
fstype: "{{ volumes_fstype }}"
resizefs: yes
dev: /dev/vg{{ item.mount_point | regex_replace('/', '.') }}/lv{{ item.mount_point | regex_replace('/', '.') }}
force: "{{ force | default(omit) }}"
with_items: "{{ launch_volumes }}"
when: ( item.mount_point != '/' ) and
( item.volume_size is defined ) and
( launch_volumes is defined )

The task receives its parameters from the launch_volumes dictionary, containing the following values:

launch_volumes:
- mount_point: /
device_name: /dev/sda1
device_type: gp2
volume_size: 10
delete_on_termination: True
- mount_point: /localvolume
device_name: /dev/xvdh
device_type: gp2
volume_size: 100
delete_on_termination: True

EXPECTED RESULTS

TASK [ec2-volumes : create ext4 filesystems on LVM logical volumes] ********************************************************************************************
task path: /opt/ansible/roles/ec2-volumes/tasks/main.yml:31
skipping: [10.233.50.122] => (item={u'volume_size': 10, u'mount_point': u'/', u'delete_on_termination': True, u'device_type': u'gp2', u'device_name': u'/dev/sda1'}) => {
"changed": false,
"item": {
"delete_on_termination": true,
"device_name": "/dev/sda1",
"device_type": "gp2",
"mount_point": "/",
"volume_size": 10
},
"skip_reason": "Conditional result was False",
"skipped": true
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.py
<10.233.50.122> ESTABLISH SSH CONNECTION FOR USER: root
<10.233.50.122> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/mvaughn/.ansible/cp/
9f8854b6f2 10.233.50.122 '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''
ok: [10.233.50.122] => (item={u'volume_size': 100, u'mount_point': u'/localvolume', u'delete_on_termination': True, u'device_type': u'gp2', u'device_name': u'/dev/xvdh'}) => {
"changed": false,
"invocation": {
"module_args": {
"dev": "/dev/vg.localvolume/lv.localvolume",
"force": false,
"fstype": "ext4",
"opts": null,
"resizefs": true
}
},
"item": {
"delete_on_termination": true,
"device_name": "/dev/xvdh",
"device_type": "gp2",
"mount_point": "/localvolume",
"volume_size": 100
},
"msg": "ext4 filesystem is using the whole device /dev/vg.localvolume/lv.localvolume"
}

ACTUAL RESULTS

TASK [ec2-volumes : create ext4 filesystems on LVM logical volumes] ********************************************************************************************
task path: /opt/ansible/roles/ec2-volumes/tasks/main.yml:31
skipping: [10.233.50.122] => (item={u'volume_size': 10, u'mount_point': u'/', u'delete_on_termination': True, u'device_type': u'gp2', u'device_name': u'/dev/sda1'}) => {
"changed": false,
"item": {
"delete_on_termination": true,
"device_name": "/dev/sda1",
"device_type": "gp2",
"mount_point": "/",
"volume_size": 10
},
"skip_reason": "Conditional result was False",
"skipped": true
}
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/filesystem.py
<10.233.50.122> ESTABLISH SSH CONNECTION FOR USER: root
<10.233.50.122> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/mvaughn/.ansible/cp/
9f8854b6f2 10.233.50.122 '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''
[WARNING]: Removed unexpected internal key in module return: _ansible_parsed = False

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_fL10VJ/ansible_module_filesystem.py", line 267, in <module>
main()
File "/tmp/ansible_fL10VJ/ansible_module_filesystem.py", line 219, in main
devsize_in_bytes = _get_dev_size(dev, module)
File "/tmp/ansible_fL10VJ/ansible_module_filesystem.py", line 83, in _get_dev_size
return int(devsize_in_bytes)
ValueError: invalid literal for int() with base 10: ''

failed: [10.233.50.122] (item={u'volume_size': 100, u'mount_point': u'/localvolume', u'delete_on_termination': True, u'device_type': u'gp2', u'device_name': u'/dev/xvdh'}) => {
"failed": true,
"item": {
"delete_on_termination": true,
"device_name": "/dev/xvdh",
"device_type": "gp2",
"mount_point": "/localvolume",
"volume_size": 100
},
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_fL10VJ/ansible_module_filesystem.py\", line 267, in <module>\n main()\n File \"/tmp/ansible_fL10VJ/ansible_module_filesystem.py\", line 219, in main\n devsize_in_bytes = _get_dev_size(dev, module)\n File \"/tmp/ansible_fL10VJ/ansib
le_module_filesystem.py\", line 83, in _get_dev_size\n return int(devsize_in_bytes)\nValueError: invalid literal for int() with base 10: ''\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 1
}

Observe that the value devsize_in_bytes evaluates to the empty string, '', which is invalid.

Issue 2:
That is most likely related to #20551

ISSUE TYPE

Bug Report

COMPONENT NAME

filesystem

ANSIBLE VERSION

ansible 2.3.0
config file =
configured module search path = Default w/o overrides

CONFIGURATION

Default

OS / ENVIRONMENT

SUMMARY

filesystem module fails on CoreOS with:

mke2fs 1.42.13 (17-May-2015)\nThe file [/dev/xvdf] does not exist and no size was specified.\n

STEPS TO REPRODUCE

- filesystem: fstype=ext4 dev=/dev/xvdf force=yes

EXPECTED RESULTS

Filesystem is created on a given block device.

ACTUAL RESULTS

Error is thrown.

fatal: [35.157.42.174]: FAILED! => {
"changed": false,
"err": "mke2fs 1.42.13 (17-May-2015)\nThe file [/dev/xvdf] does not exist and no size was specified.\n",
"failed": true,
"invocation": {
"module_args": {
"dev": [
"/dev/xvdf"
],
"force": true,
"fstype": "ext4",
"opts": null,
"resizefs": false
}
},
"msg": "Creating filesystem ext4 on device '['/dev/xvdf']' failed",
"rc": 1
}