Merge "Allow for specifying the output_dir"
[apex-tripleo-heat-templates.git] / deployed-server / deployed-server.yaml
1 heat_template_version: ocata
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: 'deployed-server'
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   UpgradeInitCommand:
42     type: string
43     description: |
44       Command or script snippet to run on all overcloud nodes to
45       initialize the upgrade process. E.g. a repository switch.
46     default: ''
47
48 resources:
49   deployed-server:
50     type: OS::Heat::DeployedServer
51     properties:
52       name: {get_param: name}
53       software_config_transport: {get_param: software_config_transport}
54
55   UpgradeInitConfig:
56     type: OS::Heat::SoftwareConfig
57     properties:
58       group: script
59       config:
60         list_join:
61         - ''
62         - - "#!/bin/bash\n\n"
63           - "if [[ -f /etc/resolv.conf.save ]] ; then rm /etc/resolv.conf.save; fi\n\n"
64           - get_param: UpgradeInitCommand
65
66   UpgradeInitDeployment:
67     type: OS::Heat::SoftwareDeployment
68     properties:
69       name: UpgradeInitDeployment
70       server: {get_resource: deployed-server}
71       config: {get_resource: UpgradeInitConfig}
72
73
74   InstanceIdConfig:
75     type: OS::Heat::StructuredConfig
76     properties:
77       group: apply-config
78       config:
79         instance-id: {get_resource: deployed-server}
80
81   InstanceIdDeployment:
82     type: OS::Heat::StructuredDeployment
83     properties:
84       config: {get_resource: InstanceIdConfig}
85       server: {get_resource: deployed-server}
86     depends_on: UpgradeInitDeployment
87
88   HostsEntryConfig:
89     type: OS::Heat::SoftwareConfig
90     properties:
91       group: script
92       config: |
93           #!/bin/bash
94           set -eux
95           mkdir -p $heat_outputs_path
96           host=$(hostname -s)
97           echo -n $host > $heat_outputs_path.hostname
98           cat $heat_outputs_path.hostname
99       outputs:
100         - name: hostname
101           description: hostname
102
103   HostsEntryDeployment:
104     type: OS::Heat::SoftwareDeployment
105     properties:
106       config: {get_resource: HostsEntryConfig}
107       server: {get_resource: deployed-server}
108
109   DeployedServerBootstrapConfig:
110     type: OS::TripleO::DeployedServer::Bootstrap
111     properties:
112       server: {get_resource: deployed-server}
113
114   ControlPlanePort:
115     type: OS::TripleO::DeployedServer::ControlPlanePort
116     properties:
117       network: ctlplane
118       name:
119         list_join:
120           - '-'
121           - - {get_attr: [HostsEntryDeployment, hostname]}
122             - ctlplane
123       replacement_policy: AUTO
124
125 outputs:
126   OS::stack_id:
127     value: {get_resource: deployed-server}
128   networks:
129     value:
130       ctlplane:
131         - {get_attr: [ControlPlanePort, fixed_ips, 0, ip_address]}
132   name:
133     value: {get_attr: [HostsEntryDeployment, hostname]}