foreman_deployments 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/LICENSE +619 -0
- data/README.md +52 -0
- data/Rakefile +30 -0
- data/app/controllers/foreman_deployments/api/v2/base_controller.rb +25 -0
- data/app/controllers/foreman_deployments/api/v2/deployments_controller.rb +102 -0
- data/app/controllers/foreman_deployments/api/v2/stacks_controller.rb +52 -0
- data/app/controllers/foreman_deployments/create_resources_controller.rb +62 -0
- data/app/controllers/foreman_deployments/deployments_controller.rb +5 -0
- data/app/controllers/foreman_deployments/stacks_controller.rb +5 -0
- data/app/lib/foreman_deployments/base_dereference_visitor.rb +55 -0
- data/app/lib/foreman_deployments/config.rb +16 -0
- data/app/lib/foreman_deployments/config/array.rb +91 -0
- data/app/lib/foreman_deployments/config/configurator.rb +23 -0
- data/app/lib/foreman_deployments/config/hash.rb +81 -0
- data/app/lib/foreman_deployments/config/load_visitor.rb +23 -0
- data/app/lib/foreman_deployments/config/merge_visitor.rb +23 -0
- data/app/lib/foreman_deployments/config/save_visitor.rb +23 -0
- data/app/lib/foreman_deployments/inputs/base_input_definition.rb +39 -0
- data/app/lib/foreman_deployments/inputs/value.rb +25 -0
- data/app/lib/foreman_deployments/planner_visitor.rb +26 -0
- data/app/lib/foreman_deployments/registry.rb +67 -0
- data/app/lib/foreman_deployments/stack_definition.rb +37 -0
- data/app/lib/foreman_deployments/stack_parser.rb +121 -0
- data/app/lib/foreman_deployments/task_reference.rb +48 -0
- data/app/lib/foreman_deployments/tasks/base_action.rb +6 -0
- data/app/lib/foreman_deployments/tasks/base_definition.rb +72 -0
- data/app/lib/foreman_deployments/tasks/creation_task_definition.rb +68 -0
- data/app/lib/foreman_deployments/tasks/host_creation_task_definition.rb +44 -0
- data/app/lib/foreman_deployments/tasks/search_task_definition.rb +55 -0
- data/app/lib/foreman_deployments/tasks/stack_deploy_action.rb +10 -0
- data/app/lib/foreman_deployments/tasks/wait_until_built_task_definition.rb +65 -0
- data/app/lib/foreman_deployments/validation/dereference_visitor.rb +18 -0
- data/app/lib/foreman_deployments/validation/remove_ids_visitor.rb +59 -0
- data/app/lib/foreman_deployments/validation/validation_error.rb +12 -0
- data/app/lib/foreman_deployments/validation/validation_result.rb +26 -0
- data/app/lib/foreman_deployments/validation/validation_visitor.rb +20 -0
- data/app/lib/foreman_deployments/validation/validator.rb +29 -0
- data/app/models/foreman_deployments/concerns/belongs_to_single_taxonomy.rb +42 -0
- data/app/models/foreman_deployments/concerns/belongs_to_stack_taxonomy.rb +24 -0
- data/app/models/foreman_deployments/configuration.rb +26 -0
- data/app/models/foreman_deployments/deployment.rb +57 -0
- data/app/models/foreman_deployments/resource_models/create_resource.rb +18 -0
- data/app/models/foreman_deployments/stack.rb +20 -0
- data/app/views/foreman_deployments/api/v2/deployments/base.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/create.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/index.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/main.json.rabl +5 -0
- data/app/views/foreman_deployments/api/v2/deployments/merge_configuration.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/replace_configuration.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/run.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/deployments/show.json.rabl +11 -0
- data/app/views/foreman_deployments/api/v2/deployments/update.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/stacks/base.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/stacks/create.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/stacks/index.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/stacks/main.json.rabl +3 -0
- data/app/views/foreman_deployments/api/v2/stacks/show.json.rabl +7 -0
- data/app/views/foreman_deployments/api/v2/stacks/update.json.rabl +3 -0
- data/app/views/foreman_deployments/create_resources/new.html.erb +6 -0
- data/config/routes.rb +41 -0
- data/db/migrate/20150623140612_create_stacks.rb +10 -0
- data/db/migrate/20150814092932_create_deployment.rb +20 -0
- data/db/migrate/20150916133305_add_task_to_deployments.rb +5 -0
- data/db/migrate/20150917130618_add_taxonomy_to_deployments.rb +8 -0
- data/db/seeds.d/03-permissions.rb +14 -0
- data/doc/deployment_process.md +112 -0
- data/doc/design/capsule_stack.puml +51 -0
- data/doc/design/complete_stack.puml +17 -0
- data/doc/design/config_resource_overview.puml +15 -0
- data/doc/design/design.md +230 -0
- data/doc/design/diagrams/capsule_stack.png +0 -0
- data/doc/design/diagrams/capsule_stack.svg +1 -0
- data/doc/design/diagrams/complete_stack.png +0 -0
- data/doc/design/diagrams/complete_stack.svg +1 -0
- data/doc/design/diagrams/config_resource_overview.png +0 -0
- data/doc/design/diagrams/config_resource_overview.svg +1 -0
- data/doc/design/diagrams/ordered_resource_overview.png +0 -0
- data/doc/design/diagrams/ordered_resource_overview.svg +1 -0
- data/doc/design/diagrams/overview.png +0 -0
- data/doc/design/diagrams/overview.svg +1 -0
- data/doc/design/diagrams/overview_class.png +0 -0
- data/doc/design/diagrams/overview_class.svg +1 -0
- data/doc/design/diagrams/sat_stack.png +0 -0
- data/doc/design/diagrams/sat_stack.svg +1 -0
- data/doc/design/diagrams/solr_usecase.png +0 -0
- data/doc/design/diagrams/solr_usecase.svg +1 -0
- data/doc/design/examples.md +192 -0
- data/doc/design/generate-diagrams.sh +7 -0
- data/doc/design/implementation.md +128 -0
- data/doc/design/ordered_resource_overview.puml +15 -0
- data/doc/design/overview.puml +42 -0
- data/doc/design/overview_class.puml +64 -0
- data/doc/design/resources.md +134 -0
- data/doc/design/sat_stack.puml +37 -0
- data/doc/design/shared.puml +171 -0
- data/doc/design/solr_usecase.puml +189 -0
- data/doc/design/tasks.md +74 -0
- data/doc/design/user_interfaces.md +189 -0
- data/doc/introduction.md +84 -0
- data/doc/writing_stacks.md +102 -0
- data/lib/foreman_deployments.rb +7 -0
- data/lib/foreman_deployments/engine.rb +94 -0
- data/lib/foreman_deployments/monkey_patches.rb +9 -0
- data/lib/foreman_deployments/version.rb +3 -0
- data/lib/tasks/foreman_deployments_tasks.rake +22 -0
- data/locale/Makefile +62 -0
- data/test/factories/foreman_deployments.rb +70 -0
- data/test/functional/api/v2/deployments_controller_test.rb +318 -0
- data/test/functional/api/v2/stacks_controller_test.rb +140 -0
- data/test/test_plugin_helper.rb +14 -0
- data/test/unit/lib/config/array_test.rb +217 -0
- data/test/unit/lib/config/configurator_test.rb +66 -0
- data/test/unit/lib/config/hash_test.rb +178 -0
- data/test/unit/lib/inputs/value_test.rb +47 -0
- data/test/unit/lib/registry_test.rb +117 -0
- data/test/unit/lib/stack_definition_test.rb +54 -0
- data/test/unit/lib/stack_parser_test.rb +129 -0
- data/test/unit/lib/task_reference_test.rb +63 -0
- data/test/unit/lib/tasks/base_definition_test.rb +137 -0
- data/test/unit/lib/tasks/creation_task_definition_test.rb +57 -0
- data/test/unit/lib/tasks/host_creation_task_definition_test.rb +10 -0
- data/test/unit/lib/tasks/search_task_definition_test.rb +49 -0
- data/test/unit/lib/tasks/stack_deploy_action_test.rb +83 -0
- data/test/unit/lib/tasks/wait_until_built_task_definition_test.rb +71 -0
- data/test/unit/lib/validation/dereference_visitor_test.rb +48 -0
- data/test/unit/lib/validation/remove_ids_visitor_test.rb +90 -0
- data/test/unit/lib/validation/validation_result_test.rb +40 -0
- data/test/unit/lib/validation/validation_visitor_test.rb +67 -0
- data/test/unit/model/configuration_test.rb +88 -0
- data/test/unit/model/deployment_test.rb +159 -0
- data/test/unit/model/stack_test.rb +33 -0
- metadata +241 -0
data/doc/design/tasks.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## Tasks
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#### RunPuppetTask
|
|
5
|
+
Triggers a puppetrun on a host or group of them.
|
|
6
|
+
|
|
7
|
+
* inputs:
|
|
8
|
+
* host_id(s)
|
|
9
|
+
|
|
10
|
+
#### EnablePuppetTask
|
|
11
|
+
Enable/disable periodic puppet runs on a host or group of them.
|
|
12
|
+
|
|
13
|
+
* inputs:
|
|
14
|
+
* host_id(s)
|
|
15
|
+
* enable (flag saying whether to enable or disable puppet)
|
|
16
|
+
|
|
17
|
+
#### ProvisionHostTask
|
|
18
|
+
Starts provisioning of a host or group of them.
|
|
19
|
+
|
|
20
|
+
* inputs:
|
|
21
|
+
* host_id(s)
|
|
22
|
+
|
|
23
|
+
#### ParameterUpdateTask
|
|
24
|
+
Updates a parameter on a hostgroup, host or group of them.
|
|
25
|
+
|
|
26
|
+
* inputs:
|
|
27
|
+
* parameter
|
|
28
|
+
* host_id(s)
|
|
29
|
+
* hostgroup_id(s)
|
|
30
|
+
|
|
31
|
+
#### RemoteExecutionTask
|
|
32
|
+
Execute custom code on a host or group of them.
|
|
33
|
+
|
|
34
|
+
* inputs:
|
|
35
|
+
* execution provider
|
|
36
|
+
* host_id(s)
|
|
37
|
+
|
|
38
|
+
#### SelectResourceTask
|
|
39
|
+
Select an existing resource from the Foreman.
|
|
40
|
+
|
|
41
|
+
* limited only to resources that have scoped search defined on them
|
|
42
|
+
* allows for defining query that limits the selection
|
|
43
|
+
* inputs:
|
|
44
|
+
* preselected resource id (can be used as default)
|
|
45
|
+
* output:
|
|
46
|
+
* the resource's id
|
|
47
|
+
|
|
48
|
+
#### CreateResourceTask
|
|
49
|
+
Creates a Foreman resource. Eventually it should be possible to create any resource inside Foreman.
|
|
50
|
+
|
|
51
|
+
We're currently evaluating the posibilities of re-using the existing UI partials for this task's configuration.
|
|
52
|
+
|
|
53
|
+
It will be possible to specify a range of how many resources of such type should be created. This is useful mainly for hosts
|
|
54
|
+
where one sometimes wants to create multiple hosts with the same configuration. In such case, the host name will be configured
|
|
55
|
+
to a template "#{name}-#{index}" by default.
|
|
56
|
+
|
|
57
|
+
* inputs:
|
|
58
|
+
* attributes for the resource
|
|
59
|
+
* range for the number of resources (mainly for hosts)
|
|
60
|
+
* output:
|
|
61
|
+
* the resource's id
|
|
62
|
+
|
|
63
|
+
Alternatively we can create a dedicated task for each resource type.
|
|
64
|
+
|
|
65
|
+
#### SelectOrCreateResourceTask
|
|
66
|
+
Shows configuration UI of the select task but allows for switching into creation mode
|
|
67
|
+
and adding new resource.
|
|
68
|
+
|
|
69
|
+
* encapsulates `SelectResourceTask` and `CreateResourceTask` into one
|
|
70
|
+
* inputs:
|
|
71
|
+
* select task (and it's configuration)
|
|
72
|
+
* create task (and it's configuration)
|
|
73
|
+
* output:
|
|
74
|
+
* the resource's id
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# User interfaces
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## 3 Ways of creating a deployment:
|
|
5
|
+
- by deploying a stack
|
|
6
|
+
- every stack is deployable
|
|
7
|
+
- the UI path: `stack list` → select stack & click `[Deploy]` → `deployment creation form` → click `[Configure]` → `deployment config form` → click `[Deploy]` → `deployment info`
|
|
8
|
+
- by deploying a configuraion
|
|
9
|
+
- an existing configuration is cloned and used for the new deployment (not all values are clonable, e.g. bare metal hosts)
|
|
10
|
+
- the path: `stack's config list` → select config & click `[Deploy]` → `deployment creation form` → click `[Configure]` → `deployment config form` with cloned values, fields that are not clonable are blank → click `[Deploy]` → `deployment info`
|
|
11
|
+
- by cloning an existing deployment
|
|
12
|
+
- technically the same as deploying a configuration, different only from the user's perspective
|
|
13
|
+
- the path: `deployment list` → select config & click `[Clone]` → `deployment creation form` → `[Configure]` → `deployment config form` with cloned values, fields that are not clonable are blank → `[Deploy]` → `deployment info`
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## UI pages
|
|
17
|
+
|
|
18
|
+
### List of stacks
|
|
19
|
+
- shows all stacks imported into foreman
|
|
20
|
+
- the list contains
|
|
21
|
+
- stack name
|
|
22
|
+
- number of existing deployments (link to list of the deployments filtered by search)
|
|
23
|
+
- row action buttons:
|
|
24
|
+
- `deploy` - leads to the deployment creation form
|
|
25
|
+
- `configure` - leads to config form, result is saved as a separate config for future cloning
|
|
26
|
+
- `configurations` - leads to the list of existing configurations
|
|
27
|
+
- `export`
|
|
28
|
+
- `delete` - disabled if it's already deployed
|
|
29
|
+
- top buttons:
|
|
30
|
+
- `import stack`
|
|
31
|
+
|
|
32
|
+
### Stack info
|
|
33
|
+
- shows info about used tasks, required puppet classes, subnets etc.
|
|
34
|
+
- top buttons:
|
|
35
|
+
- `deploy` - leads to the deployment creation form
|
|
36
|
+
- `configure` - leads to config form, result is saved as a separate config for future cloning
|
|
37
|
+
- `export`
|
|
38
|
+
- `delete` - disabled if it's already deployed
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### List of stack configurations
|
|
42
|
+
- shows all stack configurations
|
|
43
|
+
- the list contains
|
|
44
|
+
- name of the configuration
|
|
45
|
+
- what stack is that for
|
|
46
|
+
- what deployment was that for (only if it's not a saved config template)
|
|
47
|
+
- row action buttons:
|
|
48
|
+
- `deploy` - leads to the deployment creation form
|
|
49
|
+
- `delete` - only for configurations that have no deployment assigned
|
|
50
|
+
- `details` - list of all configuration values
|
|
51
|
+
- top buttons:
|
|
52
|
+
- NONE
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### List of existing deployments
|
|
56
|
+
- shows all created deplyments
|
|
57
|
+
- the list contains
|
|
58
|
+
- name of the deployment
|
|
59
|
+
- phase of the deployment (created/configured/deploying/deployed)
|
|
60
|
+
- number of hosts in the stack (link to list of the hosts filtered by search)
|
|
61
|
+
- row action buttons:
|
|
62
|
+
- `configure` - leads to the deployment creation form, shown only if the configuration is not finished yet
|
|
63
|
+
- `delete`
|
|
64
|
+
- top buttons:
|
|
65
|
+
- NONE
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Import stack form
|
|
69
|
+
- select file field
|
|
70
|
+
- below buttons:
|
|
71
|
+
- `cancel`
|
|
72
|
+
- `import` - successful import leads to the list of stacks
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Deployment creation form
|
|
76
|
+
- name for the deployment
|
|
77
|
+
- list of select boxes for abstract substacks (name, description from the ChildStackTask should be shown here to explain)
|
|
78
|
+
- select box for existing configuration (probably dependent on the combination of concrete substacks)
|
|
79
|
+
- below buttons:
|
|
80
|
+
- `cancel`
|
|
81
|
+
- `create` - leads to config form
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Deployment configuration form
|
|
85
|
+
- displays field for configuration name (is prefilled with some meaningful value or hidden in case of deploying without preset config)
|
|
86
|
+
- shows configuration partials for tasks that need some users inputs
|
|
87
|
+
- parials are shown in the order from the stack definition
|
|
88
|
+
|
|
89
|
+
- below buttons:
|
|
90
|
+
- `save`
|
|
91
|
+
- `deploy`
|
|
92
|
+
- `cancel`
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Deployment info
|
|
96
|
+
- progressbar is shown, waits until all hosts are provisioned and configured.
|
|
97
|
+
- can show progress of the single actions
|
|
98
|
+
- link to dynflow console
|
|
99
|
+
- below buttons:
|
|
100
|
+
- `cancel`/`back`
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
## CLI interactions
|
|
104
|
+
Mimics the UI interactions.
|
|
105
|
+
|
|
106
|
+
List available stacks
|
|
107
|
+
```bash
|
|
108
|
+
hammer stack list
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Import a new stack from a file
|
|
112
|
+
```bash
|
|
113
|
+
hammer stack import --name "Web Server Stack" --file "web_server.json"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Json export of existing stacks
|
|
117
|
+
```bash
|
|
118
|
+
hammer stack export --name "Web Server Stack"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Get details about a stack
|
|
122
|
+
```bash
|
|
123
|
+
hammer stack info --name "Web Server Stack"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
List all deployments of a stack
|
|
127
|
+
```bash
|
|
128
|
+
hammer stack deployments --name "Web Server Stack"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
List saved configurations and deployments' configurations
|
|
132
|
+
```bash
|
|
133
|
+
hammer stack configurations --name "Web Server Stack"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
List all existing deployments, filterable by stacks
|
|
137
|
+
```bash
|
|
138
|
+
hammer deployment list [--stack "Web Server Stack"]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Create a deployment of a stack. Users can optionally pass a saved config
|
|
142
|
+
```bash
|
|
143
|
+
hammer deployment create --stack "Web Server Stack" --name "Web Server Instance" [--configuration "My saved config"]
|
|
144
|
+
```
|
|
145
|
+
Assignment of concrete stacks will be available in future
|
|
146
|
+
```bash
|
|
147
|
+
hammer deployment create --stack "Web Server Stack" --name "Web Server Instance" [--configuration "My saved config"] --stacks="db=mysql,gallery=phoca"
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Get details about a deployment. It shows state of the deployment and configuration values too
|
|
151
|
+
```bash
|
|
152
|
+
hammer deployment info --name "Web Server Instance"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Configure the deployment parameters. Values can be saved either all at once or one by one. There are multiple ways of implementing this
|
|
156
|
+
|
|
157
|
+
**TODO**: *solve how to send structured values like nics*
|
|
158
|
+
|
|
159
|
+
1) Mapping config to key-value pairs
|
|
160
|
+
```bash
|
|
161
|
+
hammer deployment configure --name "Web Server Instance" --values "db_passwd=xxx,db_user=webapp"
|
|
162
|
+
```
|
|
163
|
+
2) Always specify the task one configures as a full dot separated path
|
|
164
|
+
```bash
|
|
165
|
+
hammer deployment configure --name "Web Server Instance" --task "db" --values "count=1,compute_resource=libvirt"
|
|
166
|
+
```
|
|
167
|
+
```bash
|
|
168
|
+
hammer deployment configure --name "Web Server Instance" --task "db.nics" --values "count=1"
|
|
169
|
+
```
|
|
170
|
+
3) Always send a json
|
|
171
|
+
```bash
|
|
172
|
+
hammer deployment configure --name "Web Server Instance" --values "{'db': {'count': 1, 'nics': [ ... ]}}"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Start the deployment process
|
|
176
|
+
```bash
|
|
177
|
+
hammer deployment deploy --name "Web Server Instance"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Clone a deployment. Creates a deployment with the cloned configuration. Should notify user whether there are some blank values that need additional attention.
|
|
181
|
+
```bash
|
|
182
|
+
hammer deployment clone --name "Web Server Instance" --new-name "Second Web Server Instance"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Deploy the cloned deployment.
|
|
186
|
+
```bash
|
|
187
|
+
hammer deployment deploy --name "Second Web Server Instance"
|
|
188
|
+
```
|
|
189
|
+
|
data/doc/introduction.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Foreman deployments
|
|
2
|
+
|
|
3
|
+
Foreman deployments plugin allows for defining multi-host provisioning, configuration and orchestration.
|
|
4
|
+
There are three main entities accross the whole plugin: **stacks**, **tasks** and **deployments**.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Stack
|
|
8
|
+
|
|
9
|
+
*Stack* is an abstract representation of the multi-host infrastructure to be built. They are composed of multiple *tasks* dependent on each other and define
|
|
10
|
+
relationships between them. See the "Tasks" section below for the detailed definition of the term.
|
|
11
|
+
|
|
12
|
+
Same as majority of entities in the Foreman, stacks can be available to multiple organizations and locations.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Tasks
|
|
16
|
+
|
|
17
|
+
Tasks are the units a stack is composed of. Each task has defined input parameters and results that it produces. Result of one task can be used as an input
|
|
18
|
+
of another one, which enables for setting dependencies.
|
|
19
|
+
|
|
20
|
+
The stack definition gives a unique name for each of the task instances.
|
|
21
|
+
|
|
22
|
+
See the list of all [available tasks](writing_stacks.md) and their parameters.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Stack definition
|
|
26
|
+
|
|
27
|
+
The stack defines tasks to be used, their inputs and relationships. Task's input can be:
|
|
28
|
+
* hardcoded value
|
|
29
|
+
* input required form a user in the configuration phase, see list of [available inputs](writing_stacks.md#available-inputs)
|
|
30
|
+
* reference to a value from another task
|
|
31
|
+
* ignored (default value is used)
|
|
32
|
+
|
|
33
|
+
Stacks are defined in yaml files.
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
# Following is an example stack definition that creates a new host within a hostgroup
|
|
37
|
+
|
|
38
|
+
# name of the task
|
|
39
|
+
# | task type
|
|
40
|
+
# | |
|
|
41
|
+
# ˇ ˇ
|
|
42
|
+
test_hostgroup: !task:FindResource
|
|
43
|
+
class: test_hostgroup # <-- task parameters
|
|
44
|
+
search_term: 'name = Test'
|
|
45
|
+
|
|
46
|
+
test_host: !task:CreateResource
|
|
47
|
+
class: Host
|
|
48
|
+
params:
|
|
49
|
+
hostgroup_id: !reference # <-- reference to another task's output
|
|
50
|
+
object: test_hostgroup
|
|
51
|
+
field: result.ids.first
|
|
52
|
+
compute_resource_id: 1
|
|
53
|
+
compute_profile_id: 1
|
|
54
|
+
compute_attributes:
|
|
55
|
+
start: '1'
|
|
56
|
+
name: !input:Value # <-- input entry point
|
|
57
|
+
default: deployment-test
|
|
58
|
+
description: Name for the test host
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### Stack's lifecycle
|
|
62
|
+
|
|
63
|
+
1. Stacks are created as yaml descriptions of the infrastructure. Such yaml file is imported into the Foreman either via API.
|
|
64
|
+
1. Modification of imported stacks are allowed up to the point where a first deployment of the stack is created.
|
|
65
|
+
1. Stacks can't be deleted in the current release but this feature will be comming soon.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Deployment
|
|
69
|
+
|
|
70
|
+
A *deployment* is a result of performing the instructions in a *stack*. It is an instance of a *stack*.
|
|
71
|
+
|
|
72
|
+
Similar to hosts, deployments belong to a single organization and location.
|
|
73
|
+
|
|
74
|
+
#### Deployment's lifecycle
|
|
75
|
+
|
|
76
|
+
1. A deployment is created as a named instance of a stack.
|
|
77
|
+
2. Before the deployment can be deployed, it can be configured. Users fill missing parameters in this step.
|
|
78
|
+
3. A configured deployment can be deployed onto the Foreman's infrastructure. This step is handled by dynflow.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## Example
|
|
82
|
+
|
|
83
|
+
A more detailed example is covered in [How to create and deploy a stack](deployment_process.md) section
|
|
84
|
+
of our documentation.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# How to write a stack
|
|
2
|
+
|
|
3
|
+
Stacks are defined in [yaml](http://yaml.org) format. Foreman deployments provide set of custom
|
|
4
|
+
yaml tags for specifying tasks, references between them and inputs.
|
|
5
|
+
|
|
6
|
+
Stack definition can contain only `task name` -> `task definition` pairs.
|
|
7
|
+
Inner structure of the task definition varies according to the task type.
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
uniqe_task_name: !task:TaskType
|
|
11
|
+
parameters:
|
|
12
|
+
some: values
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Available tasks
|
|
16
|
+
|
|
17
|
+
### CreateResource
|
|
18
|
+
Creates a resource in the Foreman including hosts.
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
example: !task:CreateResource
|
|
22
|
+
class: Host # The foreman resource to create
|
|
23
|
+
params: # Hash of parameters for the resource
|
|
24
|
+
# ...
|
|
25
|
+
```
|
|
26
|
+
**Output:**
|
|
27
|
+
```yaml
|
|
28
|
+
object:
|
|
29
|
+
# hash of the host's parameters including facts
|
|
30
|
+
# ...
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### FindResource
|
|
34
|
+
Find resources by the scoped search filter.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
example: !task:FindResource
|
|
38
|
+
class: Hostgroup # The foreman resource to search for
|
|
39
|
+
search_term: 'name = Test' # Scoped search filter, same syntax as in the UI Search field
|
|
40
|
+
```
|
|
41
|
+
**Output:**
|
|
42
|
+
```yaml
|
|
43
|
+
results:
|
|
44
|
+
# array of the found resources
|
|
45
|
+
# ...
|
|
46
|
+
result:
|
|
47
|
+
ids: # array of resources' ids
|
|
48
|
+
- 1
|
|
49
|
+
- 2
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### WaitUntilBuilt
|
|
53
|
+
Waits until a host is provisioned and reports successfully.
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
example: !task:WaitUntilBuilt
|
|
57
|
+
timout: 3600 # In seconds, default is 3 hours
|
|
58
|
+
host_id: !reference # Id fo a host to wait for,
|
|
59
|
+
object: host_x # usually passed as a reference to a host creation task
|
|
60
|
+
field: object.id
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
**Output:**
|
|
64
|
+
```yaml
|
|
65
|
+
task:
|
|
66
|
+
build: true/false # has the host been built yet?
|
|
67
|
+
object:
|
|
68
|
+
# hash of the host's parameters including facts
|
|
69
|
+
# ...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Available inputs
|
|
73
|
+
|
|
74
|
+
Currently there's only one input type.
|
|
75
|
+
More input types including some validation capabilities will be implemented in future.
|
|
76
|
+
|
|
77
|
+
### Value
|
|
78
|
+
Marks the parameter as an input entry point for users. It allows to
|
|
79
|
+
provide a description and a default value.
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
example: !task:SomeTask
|
|
83
|
+
name: !input:Value
|
|
84
|
+
default: test-deployment-foreman
|
|
85
|
+
description: Name for the foreman host
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Ordering actions without direct dependency
|
|
89
|
+
|
|
90
|
+
Even though dynflow engine calculates the task dependencies automatically,
|
|
91
|
+
there might be cases when a stack writer needs to put hard order between two
|
|
92
|
+
tasks that don't directly depend on each other. In such situations a reserved
|
|
93
|
+
field `after` can be used:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
FirstTask: !task:SomeTask
|
|
97
|
+
|
|
98
|
+
SecondTask: !task:SomeTask
|
|
99
|
+
after: !reference
|
|
100
|
+
object: 'FirstTask'
|
|
101
|
+
field: 'result'
|
|
102
|
+
```
|