@@ -147,79 +147,6 @@ trigger this Ansible logic when a custom resource changes. In the above
147
147
example, we want to map a role to a specific Kubernetes resource that the
148
148
operator will watch. This mapping is done in a file called `watches.yaml`.
149
149
150
- # ## Watches file
151
-
152
- The Operator expects a mapping file, which lists each GVK to watch and the
153
- corresponding path to an Ansible role or playbook, to be copied into the
154
- container at a predefined location : /opt/ansible/watches.yaml
155
-
156
- Dockerfile example :
157
- ` ` ` Dockerfile
158
- COPY watches.yaml /opt/ansible/watches.yaml
159
- ` ` `
160
-
161
- The Watches file format is yaml and is an array of objects. The object has
162
- mandatory fields :
163
-
164
- **version**: The version of the Custom Resource that you will be watching.
165
-
166
- **group**: The group of the Custom Resource that you will be watching.
167
-
168
- **kind**: The kind of the Custom Resource that you will be watching.
169
-
170
- **playbook**: This is the path to the playbook that you have added to the
171
- container. This playbook is expected to be simply a way to call roles. This
172
- field is mutually exclusive with the "role" field.
173
-
174
- **role**: This is the path to the role that you have added to the container.
175
- For example if your roles directory is at `/opt/ansible/roles/` and your role
176
- is named `busybox`, this value will be `/opt/ansible/roles/busybox`. This field
177
- is mutually exclusive with the "playbook" field.
178
-
179
- Example specifying a role :
180
-
181
- ` ` ` yaml
182
- ---
183
- - version: v1alpha1
184
- group: foo.example.com
185
- kind: Foo
186
- role: /opt/ansible/roles/Foo
187
- ` ` `
188
-
189
- # ### Using playbooks in watches.yaml
190
-
191
- By default, `operator-sdk new --type ansible` sets `watches.yaml` to execute a
192
- role directly on a resource event. This works well for new projects, but with a
193
- lot of Ansible code this can be hard to scale if we are putting everything
194
- inside of one role. Using a playbook allows the developer to have more
195
- flexibility in consuming other roles and enabling more customized deployments
196
- of their application. To do this, modify `watches.yaml` to use a playbook
197
- instead of the role :
198
- ` ` ` yaml
199
- ---
200
- - version: v1alpha1
201
- group: foo.example.com
202
- kind: Foo
203
- playbook: /opt/ansible/playbook.yml
204
- ` ` `
205
-
206
- Modify `tmp/build/Dockerfile` to put `playbook.yml` in `/opt/ansible` in the
207
- container in addition to the role (`/opt/ansible` is the `HOME` environment
208
- variable inside of the Ansible Operator base image) :
209
- ` ` ` Dockerfile
210
- FROM quay.io/water-hole/ansible-operator
211
-
212
- COPY roles/ ${HOME}/roles
213
- COPY playbook.yaml ${HOME}/playbook.yaml
214
- COPY watches.yaml ${HOME}/watches.yaml
215
- ` ` `
216
-
217
- Alternatively, to generate a skeleton project with the above changes, a
218
- developer can also do :
219
- ` ` ` bash
220
- $ operator-sdk new --type ansible --kind Foo --api-version foo.example.com/v1alpha1 foo-operator --generate-playbook
221
- ` ` `
222
-
223
150
# ## Custom Resource file
224
151
225
152
The Custom Resource file format is Kubernetes resource file. The object has
0 commit comments