centos1, 2, 3 삭제 (destroy, undefine) centos01.qcow2 , centos01.qcow2 , centos03.qcow3 삭제

원본파일을 이용하여 centos01.qcow2 , centos01.qcow2 , centos03.qcow3 다시 복사

virt-install 한 다음 centos1, centos2는 nfs-client로 centos3은 nfs-server 구성하는 플레이북을 만드세요!

centos1, 2, 3 삭제

  1. [root@vagrant sim]# virsh destroy centos1 [root@vagrant sim]# virsh destroy centos2 [root@vagrant sim]# virsh destroy centos3

    [root@vagrant sim]# virsh destroy centos1
    Domain centos1 destroyed
    
    [root@vagrant sim]# virsh destroy centos2
    Domain centos2 destroyed
    
    [root@vagrant sim]# virsh destroy centos3
    Domain centos3 destroyed
    
  2. [root@vagrant sim]# virsh undefine centos1 [root@vagrant sim]# virsh undefine centos2 [root@vagrant sim]# virsh undefine centos3

    [root@vagrant sim]# virsh undefine centos1
    Domain centos1 has been undefined
    
    [root@vagrant sim]# virsh undefine centos2
    Domain centos2 has been undefined
    
    [root@vagrant sim]# virsh undefine centos3
    Domain centos3 has been undefined
    

파일 다시 복사

  1. [root@vagrant sim]# ls

    [root@vagrant sim]# ls
    centos01.qcow2  centos02.qcow2  centos03.qcow2  my_inven.txt  web_inven.txt  web.yml
    
  2. [root@vagrant sim]# rm -rf centos* [root@vagrant sim]# ls

    [root@vagrant sim]# rm -rf centos*
    [root@vagrant sim]# ls
    my_inven.txt  web_inven.txt  web.yml
    
  3. [root@vagrant sim]# ls ~

    [root@vagrant sim]# ls ~
    anaconda-ks.cfg  Desktop    initial-setup-ks.cfg  Public     vagrant_2.2.16_x86_64.rpm
    centos01.qcow2   Documents  Music                 Templates  Vagrantfile
    cent.yml         Downloads  Pictures              vagrant    Videos
    
  4. [root@vagrant sim]# cp ~/centos01.qcow2 ./centos01.qcow2 [root@vagrant sim]# cp ~/centos01.qcow2 ./centos02.qcow2 [root@vagrant sim]# cp ~/centos01.qcow2 ./centos03.qcow2 [root@vagrant sim]# ls

    [root@vagrant sim]# cp ~/centos01.qcow2 ./centos01.qcow2
    [root@vagrant sim]# cp ~/centos01.qcow2 ./centos02.qcow2
    [root@vagrant sim]# cp ~/centos01.qcow2 ./centos03.qcow2
    [root@vagrant sim]# ls
    centos01.qcow2  centos02.qcow2  centos03.qcow2  my_inven.txt  web_inven.txt  web.yml
    
  5. [root@vagrant sim]# virsh list

    [root@vagrant sim]# virsh list
     Id    Name                           State
    ----------------------------------------------------
     31    centos1                        running
     32    centos2                        running
     33    centos3                        running
    

KVM 생성

  1. [root@vagrant sim]# virt-install --name centos1 --ram 1024 --disk path=./centos01.qcow2 --vcpus 1 --graphics none --serial pty --console pty --import &
  2. [root@vagrant sim]# virt-install --name centos2 --ram 1024 --disk path=./centos02.qcow2 --vcpus 1 --graphics none --serial pty --console pty --import &
  3. [root@vagrant sim]# virt-install --name centos3 --ram 1024 --disk path=./centos03.qcow2 --vcpus 1 --graphics none --serial pty --console pty --import &

NFS 설정

  1. [root@vagrant sim]# virsh domifaddr centos1 [root@vagrant sim]# virsh domifaddr centos2 [root@vagrant sim]# virsh domifaddr centos3

    [root@vagrant sim]# virsh domifaddr centos1
     Name       MAC address          Protocol     Address
    -------------------------------------------------------------------------------
     vnet0      52:54:00:77:89:9e    ipv4         192.168.122.172/24
    
    [root@vagrant sim]# virsh domifaddr centos2
     Name       MAC address          Protocol     Address
    -------------------------------------------------------------------------------
     vnet1      52:54:00:d3:0a:39    ipv4         192.168.122.9/24
    
    [root@vagrant sim]# virsh domifaddr centos3
     Name       MAC address          Protocol     Address
    -------------------------------------------------------------------------------
     vnet2      52:54:00:82:41:fc    ipv4         192.168.122.175/24
    
  2. [root@vagrant ~]# vi /etc/ansible/hosts

    192.168.122.172
    192.168.122.9
    192.168.122.175
    
    # This is the default ansible 'hosts' file.
    ...