The below playbook is not printing an error message when the disk is not defined on a host. Could you please advise if I have made an mistake in the playbook. Thanks
$ ansible-playbook partition.yml
PLAY [Create a partition] ******************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************************************************************************************************************
ok: [
ansible2.example.com]
ok: [
ansible4.example.com]
ok: [
ansible3.example.com]
TASK [Gather disk info] ********************************************************************************************************************************************************************************************************************
fatal: [
ansible4.example.com]: FAILED! => {"changed": false, "err": "Error: Could not stat device /dev/sdb - No such file or directory.\n", "msg": "Error while getting device information with parted script: '/sbin/parted -s -m /dev/sdb -- unit 'MB' print'", "out": "", "rc": 1}
ok: [
ansible3.example.com]
ok: [
ansible2.example.com]
TASK [Print disk info] *********************************************************************************************************************************************************************************************************************
ok: [
ansible2.example.com] => {
"device_info": {
"changed": false,
"disk": {
"dev": "/dev/sdb",
"logical_block": 512,
"model": "ATA VBOX HARDDISK",
"physical_block": 512,
"size": 12885.0,
"table": "msdos",
"unit": "mb"
},
"failed": false,
"partitions": [
{
"begin": 1.05,
"end": 1200.0,
"flags": [],
"fstype": "ext4",
"name": "",
"num": 1,
"size": 1199.0,
"unit": "mb"
}
],
"script": "unit 'MB' print"
}
}
ok: [
ansible3.example.com] => {
"device_info": {
"changed": false,
"disk": {
"dev": "/dev/sdb",
"logical_block": 512,
"model": "ATA VBOX HARDDISK",
"physical_block": 512,
"size": 1074.0,
"table": "msdos",
"unit": "mb"
},
"failed": false,
"partitions": [
{
"begin": 1.05,
"end": 800.0,
"flags": [],
"fstype": "ext4",
"name": "",
"num": 1,
"size": 799.0,
"unit": "mb"
}
],
"script": "unit 'MB' print"
}
}
TASK [Create partition] ********************************************************************************************************************************************************************************************************************
skipping: [
ansible3.example.com]
ok: [
ansible2.example.com]
TASK [Print enough size is not available] **************************************************************************************************************************************************************************************************
skipping: [
ansible2.example.com]
ok: [
ansible3.example.com] => {
"msg": "Enough size is not available"
}
TASK [Create 800MB partition] **************************************************************************************************************************************************************************************************************
skipping: [
ansible2.example.com]
ok: [
ansible3.example.com]
TASK [Create file system] ******************************************************************************************************************************************************************************************************************
fatal: [
ansible3.example.com]: FAILED! => {"changed": false, "cmd": "/sbin/mkfs.ext4 -F /dev/sdb1", "msg": "mke2fs 1.44.6 (5-Mar-2019)\n/dev/sdb1 is mounted; will not make a filesystem here!", "rc": 1, "stderr": "mke2fs 1.44.6 (5-Mar-2019)\n/dev/sdb1 is mounted; will not make a filesystem here!\n", "stderr_lines": ["mke2fs 1.44.6 (5-Mar-2019)", "/dev/sdb1 is mounted; will not make a filesystem here!"], "stdout": "", "stdout_lines": []}
fatal: [
ansible2.example.com]: FAILED! => {"changed": false, "cmd": "/sbin/mkfs.ext4 -F /dev/sdb1", "msg": "mke2fs 1.44.6 (5-Mar-2019)\n/dev/sdb1 is mounted; will not make a filesystem here!", "rc": 1, "stderr": "mke2fs 1.44.6 (5-Mar-2019)\n/dev/sdb1 is mounted; will not make a filesystem here!\n", "stderr_lines": ["mke2fs 1.44.6 (5-Mar-2019)", "/dev/sdb1 is mounted; will not make a filesystem here!"], "stdout": "", "stdout_lines": []}
PLAY RECAP *********************************************************************************************************************************************************************************************************************************
ansible2.example.com : ok=4 changed=0 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0
ansible3.example.com : ok=5 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0
ansible4.example.com : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0