Skip to content

Commit 85303a1

Browse files
fabianvfmhrivnak
authored andcommitted
Make migrate command look for playbook.yml instead of .yaml (#948)
* Make migrate command look for playbook.yml instead of .yaml * update documentation to match new scaffolding * playbook.yaml -> playbook.yml * Add note to migrate command
1 parent d55146f commit 85303a1

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

commands/operator-sdk/cmd/migrate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func migrateAnsible() {
6969
Watches: true,
7070
Roles: true,
7171
}
72-
_, err := os.Stat("playbook.yaml")
72+
_, err := os.Stat("playbook.yml")
7373
switch {
7474
case err == nil:
7575
dockerfile.Playbook = true
7676
case os.IsNotExist(err):
7777
log.Info("No playbook was found, so not including it in the new Dockerfile")
7878
default:
79-
log.Fatalf("Error trying to stat playbook.yaml: (%v)", err)
79+
log.Fatalf("Error trying to stat playbook.yml: (%v)", err)
8080
}
8181

8282
renameDockerfile()

doc/ansible/dev/developer_guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Modify `roles/Foo/defaults/main.yml` to set `state` to `present` by default.
7676
state: present
7777
```
7878

79-
Create an Ansible playbook `playbook.yaml` in the top-level directory which
79+
Create an Ansible playbook `playbook.yml` in the top-level directory which
8080
includes role `Foo`:
8181
```yaml
8282
---
@@ -87,7 +87,7 @@ includes role `Foo`:
8787

8888
Run the playbook:
8989
```bash
90-
$ ansible-playbook playbook.yaml
90+
$ ansible-playbook playbook.yml
9191
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
9292
9393

doc/ansible/user-guide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ An example Watches file:
106106
- version: v1alpha1
107107
group: bar.example.com
108108
kind: Bar
109-
playbook: /opt/ansible/playbook.yaml
109+
playbook: /opt/ansible/playbook.yml
110110

111111
# More complex example for our Baz kind
112112
# Here we will disable requeuing and be managing the CR status in the playbook
113113
- version: v1alpha1
114114
group: baz.example.com
115115
kind: Baz
116-
playbook: /opt/ansible/baz.yaml
116+
playbook: /opt/ansible/baz.yml
117117
reconcilePeriod: 0
118118
manageStatus: false
119119
```
@@ -149,7 +149,7 @@ should go.
149149
- version: v1alpha1
150150
group: cache.example.com
151151
kind: Memcached
152-
role: /opt/ansible/roles/Memcached
152+
role: /opt/ansible/roles/memcached
153153
```
154154

155155
**Playbook**
@@ -167,7 +167,7 @@ Playbook
167167
## Building the Memcached Ansible Role
168168

169169
The first thing to do is to modify the generated Ansible role under
170-
`roles/Memcached`. This Ansible Role controls the logic that is executed when a
170+
`roles/memcached`. This Ansible Role controls the logic that is executed when a
171171
resource is modified.
172172

173173
### Define the Memcached spec
@@ -183,7 +183,7 @@ It is recommended that you perform some type validation in Ansible on the
183183
variables to ensure that your application is receiving expected input.
184184

185185
First, set a default in case the user doesn't set the `spec` field by modifying
186-
`roles/Memcached/defaults/main.yml`:
186+
`roles/memcached/defaults/main.yml`:
187187
```yaml
188188
size: 1
189189
```
@@ -192,13 +192,13 @@ size: 1
192192

193193
Now that we have the spec defined, we can define what Ansible is actually
194194
executed on resource changes. Since this is an Ansible Role, the default
195-
behavior will be to execute the tasks in `roles/Memcached/tasks/main.yml`. We
195+
behavior will be to execute the tasks in `roles/memcached/tasks/main.yml`. We
196196
want Ansible to create a deployment if it does not exist which runs the
197197
`memcached:1.4.36-alpine` image. Ansible 2.5+ supports the [k8s Ansible
198198
Module](https://docs.ansible.com/ansible/2.6/modules/k8s_module.html) which we
199199
will leverage to control the deployment definition.
200200

201-
Modify `roles/Memcached/tasks/main.yml` to look like the following:
201+
Modify `roles/memcached/tasks/main.yml` to look like the following:
202202
```yaml
203203
---
204204
- name: start memcached

doc/sdk-cli-reference.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ Generating CSV manifest version 0.1.1
167167
Adds a main.go source file and any associated source files for an operator that
168168
is not of the "go" type.
169169

170+
**Note**: This command will look for playbook.yml in the project root, if you use the .yaml extension
171+
you will need to rename it before running migrate or manually add it to your Dockerfile.
172+
170173
### Example
171174

172175
```console

hack/tests/e2e-ansible-molecule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ remove_prereqs() {
2626
}
2727

2828
pushd "$GOTMP"
29-
operator-sdk new memcached-operator --api-version=ansible.example.com/v1alpha1 --kind=Memcached --type=ansible
29+
operator-sdk new memcached-operator --api-version=ansible.example.com/v1alpha1 --kind=Memcached --type=ansible --generate-playbook
3030
cp "$ROOTDIR/test/ansible-memcached/tasks.yml" memcached-operator/roles/memcached/tasks/main.yml
3131
cp "$ROOTDIR/test/ansible-memcached/defaults.yml" memcached-operator/roles/memcached/defaults/main.yml
3232
cp "$ROOTDIR/test/ansible-memcached/asserts.yml" memcached-operator/molecule/default/asserts.yml

pkg/scaffold/ansible/dockerfilehybrid.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
type DockerfileHybrid struct {
2626
input.Input
2727

28-
// Playbook - if true, include a COPY statement for playbook.yaml
28+
// Playbook - if true, include a COPY statement for playbook.yml
2929
Playbook bool
3030

3131
// Roles - if true, include a COPY statement for the roles directory
@@ -72,7 +72,7 @@ RUN /usr/local/bin/user_setup
7272
{{- if .Roles }}
7373
COPY roles/ ${HOME}/roles/{{ end }}
7474
{{- if .Playbook }}
75-
COPY playbook.yaml ${HOME}/playbook.yaml{{ end }}
75+
COPY playbook.yml ${HOME}/playbook.yml{{ end }}
7676
{{- if .Watches }}
7777
COPY watches.yaml ${HOME}/watches.yaml{{ end }}
7878

0 commit comments

Comments
 (0)