Example Heat Template Not Sure It Works
Example Heat Template Not Sure It Works
parameters:
image:
type: string
description: Image to use for the instance
default: Ubutnu-CLI-24.04
constraints:
- custom_constraint: glance.image
flavor:
type: string
description: Instance type
default: m1.small
constraints:
- custom_constraint: nova.flavor
key_name:
type: string
description: SSH key pair name
default: tiny-key
constraints:
- custom_constraint: nova.keypair
volume_size:
type: number
description: Size of volume in GB
default: 5
constraints:
- range: { min: 5, max: 100 }
availability_zone:
type: string
description: Availability zone for instance
default: nova
resources:
private_net:
type: OS::Neutron::Net
properties:
name: stack-net
private_subnet:
type: OS::Neutron::Subnet
properties:
network_id: { get_resource: private_net }
cidr: 172.16.2.0/24
dns_nameservers: [8.8.8.8]
router:
type: OS::Neutron::Router
properties:
external_gateway_info:
network: provider # Using your provider network
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router }
subnet_id: { get_resource: private_subnet }
volume:
type: OS::Cinder::Volume
properties:
size: { get_param: volume_size }
availability_zone: { get_param: availability_zone }
volume_type: __DEFAULT__
description: Volume for stack instance
security_group:
type: OS::Neutron::SecurityGroup
properties:
name: stack-security-group
description: Security group for stack instance
rules:
- protocol: icmp
- protocol: tcp
port_range_min: 22
port_range_max: 22
- protocol: tcp
port_range_min: 80
port_range_max: 80
- protocol: tcp
port_range_min: 443
port_range_max: 443
server_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_net }
fixed_ips:
- subnet_id: { get_resource: private_subnet }
security_groups: [{ get_resource: security_group }]
server:
type: OS::Nova::Server
properties:
name: stack-server
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
availability_zone: { get_param: availability_zone }
networks:
- port: { get_resource: server_port }
user_data: |
#cloud-config
#hostname: machinaaa
users:
- default
- name: kacem
groups: sudo
shell: /bin/bash
lock_passwd: false
passwd:
$6$eXqZO7oBwNBlnMxn$iEmf.Odml.tATHOXq0CXtly.cZzECOawcu23CUYJT5ldYz4bLVa/
Z815UZ9LaIqS8WhEN3SzHHqvylUZ1unMV1
chpasswd:
expire: false
runcmd:
- rm -f /etc/resolv.conf
- echo "nameserver 8.8.8.8" > /etc/resolv.conf
- echo "nameserver 8.8.4.4" >> /etc/resolv.conf
- chattr +i /etc/resolv.conf
- apt update
- apt install -y iputils-ping
- loadkeys fr
- sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="fr"/g' /etc/default/keyboard
- dpkg-reconfigure -f noninteractive keyboard-configuration
- service keyboard-setup restart
volume_attachment:
type: OS::Cinder::VolumeAttachment
properties:
volume_id: { get_resource: volume }
instance_uuid: { get_resource: server }
floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network: provider
floating_ip_assoc:
type: OS::Neutron::FloatingIPAssociation
properties:
floatingip_id: { get_resource: floating_ip }
port_id: { get_resource: server_port }
outputs:
server_floating_ip:
description: Floating IP address of the deployed instance
value: { get_attr: [floating_ip, floating_ip_address] }
server_private_ip:
description: Private IP address of the deployed instance
value: { get_attr: [server, first_address] }
volume_id:
description: ID of the attached volume
value: { get_resource: volume }