Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
195 lines (183 sloc) 6.59 KB
heat_template_version: 2013-05-23
description: Base Heat stack with single-node Salt master
parameters:
key_name:
type: string
key_value:
type: string
cfg01_name:
type: string
default: cfg01.workshop.cloudlab.cz
reclass_address:
type: string
default: https://github.com/tcpcloud/workshop-salt-model.git
reclass_branch:
type: string
default: master
instance_flavor:
type: string
description: Instance type for servers
default: m1.small
constraints:
- allowed_values: [m1.tiny, m1.small, m1.medium, m1.large, m1.xlarge]
description: instance_type must be a valid instance type
instance_image:
type: string
description: Image name to use for the servers.
default: ubuntu-14-04-x64-1437486976
availability_zone:
type: string
public_net_id:
type: string
description: ID or name of public network for which floating IP addresses will be allocated
router_name:
type: string
description: Name of router to be created
default: workshop-router
private_net_name:
type: string
description: Name of private network to be created
default: workshop-net
private_net_cidr:
type: string
description: Private network address (CIDR notation)
default: 172.16.10.0/24
private_net_pool_start:
type: string
description: Start of private network IP address allocation pool
default: 172.16.10.100
private_net_pool_end:
type: string
description: End of private network IP address allocation pool
default: 172.16.10.200
resources:
keypair:
type: OS::Nova::KeyPair
properties:
name: { get_param: key_name }
public_key: { get_param: key_value }
save_private_key: false
private_net:
type: OS::Neutron::Net
properties:
name: { get_param: private_net_name }
private_subnet:
type: OS::Neutron::Subnet
properties:
name: { get_param: private_net_name }
network_id: { get_resource: private_net }
cidr: { get_param: private_net_cidr }
allocation_pools:
- start: { get_param: private_net_pool_start }
end: { get_param: private_net_pool_end }
router:
type: OS::Neutron::Router
properties:
name: { get_param: router_name }
external_gateway_info:
network: { get_param: public_net_id }
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router }
subnet_id: { get_resource: private_subnet }
workshop_security_group:
type: OS::Neutron::SecurityGroup
properties:
name: workshop
description: Workshop security group
rules:
- protocol: tcp
remote_ip_prefix: 0.0.0.0/0
- protocol: icmp
remote_ip_prefix: 0.0.0.0/0
cfg01_floating_ip:
type: OS::Nova::FloatingIP
properties:
pool: { get_param: public_net_id }
cfg01_floating_ip_association:
type: OS::Nova::FloatingIPAssociation
properties:
floating_ip: { get_resource: cfg01_floating_ip }
server_id: { get_resource: cfg01_instance }
cfg01_instance:
type: OS::Nova::Server
properties:
image: { get_param: instance_image }
flavor: { get_param: instance_flavor }
key_name: { get_resource: keypair }
name: { get_param: cfg01_name }
availability_zone: { get_param: availability_zone }
networks:
- network: { get_resource: private_net }
security_groups:
- default
- { get_resource: workshop_security_group }
user_data_format: RAW
user_data:
str_replace:
template: |
#!/bin/bash
echo "Preparing base OS"
which wget >/dev/null || (apt-get update; apt-get install -y wget)
echo "deb [arch=amd64] http://apt.tcpcloud.eu/nightly/ trusty main security extra tcp tcp-salt" > /etc/apt/sources.list
wget -O - http://apt.tcpcloud.eu/public.gpg | apt-key add -
apt-get clean
apt-get update
echo "Configuring salt master ..."
apt-get install -y salt-master reclass
apt-get install -y salt-formula-linux salt-formula-reclass salt-formula-salt salt-formula-openssh salt-formula-ntp salt-formula-git salt-formula-graphite salt-formula-collectd salt-formula-sensu salt-formula-heka
# Temporary until multi-site horizon is deployed on salt master
apt-get install -y salt-formula-horizon salt-formula-nginx salt-formula-memcached salt-formula-python salt-formula-supervisor
cat << 'EOF' >> /etc/salt/master.d/master.conf
file_roots:
base:
- /usr/share/salt-formulas/env
pillar_opts: False
open_mode: True
reclass: &reclass
storage_type: yaml_fs
inventory_base_uri: /srv/salt/reclass
ext_pillar:
- reclass: *reclass
master_tops:
reclass: *reclass
EOF
echo "Configuring reclass ..."
git clone $reclass_address /srv/salt/reclass -b $reclass_branch
mkdir -p /srv/salt/reclass/classes/service
for i in /usr/share/salt-formulas/reclass/service/*; do
ln -s $i /srv/salt/reclass/classes/service/
done
[ ! -d /etc/reclass ] && mkdir /etc/reclass
cat << 'EOF' >> /etc/reclass/reclass-config.yml
storage_type: yaml_fs
pretty_print: True
output: yaml
inventory_base_uri: /srv/salt/reclass
EOF
echo "Configuring salt minion ..."
apt-get install -y salt-minion
[ ! -d /etc/salt/minion.d ] && mkdir -p /etc/salt/minion.d
cat << "EOF" >> /etc/salt/minion.d/minion.conf
id: $node_name
master: localhost
EOF
echo "Restarting services ..."
service salt-master restart
rm -f /etc/salt/pki/minion/minion_master.pub
service salt-minion restart
echo "Showing system info and metadata ..."
salt-call --no-color grains.items
salt-call --no-color pillar.data
reclass -n $node_name
echo "Running complete state ..."
salt-call --no-color state.sls linux openssh salt.minion
salt-call --no-color state.sls salt.master
service salt-minion restart
#salt-call --no-color state.highstate
params:
$node_name: { get_param: cfg01_name }
$reclass_address: { get_param: reclass_address }
$reclass_branch: { get_param: reclass_branch }
$config_host: localhost