HI kai,
Thanks a lot it was working for me.
I need one more help from you.
my playbook got 2 new disks, Everything works perfectly except creating pv
and VG as below.
- name: "finding recent added device"
shell: bash -c 'comm -23 <(lsblk -l | grep disk | cut -f1 -d" ") <(lsblk
-l | grep part | cut -c1-3 | uniq)'
register: fdisk
- debug:
msg: "New disks are {{fdisk.stdout_lines}}"
- name: "creating disk from raw"
parted:
device: "/dev/{{item}}"
number: 1
flags: [ lvm ]
state: present
part_start: 0%
part_end: 100%
unit: '%'
with_items:
- "{{fdisk.stdout_lines}}"
- name: "Vg creation"
lvg:
vg: "{{vg_name}}"
pvs: "/dev/{{item}}1"
with_items:
- "{{fdisk.stdout_lines}}"
TASK [LVM : Vg creation]
***********************************************************************************************************************************************
changed: [XXXXXXXXXXXXX] => (item=sdh)
failed: [XXXXXXXXXXXX] (item=sdi) => {"changed": true, "cmd": "vgcreate
test /dev/sdi1", "delta": "0:00:00.047863", "end": "2018-10-02
11:19:49.557057", "item": "sdi", "msg": "non-zero return code", "rc": 5,
"start": "2018-10-02 11:19:49.509194", "stderr": " A volume group called
test already exists.", "stderr_lines": [" A volume group called test
already exists."], "stdout": "", "stdout_lines": []}
to retry, use: --limit @/home/viraj4/ansible/lv.retry
On Sunday, September 30, 2018 at 4:57:12 PM UTC+2, [email protected] wrote:
> HI all,
>
> I am trying to get the disk information of target machine.
>
> 1. I want to check the newly added disk which is fully free, means there
> is no partition created.
> 2. running a loop like /dev/sda to /dev/sdz and that should fail if
> patition is not created and print the me last failed disk. can someone help
> me ?
>
> I have tried bellow playbook in Linux machine. let me know the changes.
>
> Thanks in advance.
>
> - hosts: one
> become: true
> tasks:
> - shell: " lsblk | grep -i disk | awk '{print$1}' "
> register: part
> - debug:
> msg: "{{part.stdout_lines}}"
> - shell: "fdisk -l /dev/{{item}}1 | grep -i cylinders"
> register: new
> with_items:
> - "{{part.stdout_lines}}"
> #until: '"cylinders" not in new.stdout'
> failed_when: new.rc == 1
> ignore_errors: true
> - debug:
> msg: "{{item.new}}"
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/87a6c26a-91e2-4f76-84e4-962ca853db27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.