Last active
December 11, 2021 05:08
-
-
Save halberom/8f22f58f56c142c1f142a65bdf5f6cff to your computer and use it in GitHub Desktop.
Revisions
-
Gerard Lynch revised this gist
Aug 1, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,5 +26,5 @@ src: "{{ item.disk.dev }}" fstype: ntfs when: "item.partitions | length > 0 and item.partitions | selectattr('fstype', 'equalto', 'ntfs') | list | length > 0" with_items: "{{ driveFStype.results }}"
-
Gerard Lynch revised this gist
Aug 1, 2017 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ --- - hosts: localhost connection: local gather_facts: False tasks: - setup: filter: ansible_devices # - include_vars: jsonfile.json # - name: Check for partitions on disk devices # parted: # device: "/dev/{{ item.key }}" # unit: MiB # when: item.partitions | length > 0 # with_dict: "{{ ansible_devices }}" # register: driveFStype - include_vars: path: 01_parted.json name: driveFStype - name: mount ntfs partitions mount: path: "/mnt/{{ item.item }}" src: "{{ item.disk.dev }}" fstype: ntfs when: "item.partitions | length > 0 and item.partitions | selectattr('fstype', 'equalto', 'ntfs') | list | length > 0" with_items: "{{ driveFStype }}"
-
Gerard Lynch created this gist
Aug 1, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ --- - hosts: localhost connection: local gather_facts: False tasks: # - include_vars: jsonfile.json # # - debug: # var: ansible_devices # # - debug: # var: item.value.partitions # when: "item.value.partitions | length > 0" # with_dict: "{{ ansible_devices }}" # # - name: Check for partitions on disk devices # parted: # device: "/dev/{{ item.key }}" # unit: MiB # when: item.partitions | length > 0 # with_dict: "{{ ansible_devices }}" # register: driveFStype - include_vars: 01_parted.json - debug: msg: "{{ results | json_query(query) }}" vars: query: "[].{disk: disk.dev, partitions: partitions[?fstype=='ntfs']}" #query: "[].disk.dev"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ "results": [ { "_ansible_item_result": true, "_ansible_no_log": false, "_ansible_parsed": true, "changed": false, "disk": { "dev": "/dev/sda2", "logical_block": 512, "model": "Unknown", "physical_block": 512, "size": 32466.0, "table": "loop", "unit": "mib" }, "invocation": { "module_args": { "align": "optimal", "device": "/dev/sda2", "flags": null, "label": null, "name": null, "number": null, "part_end": "100%", "part_start": "0%", "part_type": "primary", "state": "info", "unit": "MiB" } }, "item": "sda2", "partitions": [ { "begin": 0.0, "end": 32466.0, "flags": [], "fstype": "ntfs", "num": 1, "size": 32466.0, "unit": "mib" } ], "script": "unit 'MiB' print" }, { "_ansible_item_result": true, "_ansible_no_log": false, "_ansible_parsed": true, "changed": false, "disk": { "dev": "/dev/sda1", "logical_block": 512, "model": "Unknown", "physical_block": 512, "size": 300.0, "table": "loop", "unit": "mib" }, "invocation": { "module_args": { "align": "optimal", "device": "/dev/sda1", "flags": null, "label": null, "name": null, "number": null, "part_end": "100%", "part_start": "0%", "part_type": "primary", "state": "info", "unit": "MiB" } }, "item": "sda1", "partitions": [ { "begin": 0.0, "end": 300.0, "flags": [], "fstype": "ntfs", "num": 1, "size": 300.0, "unit": "mib" } ], "script": "unit 'MiB' print" } ] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ PLAY [localhost] ********************************************************************************************************************** TASK [include_vars] ******************************************************************************************************************* ok: [localhost] TASK [debug] ************************************************************************************************************************** ok: [localhost] => { "msg": [ { "disk": "/dev/sda2", "partitions": [ { "begin": 0.0, "end": 32466.0, "flags": [], "fstype": "ntfs", "num": 1, "size": 32466.0, "unit": "mib" } ] }, { "disk": "/dev/sda1", "partitions": [ { "begin": 0.0, "end": 300.0, "flags": [], "fstype": "ntfs", "num": 1, "size": 300.0, "unit": "mib" } ] } ] } PLAY RECAP **************************************************************************************************************************** localhost : ok=2 changed=0 unreachable=0 failed=0