#!/bin/bash
#
#此脚本还写了个ansible的playbook
#
grep "223.5.5.5" /etc/sysconfig/network-scripts/ifcfg-eth0
if [ $? == 1 ];then
	  echo "DNS1=223.5.5.5" >> /etc/sysconfig/network-scripts/ifcfg-eth0
	    echo "nameserver 223.5.5.5" >> /etc/resolv.conf
fi
##ansible  file  absent
rm -f /etc/yum.repos.d/epel.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

yum clean all
yum makecache
#ansible all -m yum -a 'name=lvm2 state=present'
yum install -y lvm2

pvcreate /dev/vdb
vgcreate centos /dev/vdb
lvcreate -l 100%VG -n data centos

mkfs -t xfs /dev/centos/data
# ansible file
mkdir /data

myuuid=$(blkid |grep centos-data|awk  '{print $2}'|sed 's/\"//g')
if [ -n "$myuuid" ];then
    echo "$myuuid /data                    xfs  defaults  1 1" >> /etc/fstab
    #echo "/dev/mapper/centos-data /data                    xfs  defaults  1 1" >> /etc/fstab
    mount -a
fi
