Last active
          August 29, 2015 14:04 
        
      - 
      
- 
        Save therve/0e1148296c6c9b43cb55 to your computer and use it in GitHub Desktop. 
    Heat Docker template using wait conditions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | heat_template_version: 2013-05-23 | |
| description: > | |
| Heat Docker template using wait conditions. | |
| parameters: | |
| key_name: | |
| type: string | |
| description : Name of a KeyPair to enable SSH access to the instance | |
| default: heat | |
| instance_type: | |
| type: string | |
| description: Instance type for WordPress server | |
| default: m1.small | |
| image_id: | |
| type: string | |
| description: > | |
| Name or ID of the image to use for the Docker server. | |
| Recommended values are fedora-20.i386 or fedora-20.x86_64; | |
| get them from http://cloud.fedoraproject.org/fedora-20.i386.qcow2 | |
| or http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2 . | |
| resources: | |
| docker_sg: | |
| type: OS::Neutron::SecurityGroup | |
| properties: | |
| description: Ping, SSH, Docker | |
| 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: 2345 | |
| port_range_max: 2345 | |
| docker_wait_handle: | |
| type: AWS::CloudFormation::WaitConditionHandle | |
| docker_wait_condition: | |
| type: AWS::CloudFormation::WaitCondition | |
| depends_on: [docker_host] | |
| properties: | |
| Handle: | |
| get_resource: docker_wait_handle | |
| Timeout: '6000' | |
| docker_host: | |
| type: OS::Nova::Server | |
| properties: | |
| image: {get_param: image_id} | |
| flavor: {get_param: instance_type} | |
| key_name: {get_param: key_name} | |
| security_groups: | |
| - {get_resource: docker_sg} | |
| user_data_format: RAW | |
| user_data: | |
| str_replace: | |
| template: | | |
| #!/bin/bash -v | |
| setenforce 0 | |
| yum -y install docker-io | |
| cp /usr/lib/systemd/system/docker.service /etc/systemd/system/ | |
| sed -i -e '/ExecStart/ { s,fd://,tcp://0.0.0.0:2345, }' /etc/systemd/system/docker.service | |
| systemctl start docker.service | |
| cfn-signal -e 0 --data "OK" -r "Setup complete" "WAIT_HANDLE" | |
| params: | |
| WAIT_HANDLE: {get_resource: docker_wait_handle} | |
| database_password: | |
| type: OS::Heat::RandomString | |
| database: | |
| type: DockerInc::Docker::Container | |
| depends_on: [docker_wait_condition] | |
| properties: | |
| image: mysql | |
| name: db | |
| docker_endpoint: | |
| str_replace: | |
| template: http://host:2345/ | |
| params: | |
| host: {get_attr: [docker_host, networks, private, 0]} | |
| env: | |
| - {str_replace: {template: MYSQL_ROOT_PASSWORD=password, | |
| params: {password: {get_attr: [database_password, value]}}} | |
| wordpress: | |
| type: DockerInc::Docker::Container | |
| depends_on: [database] | |
| properties: | |
| image: wordpress | |
| links: | |
| db: mysql | |
| port_bindings: | |
| 80/tcp: [{"HostPort": "80"}] | |
| docker_endpoint: | |
| str_replace: | |
| template: http://host:2345/ | |
| params: | |
| host: {get_attr: [docker_host, networks, private, 0]} | |
| outputs: | |
| info: | |
| description: Public address of the web site | |
| value: | |
| str_replace: | |
| template: http://host/wordpress | |
| params: | |
| host: {get_attr: [docker_host, networks, private, 0]} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment