Repository: ansible/ansible

Issue:
lvol - logical volume extension with resizefs parameter
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->

 - Feature Idea


##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
lvol module
##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Aug  2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
 
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->

##### OS / ENVIRONMENT
<!---
Ansible host and client host are running with RHEL 7.3
-->

##### SUMMARY
lvextend has an option to resize the filesystem but unable to find the same parameter with lvol module.

Example:

lvextend --resizefs --size +9GB /dev/vg00/lvUsr

##### STEPS TO REPRODUCE
<!---
- lvol:
    vg: vg00
    lv: lvUsr
    size: +9GB
    resizefs: True
-->

<!--- Paste example playbooks or commands between quotes below -->
```yaml

```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```

```



Discussion:
cc @abulimov @jhoekx
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
- lvol:
    vg: vg00
    lv: lvUsr
    size: +9GB
    resizefs: True

expecting the above format for lvol extension of a vol

Resolving patch:
diff --git a/lib/ansible/modules/system/lvol.py b/lib/ansible/modules/system/lvol.py
--- a/lib/ansible/modules/system/lvol.py
+++ b/lib/ansible/modules/system/lvol.py
@@ -58,7 +58,7 @@
     version_added: "1.5"
   opts:
     description:
-    - Free-form options to be passed to the lvcreate command
+    - Free-form options to be passed to the lvcreate command.
     version_added: "2.0"
   snapshot:
     description:
@@ -66,16 +66,20 @@
     version_added: "2.1"
   pvs:
     description:
-    - Comma separated list of physical volumes e.g. /dev/sda,/dev/sdb
+    - Comma separated list of physical volumes (e.g. /dev/sda,/dev/sdb).
     version_added: "2.2"
   shrink:
     description:
-    - shrink if current size is higher than size requested
+    - Shrink if current size is higher than size requested.
     type: bool
     default: 'yes'
     version_added: "2.2"
-notes:
-  - Filesystems on top of the volume are not resized.
+  resizefs:
+    description:
+    - Resize the underlying filesystem together with the logical volume.
+    type: bool
+    default: 'yes'
+    version_added: "2.5"
 '''
 
 EXAMPLES = '''
@@ -135,6 +139,7 @@
     vg: firefly
     lv: test
     size: 100%PVS
+    resizefs: true
 
 - name: Resize the logical volume to % of VG
   lvol:
@@ -244,7 +249,8 @@ def main():
             shrink=dict(type='bool', default=True),
             active=dict(type='bool', default=True),
             snapshot=dict(type='str'),
-            pvs=dict(type='str')
+            pvs=dict(type='str'),
+            resizefs=dict(type='bool', default=False),
         ),
         supports_check_mode=True,
     )
@@ -267,6 +273,7 @@ def main():
     force = module.boolean(module.params['force'])
     shrink = module.boolean(module.params['shrink'])
     active = module.boolean(module.params['active'])
+    resizefs = module.boolean(module.params['resizefs'])
     size_opt = 'L'
     size_unit = 'm'
     snapshot = module.params['snapshot']
@@ -421,6 +428,8 @@ def main():
                     tool = '%s %s' % (tool, '--force')
 
             if tool:
+                if resizefs:
+                    tool = '%s %s' % (tool, '--resizefs')
                 cmd = "%s %s -%s %s%s %s/%s %s" % (tool, test_opt, size_opt, size, size_unit, vg, this_lv['name'], pvs)
                 rc, out, err = module.run_command(cmd)
                 if "Reached maximum COW size" in out:
@@ -450,6 +459,8 @@ def main():
                     tool = '%s %s' % (tool, '--force')
 
             if tool:
+                if resizefs:
+                    tool = '%s %s' % (tool, '--resizefs')
                 cmd = "%s %s -%s %s%s %s/%s %s" % (tool, test_opt, size_opt, size, size_unit, vg, this_lv['name'], pvs)
                 rc, out, err = module.run_command(cmd)
                 if "Reached maximum COW size" in out:


Test patch: