Advertisement
alvise72

Esercitazione Heat: NFS Farm

Oct 1st, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.34 KB | None | 0 0
  1. heat_template_version: 2013-05-23
  2. description: Creiamo due risorse Nova::Server. Una un server NFS, una un client NFS. Gli IP questa volta sono fissati per le VM per far in modo che l'NFS server sappia giĆ  (senza intervento dell'utente) a quale client esportare via NFS.
  3. resources:
  4.   my_volume:
  5.     type: OS::Cinder::Volume
  6.     properties:
  7.       name: "myVolume"
  8.       size: 3
  9.  
  10.   NFS_Sec_Group:
  11.     type: OS::Neutron::SecurityGroup
  12.     properties:
  13.       description: "Access to NFS protocol"
  14.       name: NFS-farm
  15.       rules: [{"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 111, "remote_mode": remote_ip_prefix, "port_range_max": 111, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 2049, "remote_mode": remote_ip_prefix, "port_range_max": 2049, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 32768, "remote_mode": remote_ip_prefix, "port_range_max": 32768, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 44182, "remote_mode": remote_ip_prefix, "port_range_max": 44182, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 54508, "remote_mode": remote_ip_prefix, "port_range_max": 54508, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 111, "remote_mode": remote_ip_prefix, "port_range_max": 111, "protocol": UDP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 2049, "remote_mode": remote_ip_prefix, "port_range_max": 2049, "protocol": UDP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 32768, "remote_mode": remote_ip_prefix, "port_range_max": 32768, "protocol": UDP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 32770, "remote_mode": remote_ip_prefix, "port_range_max": 32800, "protocol": UDP}]
  16.  
  17.   SSH_Sec_Group:
  18.     type: OS::Neutron::SecurityGroup
  19.     properties:
  20.       description: "Access to SSH"
  21.       name: SSH-farm
  22.       rules: [{"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "port_range_min": 22, "remote_mode": remote_ip_prefix, "port_range_max": 22, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.135.0/24, "port_range_min": 22, "remote_mode": remote_ip_prefix, "port_range_max": 22, "protocol": TCP}, {"direction": ingress, "remote_ip_prefix": 192.168.1.0/24, "remote_mode": remote_ip_prefix, "protocol": ICMP}, {"direction": ingress, "remote_ip_prefix": 192.168.135.0/24, "remote_mode": remote_ip_prefix, "protocol": ICMP} ]
  23.  
  24.   my_instance_1:
  25.     type: OS::Nova::Server
  26.     properties:
  27.       name: "NFS-Server"
  28.       key_name: KeyStudenteXY
  29.       image: Ubuntu x86_64
  30.       flavor: m1.small
  31.       security_groups: [{Ref: NFS_Sec_Group}, {Ref: SSH_Sec_Group}]
  32.       admin_pass: heattest1
  33.       networks: [{"network": NetStudenteXY, "fixed_ip": 192.168.1.113}]
  34.       user_data: |
  35.        #!/bin/bash
  36.         apt-get update
  37.         apt-get install --yes nfs-common nfs-server
  38.         cat << EOF >> /etc/exports
  39.         /nfsexport 192.168.1.114(rw,insecure,sync,no_root_squash)
  40.         EOF
  41.         mkdir /nfsexport
  42.         /etc/init.d/nfs-kernel-server start
  43.         exportfs -av
  44.         cat << EOF > /root/fdisk.sh
  45.         n
  46.         p
  47.         1
  48.        
  49.        
  50.         wq
  51.         EOF
  52.         fdisk /dev/vdb < /root/fdisk.sh
  53.         mkfs.ext4 /dev/vdb1
  54.         mount /dev/vdb1 /nfsexport
  55.  
  56.   my_instance_2:
  57.     type: OS::Nova::Server
  58.     properties:
  59.       name: "NFS-Client"
  60.       key_name: KeyStudenteXY
  61.       image: Ubuntu x86_64
  62.       flavor: m1.small
  63.       security_groups: [{Ref: NFS_Sec_Group}, {Ref: SSH_Sec_Group}]
  64.       admin_pass: heattest2
  65.       networks: [{"network": NetStudenteXY, "fixed_ip": 192.168.1.114}]
  66.       user_data: |
  67.        #!/bin/bash
  68.         apt-get update
  69.         apt-get install --yes nfs-common
  70.  
  71.   my_volume_attachment:
  72.     type: OS::Cinder::VolumeAttachment
  73.     properties:
  74.       volume_id: { get_resource: my_volume }
  75.       instance_uuid: { get_resource: my_instance_1 }
  76.  
  77.   my_fip:
  78.     type: OS::Nova::FloatingIP
  79.     properties:
  80.       pool: External
  81.  
  82.   my_fip_association:
  83.     type: OS::Nova::FloatingIPAssociation
  84.     properties:
  85.       floating_ip: { get_resource: my_fip }
  86.       server_id: { get_resource: my_instance_2 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement