3b00288070774381a878005a61931955cf902c13
[apex-tripleo-heat-templates.git] / puppet / services / ec2-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack EC2-API service configured with Puppet
5
6 parameters:
7   ServiceNetMap:
8     default: {}
9     description: Mapping of service_name -> network name. Typically set
10                  via parameter_defaults in the resource registry.  This
11                  mapping overrides those in ServiceNetMapDefaults.
12     type: json
13   DefaultPasswords:
14     default: {}
15     type: json
16   EndpointMap:
17     default: {}
18     description: Mapping of service endpoint -> protocol. Typically set
19                  via parameter_defaults in the resource registry.
20     type: json
21   Ec2ApiWorkers:
22     default: 0
23     description: Number of workers for EC2-API service.
24     type: number
25   Ec2ApiPassword:
26     description: The password for the nova service and db account, used by nova-api.
27     type: string
28     hidden: true
29   KeystoneRegion:
30     type: string
31     default: 'regionOne'
32     description: Keystone region for endpoint
33   Ec2ApiExternalNetwork:
34     type: string
35     default: ''
36     description: Name of the external network, which is used to connect VPCs to
37                  Internet and to allocate Elastic IPs
38   NovaDefaultFloatingPool:
39     default: 'public'
40     description: Default pool for floating IP addresses
41     type: string
42   MonitoringSubscriptionEc2Api:
43     default: 'overcloud-ec2-api'
44     type: string
45   Ec2ApiLoggingSource:
46     type: json
47     default:
48       tag: openstack.ec2.api
49       path: /var/log/ec2api/ec2api.log
50   EnablePackageInstall:
51     default: 'false'
52     description: Set to true to enable package installation via Puppet
53     type: boolean
54   Ec2ApiPolicies:
55     description: |
56       A hash of policies to configure for EC2-API.
57       e.g. { ec2api-context_is_admin: { key: context_is_admin, value: 'role:admin' } }
58     default: {}
59     type: json
60
61
62 conditions:
63   nova_workers_zero: {equals : [{get_param: Ec2ApiWorkers}, 0]}
64   external_network_unset: {equals : [{get_param: Ec2ApiExternalNetwork}, '']}
65
66 outputs:
67   role_data:
68     description: Role data for the EC2-API service.
69     value:
70       service_name: ec2_api
71       monitoring_subscription: {get_param: MonitoringSubscriptionEc2Api}
72       logging_source: {get_param: Ec2ApiLoggingSource}
73       logging_groups:
74         - nova
75       config_settings:
76         map_merge:
77         - tripleo.ec2_api.firewall_rules:
78             '113 ec2_api':
79               dport:
80                 - 8788
81                 - 13788
82           ec2api::keystone::authtoken::project_name: 'service'
83           ec2api::keystone::authtoken::password: {get_param: Ec2ApiPassword}
84           ec2api::keystone::authtoken::auth_uri: {get_param: [EndpointMap, KeystoneInternal, uri] }
85           ec2api::keystone::authtoken::auth_url: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix]}
86           ec2api::policy::policies: {get_param: Ec2ApiPolicies}
87           ec2api::api::enabled: true
88           ec2api::package_manage: {get_param: EnablePackageInstall}
89           ec2api::api::ec2api_listen:
90             str_replace:
91               template:
92                 "%{hiera('fqdn_$NETWORK')}"
93               params:
94                 $NETWORK: {get_param: [ServiceNetMap, Ec2ApiNetwork]}
95           ec2api::metadata::metadata_listen:
96             str_replace:
97               template:
98                 "%{hiera('fqdn_$NETWORK')}"
99               params:
100                 $NETWORK: {get_param: [ServiceNetMap, Ec2ApiMetadataNetwork]}
101           ec2api::db::database_connection:
102             make_url:
103               scheme: {get_param: [EndpointMap, MysqlInternal, protocol]}
104               username: ec2_api
105               password: {get_param: Ec2ApiPassword}
106               host: {get_param: [EndpointMap, MysqlInternal, host]}
107               path: /ec2_api
108               query:
109                 read_default_file: /etc/my.cnf.d/tripleo.cnf
110                 read_default_group: tripleo
111           ec2api::api::keystone_ec2_tokens_url:
112             list_join:
113               - ''
114               - - {get_param: [EndpointMap, KeystoneV3Internal, uri]}
115                 - '/ec2tokens'
116         -
117           if:
118           - nova_workers_zero
119           - {}
120           - ec2api::api::ec2api_workers: {get_param: Ec2ApiWorkers}
121             ec2api::metadata::metadata_workers: {get_param: Ec2ApiWorkers}
122         -
123           if:
124           - external_network_unset
125           - ec2api::api::external_network: {get_param: NovaDefaultFloatingPool}
126           - ec2api::api::external_network: {get_param: Ec2ApiExternalNetwork}
127       step_config: |
128         include tripleo::profile::base::nova::ec2api
129       service_config_settings:
130         keystone:
131           ec2api::keystone::auth::tenant: 'service'
132           ec2api::keystone::auth::public_url: {get_param: [EndpointMap, Ec2ApiPublic, uri]}
133           ec2api::keystone::auth::internal_url: {get_param: [EndpointMap, Ec2ApiInternal, uri]}
134           ec2api::keystone::auth::admin_url: {get_param: [EndpointMap, Ec2ApiAdmin, uri]}
135           ec2api::keystone::auth::password: {get_param: Ec2ApiPassword}
136           ec2api::keystone::auth::region: {get_param: KeystoneRegion}
137         mysql:
138           ec2api::db::mysql::password: {get_param: Ec2ApiPassword}
139           ec2api::db::mysql::user: ec2_api
140           ec2api::db::mysql::host: {get_param: [EndpointMap, MysqlInternal, host_nobrackets]}
141           ec2api::db::mysql::dbname: ec2_api
142           ec2api::db::mysql::allowed_hosts:
143             - '%'
144             - "%{hiera('mysql_bind_host')}"
145       upgrade_tasks:
146         - name: Check if ec2-api is deployed
147           command: systemctl is-enabled openstack-ec2-api
148           tags: common
149           ignore_errors: True
150           register: ec2_api_enabled
151         - name: "PreUpgrade step0,validation: Check if openstack-ec2-api is running"
152           shell: >
153             /usr/bin/systemctl show 'openstack-ec2-api' --property ActiveState |
154             grep '\bactive\b'
155           when: ec2_api_enabled.rc == 0
156           tags: step0,validation
157         - name: Stop openstack-ec2-api service
158           tags: step1
159           when: ec2_api_enabled.rc == 0
160           service: name=openstack-ec2-api state=stopped
161         - name: Install openstack-ec2-api package if it was disabled
162           tags: step3
163           yum: name=openstack-ec2-api state=latest
164           when: ec2_api_enabled.rc != 0
165