Merge "Make CephValidationDelay/Retries default consistent"
[apex-tripleo-heat-templates.git] / extraconfig / pre_deploy / rhel-registration / rhel-registration.yaml
1 heat_template_version: pike
2
3 description: >
4   RHEL Registration and unregistration software deployments.
5
6 # Note extra parameters can be defined, then passed data via the
7 # environment parameter_defaults, without modifying the parent template
8 parameters:
9   server:
10     type: string
11   # To be defined via a local or global environment in parameter_defaults
12   rhel_reg_activation_key:
13     type: string
14   rhel_reg_auto_attach:
15     type: string
16   rhel_reg_base_url:
17     type: string
18   rhel_reg_environment:
19     type: string
20   rhel_reg_force:
21     type: string
22   rhel_reg_machine_name:
23     type: string
24   rhel_reg_org:
25     type: string
26   rhel_reg_password:
27     type: string
28   rhel_reg_pool_id:
29     type: string
30   rhel_reg_release:
31     type: string
32   rhel_reg_repos:
33     type: string
34   rhel_reg_sat_url:
35     type: string
36   rhel_reg_server_url:
37     type: string
38   rhel_reg_service_level:
39     type: string
40   rhel_reg_user:
41     type: string
42   rhel_reg_type:
43     type: string
44   rhel_reg_method:
45     type: string
46   rhel_reg_sat_repo:
47     type: string
48   rhel_reg_http_proxy_host:
49     type: string
50   rhel_reg_http_proxy_port:
51     type: string
52   rhel_reg_http_proxy_username:
53     type: string
54   rhel_reg_http_proxy_password:
55     type: string
56   UpdateOnRHELRegistration:
57     type: boolean
58     default: false
59     description: |
60       When enabled, the system will perform a yum update after performing the
61       RHEL Registration process.
62   deployment_actions:
63     default: ['CREATE', 'UPDATE']
64     type: comma_delimited_list
65     description: >
66       List of stack actions that will trigger any deployments in this
67       templates. The actions will be an empty list of the server is in the
68       toplevel DeploymentServerBlacklist parameter's value.
69
70 conditions:
71   deployment_actions_empty:
72     equals:
73       - {get_param: deployment_actions}
74       - []
75
76 resources:
77
78   RHELRegistration:
79     type: OS::Heat::SoftwareConfig
80     properties:
81       group: script
82       inputs:
83         - name: REG_ACTIVATION_KEY
84         - name: REG_AUTO_ATTACH
85         - name: REG_BASE_URL
86         - name: REG_ENVIRONMENT
87         - name: REG_FORCE
88         - name: REG_MACHINE_NAME
89         - name: REG_ORG
90         - name: REG_PASSWORD
91         - name: REG_POOL_ID
92         - name: REG_RELEASE
93         - name: REG_REPOS
94         - name: REG_SAT_URL
95         - name: REG_SERVER_URL
96         - name: REG_SERVICE_LEVEL
97         - name: REG_USER
98         - name: REG_TYPE
99         - name: REG_METHOD
100         - name: REG_SAT_REPO
101         - name: REG_HTTP_PROXY_HOST
102         - name: REG_HTTP_PROXY_PORT
103         - name: REG_HTTP_PROXY_USERNAME
104         - name: REG_HTTP_PROXY_PASSWORD
105       config: {get_file: scripts/rhel-registration}
106
107   RHELRegistrationDeployment:
108     type: OS::Heat::SoftwareDeployment
109     properties:
110       name: RHELRegistrationDeployment
111       server:  {get_param: server}
112       config: {get_resource: RHELRegistration}
113       actions: ['CREATE'] # Only do this on CREATE
114       input_values:
115         REG_ACTIVATION_KEY: {get_param: rhel_reg_activation_key}
116         REG_AUTO_ATTACH: {get_param: rhel_reg_auto_attach}
117         REG_BASE_URL: {get_param: rhel_reg_base_url}
118         REG_ENVIRONMENT: {get_param: rhel_reg_environment}
119         REG_FORCE: {get_param: rhel_reg_force}
120         REG_MACHINE_NAME: {get_param: rhel_reg_machine_name}
121         REG_ORG: {get_param: rhel_reg_org}
122         REG_PASSWORD: {get_param: rhel_reg_password}
123         REG_POOL_ID: {get_param: rhel_reg_pool_id}
124         REG_RELEASE: {get_param: rhel_reg_release}
125         REG_REPOS: {get_param: rhel_reg_repos}
126         REG_SAT_URL: {get_param: rhel_reg_sat_url}
127         REG_SERVER_URL: {get_param: rhel_reg_server_url}
128         REG_SERVICE_LEVEL: {get_param: rhel_reg_service_level}
129         REG_USER: {get_param: rhel_reg_user}
130         REG_TYPE: {get_param: rhel_reg_type}
131         REG_METHOD: {get_param: rhel_reg_method}
132         REG_SAT_REPO: {get_param: rhel_reg_sat_repo}
133         REG_HTTP_PROXY_HOST: {get_param: rhel_reg_http_proxy_host}
134         REG_HTTP_PROXY_PORT: {get_param: rhel_reg_http_proxy_port}
135         REG_HTTP_PROXY_USERNAME: {get_param: rhel_reg_http_proxy_username}
136         REG_HTTP_PROXY_PASSWORD: {get_param: rhel_reg_http_proxy_password}
137
138   RHELUnregistration:
139     type: OS::Heat::SoftwareConfig
140     properties:
141       group: script
142       config: {get_file: scripts/rhel-unregistration}
143       inputs:
144         - name: REG_METHOD
145
146   RHELUnregistrationDeployment:
147     type: OS::Heat::SoftwareDeployment
148     properties:
149       name: RHELUnregistrationDeployment
150       server:  {get_param: server}
151       config: {get_resource: RHELUnregistration}
152       actions:
153         if:
154           - deployment_actions_empty
155           - []
156           - ['DELETE'] # Only do this on DELETE
157       input_values:
158         REG_METHOD: {get_param: rhel_reg_method}
159
160   YumUpdateConfigurationAfterRHELRegistration:
161     type: OS::Heat::SoftwareConfig
162     properties:
163       group: script
164       config: |
165         #!/bin/bash
166         set -x
167         num_updates=$(yum list -q updates | wc -l)
168         if [ "$num_updates" -eq "0" ]; then
169            echo "No packages require updating"
170            exit 0
171         fi
172         full_command="yum -q -y update"
173         echo "Running: $full_command"
174         result=$($full_command)
175         return_code=$?
176         echo "$result"
177         echo "yum return code: $return_code"
178         exit $return_code
179
180   UpdateDeploymentAfterRHELRegistration:
181     type: OS::Heat::SoftwareDeployment
182     depends_on: RHELRegistrationDeployment
183     conditions:
184       update_requested: {get_param: UpdateOnRHELRegistration}
185     properties:
186       name: UpdateDeploymentAfterRHELRegistration
187       config: {get_resource: YumUpdateConfigurationAfterRHELRegistration}
188       server:  {get_param: server}
189       actions:
190         if:
191           - deployment_actions_empty
192           - []
193           - ['CREATE'] # Only do this on CREATE
194
195 outputs:
196   deploy_stdout:
197     description: Deployment reference, used to trigger puppet apply on changes
198     value: {get_attr: [RHELRegistrationDeployment, deploy_stdout]}
199