Skip to content

Instantly share code, notes, and snippets.

@seaneagan
Created May 9, 2018 20:04
Show Gist options
  • Save seaneagan/9b8455fca7edfe396a185f592f8eca36 to your computer and use it in GitHub Desktop.
Save seaneagan/9b8455fca7edfe396a185f592f8eca36 to your computer and use it in GitHub Desktop.
# Copyright 2018 The OpenStack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# openstack keypair create --public-key ~/.ssh/id_rsa.pub osh-vm-key
# openstack orchestration template validate -t 030-osh-cluster.yaml
# openstack stack create --wait -t 030-osh-cluster.yaml osh-cluster
heat_template_version: '2016-10-14'
parameters:
node_count:
type: number
public_net:
type: string
default: public
private_net_cidr:
type: string
default: 10.11.11.0/24
storage_net_cidr:
type: string
default: 10.11.12.0/24
image:
type: string
default: cicd-upstream-Ubuntu-16.04-image
ssh_key:
type: string
default: jenkins-slave-keypair
flavor:
type: string
default: osh-node-flavor
osh_infra_repo_location:
type: string
default: https://git.openstack.org/openstack/openstack-helm-infra
osh_infra_repo_ref:
type: string
default: master
resources:
deploy_key:
type: OS::Nova::KeyPair
properties:
name: deploy_key
save_private_key: true
router:
type: OS::Neutron::Router
properties:
external_gateway_info:
network:
get_param: public_net
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id:
get_resource: router
subnet_id:
get_resource: private_subnet
private_net:
type: OS::Neutron::Net
private_subnet:
type: OS::Neutron::Subnet
properties:
network:
get_resource: private_net
cidr:
get_param: private_net_cidr
dns_nameservers:
- 8.8.8.8
- 8.8.4.4
storage_net:
type: OS::Neutron::Net
storage_subnet:
type: OS::Neutron::Subnet
properties:
gateway_ip:
network:
get_resource: storage_net
cidr:
get_param: storage_net_cidr
nodes:
type: "OS::Heat::ResourceGroup"
properties:
count: { get_param: node_count }
resource_def:
type: osh-node.yaml
properties:
node_index: "%index%"
image: { get_param: image }
ssh_key: { get_param: ssh_key }
flavor: { get_param: flavor }
deploy_public_key:
get_attr:
- deploy_key
- public_key
server_floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network:
get_param: public_net
port_id:
get_resource:
get_attr:
- nodes
- refs
- 0
outputs:
floating_ip:
value:
get_attr:
- server_floating_ip
- floating_ip_address
parameters:
node_index:
type: number
image:
type: string
ssh_key:
type: string
flavor:
type: string
osh_infra_repo_location:
type: string
osh_infra_repo_ref:
type: string
resources:
private_net_port:
type: OS::Neutron::Port
properties:
network:
get_resource: private_net
fixed_ips:
- subnet:
get_resource: private_subnet
port_security_enabled: false
storage_net_port:
type: OS::Neutron::Port
properties:
network:
get_resource: storage_net
fixed_ips:
- subnet:
get_resource: storage_subnet
port_security_enabled: false
server:
type: OS::Nova::Server
properties:
image:
get_param: image
flavor:
get_param: flavor
key_name:
get_param: ssh_key
networks:
- port:
get_resource: private_net_port
- port:
get_resource: storage_net_port
user_data_format: RAW
user_data:
str_replace:
template: |
#!/bin/bash -v
echo "$node_admin_ip $(hostname -s)" >> /etc/hosts
sudo -H su -c 'echo "$deploy_public_key" >> ~/.ssh/authorized_keys' ubuntu
apt-get update
apt-get install --no-install-recommends -y \
git
sudo -H chown -R ubuntu: /opt
sudo -H su -c 'git clone $osh_infra_repo_location /opt/openstack-helm-infra; cd /opt/openstack-helm-infra; git pull $osh_infra_repo_location $osh_infra_repo_ref ' ubuntu
params:
"$osh_infra_repo_location":
get_param: osh_infra_repo_location
"$osh_infra_repo_ref":
get_param: osh_infra_repo_ref
"$node_admin_ip":
get_attr:
- private_net_port
- fixed_ips
- 0
- ip_address
"$deploy_public_key":
get_param: deploy_public_key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment