Commit ef19bd82 authored by Swann Perarnau's avatar Swann Perarnau

[feature] base template for chameleon appliance

Derived from the complex appliances documentation.
I'm still in the process of understanding the whole softwareconfig part,
but it's a start.
parents
# Base Template for an Argo cluster:
# - use the chameleon default image
# - install argo dependencies
# - does not install argo software itself
# If used to deploy multiple nodes, will take care of allocating a floating IP
# for a frontend node
# OpenStack Liberty release version
heat_template_version: 2015-10-15
description: Bare-metal cluster with Argo dependencies
parameters:
key_name:
type: string
label: Key name
description: Name of a key pair to enable SSH access to the instance
default: default
constraints:
- custom_constraint: nova.keypair
reservation_id:
type: string
description: ID of the Blazar reservation to use for launching instances
constraints:
- custom_constraint: blazar.reservation
node_count:
type: number
label: Node count
description: Number of physical nodes
default: 1
constraints:
- range: { min: 1 }
description: There must be at least one physical node.
image:
type: string
label: Image
description: Image to use for all instances
default: CC-CentOS7
constraints:
- custom_constraint: glance.image
resources:
# generate a custom keypair for this appliance
argo_keypair:
type: OS::Nova::KeyPair
properties:
save_private_key: true
name:
str_replace:
template: argo_key_stack_id
params:
stack_id: { get_param: "OS::stack_id" }
deletion_policy: Delete
# floating IP for frontend
instance_floating_ip:
type: OS::Nova::FloatingIP
properties:
pool: public
deletion_policy: Delete
instance_association:
type: OS::Nova::FloatingIPAssociation
properties:
floating_ip: { get_resource: instance_floating_ip }
server_id: { get_attr: [argo_cluster, resource.0] }
# cluster configuration
# - initial config using cloud-init
# - software_config for global, post deploy information
argo_cluster:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: node_count }
resource_def:
type: OS::Nova::Server
properties:
name: argo-base-%index%
image: { get_param: image }
flavor: baremetal
key_name: { get_param: key_name }
networks:
- network: sharednet1
scheduler_hints: { reservation: { get_param: reservation_id } }
user_data_format: SOFTWARE_CONFIG
software_config_transport: POLL_SERVER_HEAT
user_data:
str_replace:
template: |
#!/bin/bash
cd /home/cc/.ssh/
cat << EOF > id_rsa.pub
public_key
EOF
cat << EOF > id_rsa
private_key
EOF
cat << EOF > config
Host *
StrictHostKeyChecking no
EOF
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys id_rsa
chmod 644 id_rsa.pub config
sudo chown cc:cc *
params:
private_key: { get_attr: [ argo_keypair, private_key ] }
public_key: { get_attr: [ argo_keypair, public_key ] }
# see chameleon doc
export_hosts:
type: OS::Heat::SoftwareConfig
properties:
outputs:
- name: hosts
group: script
config: |
#!/bin/sh
(echo -n $(facter ipaddress); echo -n ' '; echo $(facter hostname)) > ${heat_outputs_path}.hosts
export_hosts_sdg:
type: OS::Heat::SoftwareDeploymentGroup
properties:
config: { get_resource: export_hosts }
servers: { get_attr: [argo_cluster, refs_map] }
signal_transport: HEAT_SIGNAL
populate_hosts:
type: OS::Heat::SoftwareConfig
properties:
inputs:
- name: hosts
group: script
config: |
#!/usr/bin/env python
import ast
import os
import string
import subprocess
hosts = os.getenv('hosts')
if hosts is not None:
hosts = ast.literal_eval(string.replace(hosts, '\n', '\\n'))
with open('/etc/hosts', 'a') as hosts_file:
for ip_host in hosts.values():
hosts_file.write(ip_host.rstrip() + '\n')
populate_hosts_sdg:
type: OS::Heat::SoftwareDeploymentGroup
depends_on: export_hosts_sdg
properties:
config: { get_resource: populate_hosts }
servers: { get_attr: [argo_cluster, refs_map] }
signal_transport: HEAT_SIGNAL
input_values:
hosts: { get_attr: [ export_hosts_sdg, hosts ] }
outputs:
first_instance_ip:
description: The public IP address of the first instance. Login with the command 'ssh cc@first_instance_ip'.
value: { get_attr: [instance_floating_ip, ip] }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment