Merge "Updates and fixes to NIC config template routes"
[apex-tripleo-heat-templates.git] / deployed-server / deployed-server.yaml
1 heat_template_version: 2014-10-16
2 parameters:
3   image:
4     type: string
5     default: unused
6   flavor:
7     type: string
8     default: unused
9   key_name:
10     type: string
11     default: unused
12   security_groups:
13     type: json
14     default: []
15   # Require this so we can validate the parent passes the
16   # correct value
17   user_data_format:
18     type: string
19   user_data:
20     type: string
21     default: ''
22   name:
23     type: string
24     default: ''
25   image_update_policy:
26     type: string
27     default: ''
28   networks:
29     type: comma_delimited_list
30     default: ''
31   metadata:
32     type: json
33     default: {}
34   software_config_transport:
35     default: POLL_SERVER_CFN
36     type: string
37   scheduler_hints:
38     type: json
39     description: Optional scheduler hints to pass to nova
40     default: {}
41
42 resources:
43   # We just need something which returns a unique ID, but we can't
44   # use RandomString because RefId returns the value, not the physical
45   # resource ID, SoftwareConfig should work as it returns a UUID
46   deployed-server:
47     type: OS::TripleO::DeployedServerConfig
48     properties:
49       user_data_format: SOFTWARE_CONFIG
50
51   InstanceIdConfig:
52     type: OS::Heat::StructuredConfig
53     properties:
54       group: os-apply-config
55       config:
56         instance-id: {get_attr: [deployed-server, "OS::stack_id"]}
57
58   InstanceIdDeployment:
59     type: OS::Heat::StructuredDeployment
60     properties:
61       config: {get_resource: InstanceIdConfig}
62       server: {get_resource: deployed-server}
63
64   HostsEntryConfig:
65     type: OS::Heat::SoftwareConfig
66     properties:
67       group: script
68       config: |
69           #!/bin/bash
70           set -eux
71           mkdir -p $heat_outputs_path
72           host=$(hostnamectl --static)
73           echo -n "$host "  > $heat_outputs_path.hosts_entry
74           host_ip=$(python -c "import socket; print socket.gethostbyname(\"$host\")")
75           echo -n "$host_ip " >> $heat_outputs_path.hosts_entry
76           echo >> $heat_outputs_path.hosts_entry
77           cat $heat_outputs_path.hosts_entry
78           echo -n $host_ip > $heat_outputs_path.ip_address
79           cat $heat_outputs_path.ip_address
80           echo -n $host > $heat_outputs_path.hostname
81           cat $heat_outputs_path.hostname
82       outputs:
83         - name: hosts_entry
84           description: hosts_entry
85         - name: ip_address
86           description: ip_address
87         - name: hostname
88           description: hostname
89
90   HostsEntryDeployment:
91     type: OS::Heat::SoftwareDeployment
92     properties:
93       config: {get_resource: HostsEntryConfig}
94       server: {get_resource: deployed-server}
95
96   ControlPlanePort:
97     type: OS::TripleO::DeployedServer::ControlPlanePort
98     properties:
99       Hostname: {get_attr: [HostsEntryDeployment, hostname]}
100
101 outputs:
102   # FIXME(shardy) this is needed because TemplateResource returns an
103   # ARN not a UUID, which overflows the Deployment server_id column..
104   OS::stack_id:
105     value: {get_attr: [deployed-server, "OS::stack_id"]}
106   networks:
107     value:
108       ctlplane:
109         - {get_attr: [ControlPlanePort, ip_address]}
110   name:
111    value: {get_attr: [HostsEntryDeployment, hostname]}
112   hosts_entry:
113    value: {get_attr: [HostsEntryDeployment, hosts_entry]}
114   ip_address:
115     value: {get_attr: [HostsEntryDeployment, ip_address]}