we usually perform lot of multipath tasks in our company.

On a server if i want to configure multipath for disk aliases 


multipath -ll|egrep "dm-|size"|sed -e 's/\]/ /g'|sed -e 'N' -e 's/\n/ 
/'|awk '{print $6,$2}'|sed -e 's/\[size=//g'|sed -e 's/(//g'|sed -e 
's/)//g'|sed -e 's/\.0G/G/'|sort  this displays output like below 

size=100G 360060e8007dd94000030dd940000048e
size=100G 360060e8007dd94000030dd940000048f
size=200G 360060e8007dd94000030dd940000048d
size=50G 360060e8007dd94000030dd9400000490
size=5G 360060e8007dd94000030dd9400000491
size=5G 360060e8007dd94000030dd9400000492
size=5G 360060e8007dd94000030dd9400000493
size=5G 360060e8007dd94000030dd9400000494
size=5G 360060e8007dd94000030dd9400000495
size=5G 360060e8007dd94000030dd9400000496
size=5G 360060e8007dd94000030dd9400000497

once we have this output we usually copy this output into file like allluns 
and run a script like below  test-create-multipath-conf.sh to
#!/usr/bin/ksh
> multipath.cfg
k=0
v=0
j=0
while  read line
do
line1=`echo $line|awk '{print $1}'`
line2=`echo $line|awk '{print $2}'`
if [ "$line1" = "size=100G" ];then
j=`expr $j + 1`
echo "        multipath {" >> multipath.cfg
echo "              wwid $line2" >> multipath.cfg
echo "              alias data$j" >> multipath.cfg
echo "        }" >> multipath.cfg
elif [ "$line1" = "size=5G" ];then
v=`expr $v + 1`
echo "        multipath {" >> multipath.cfg
echo "              wwid $line2" >> multipath.cfg
echo "              alias redo$v" >> multipath.cfg
echo "        }" >> multipath.cfg
elif [ "$line1" = "size=200G" ];then
k=`expr $k + 1`
echo "        multipath {" >> multipath.cfg
echo "              wwid $line2" >> multipath.cfg
echo "              alias fra$k" >> multipath.cfg
echo "        }" >> multipath.cfg
fi

done < allluns
sed -i '$i}' multipath.cfg


and it creates output like below 
        multipath {
              wwid 360060e8007dd94000030dd940000048e
              alias data1
        }
        multipath {
              wwid 360060e8007dd94000030dd940000048f
              alias data2
        }
        multipath {
              wwid 360060e8007dd94000030dd940000048d
              alias fra1
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000491
              alias redo1
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000492
              alias redo2
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000493
              alias redo3
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000494
              alias redo4
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000495
              alias redo5
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000496
              alias redo6
        }
        multipath {
              wwid 360060e8007dd94000030dd9400000497
              alias redo7
}
        }


can any one help me with above requirement im trying to convert into 
ansible 

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c6dab864-24aa-4a57-b5c8-61d41125de04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to