...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
heat_template_version: 2018-08-31 description: > This template creates, installs and configures a fileserver, servingand as thefileclient file-repository for a certain NICE2 projectthe heat-guide. parameters: flavor: type: string label: Fileserver flavor description: The flavor used to spawn the fileserver constraints: - custom_constraint: nova.flavor ubuntu: type: string label: Fileserver image description: The image used to spawn the fileserver constraints: - custom_constraint: glance.image admin-ssh-key: type: string label: SSH Key admin description: The SSH-key to inject in the fileserver for admin-purposes. user-ssh-key: type: string label: SSH Key User description: The SSH-key to inject in the fileserver for the user user. secgroup_generic: type: string network: type: string volume_type: type: string label: Volume type description: The cinder-type used to create the volume for the fileserver default: 'HDD-300' constraints: - custom_constraint: cinder.vtype volume_size: type: number label: Volume size default: 2 description: The size of the exported volume from the fileserver resources: fileserver: type: OS::Nova::Server properties: name: str_replace: template: 'STACK-fileserver' params: STACK: { get_param: OS::stack_name } image: { get_param: ubuntu } flavor: { get_param: flavor } networks: - {"port": { get_resource: fileserver_port }} user_data_format: RAW user_data: { get_resource: cloudconf_fileserver } fileserver_port: type: OS::Neutron::Port properties: admin_state_up: true network_id: { get_param: network } security_groups: [{ get_param: secgroup_generic }] fileserver_floatingip: type: OS::Neutron::FloatingIP properties: floating_network: 'ntnu-internal' port_id: { get_resource: fileserver_port } volume: type: OS::Cinder::Volume properties: size: { get_param: volume_size } volume_type: { get_param: volume_type } volume_attach: type: OS::Cinder::VolumeAttachment properties: instance_uuid: { get_resource: fileserver } volume_id: { get_resource: volume } cloudconf_fileserver: type: OS::Heat::MultipartMime properties: parts: - config: {get_resource: cloudconf_base} - config: {get_resource: cloudconf_fileservers} - config: {get_resource: script_fileserver} cloudconf_base: type: OS::Heat::CloudConfig properties: cloud_config: package_update: true package_upgrade: true timezone: "Europe/Oslo" users: - name: administrator sudo: ALL=(ALL) NOPASSWD:ALL lock_passwd: True shell: /bin/bash ssh_authorized_keys: - { get_param: admin-ssh-key } - name: user lock_passwd: True shell: /bin/bash ssh_authorized_keys: - { get_param: user-ssh-key } power_state: mode: 'reboot' message: 'Reboots after installing' condition: True cloudconf_fileservers: type: OS::Heat::CloudConfig properties: cloud_config: packages: - 'nfs-kernel-server' - 'pwgen' write_files: - content: '/opt/data/shared 192.168.0.0/24(rw,sync,no_subtree_check)' path: '/etc/exports' - content: | options lockd nlm_udpport=32768 nlm_tcpport=32768 options nfs callback_tcpport=32764 path: '/etc/modprobe.d/local.conf' disk_setup: /dev/vdb: table_type: gpt layout: true overwrite: false fs_setup: - filesystem: 'ext4' label: 'datapartition' device: '/dev/vdb' partition: 'auto' script_fileserver: type: OS::Heat::SoftwareConfig properties: group: ungrouped config: | #!/bin/bash # Restrict NFS ports sed -i -r 's/STATDOPTS=.*/STATDOPTS="--port 32765 --outgoing-port 32766"/' /etc/default/nfs-common sed -i -r 's/RPCMOUNTDOPTS=.*/RPCMOUNTDOPTS="-p 32767"/' /etc/default/nfs-kernel-server # Mount disks echo "/dev/vdb1 /opt/data ext4 defaults,comment=cloudconfig 0 0" >> /etc/fstab mkdir /opt/data mount /dev/vdb1 /opt/data mkdir /opt/data/shared chown user:user /opt/data/shared cloudconf_nfsmount: type: OS::Heat::CloudConfig properties: cloud_config: packages: - 'nfs-common' write_files: - content: str_replace: template: 'IP:/opt/data/shared /mnt/filserver nfs4 defaults 0 0' params: IP: { get_attr: [ fileserver, networks, {get_param: network}, 0 ] } path: '/etc/fstab' append: true cloudconf_client: type: OS::Heat::MultipartMime properties: parts: - config: {get_resource: cloudconf_base} - config: {get_resource: cloudconf_nfsmount} nfsclient: type: OS::Nova::Server properties: name: str_replace: template: 'STACK-client' params: STACK: { get_param: OS::stack_name } image: { get_param: ubuntu } flavor: { get_param: flavor } networks: - {"port": { get_resource: nfsclient_port }} user_data_format: RAW user_data: { get_resource: cloudconf_client } nfsclient_port: type: OS::Neutron::Port properties: admin_state_up: true network_id: { get_param: network } security_groups: [{ get_param: secgroup_generic }] nfsclient_floatingip: type: OS::Neutron::FloatingIP properties: floating_network: 'ntnu-internal' port_id: { get_resource: nfsclient_port } outputs: fileserver_address: description: Fileserver address value: { get_attr: [ fileserver_floatingip, fixed_ip_address ] } fileserver_floating_address: description: Fileserver floating IP address value: { get_attr: [ fileserver_floatingip, floating_ip_address ] } client_address: description: Client address value: { get_attr: [ nfsclient_floatingip, fixed_ip_address ] } client_floating_address: description: Client floating IP address value: { get_attr: [ nfsclient_floatingip, floating_ip_address ] } |
...