Skip to content

Commit

Permalink
Add example usage of from_yaml_all (#505)
Browse files Browse the repository at this point in the history
Add example usage of from_yaml_all

Depends-On: #513
SUMMARY
Sometimes one might want to use a single YAML file that contains multiple Kubernetes definitions. This PR updates the documentation to provide a simple example of how to accomplish that.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
k8s
ADDITIONAL INFORMATION
I have not tested this solution against other modules, simply because I did not have use-case for those.

Reviewed-by: Mike Graves <mgraves@redhat.com>
  • Loading branch information
badnetmask authored Sep 21, 2022
1 parent 5e48c69 commit 08596fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/505-add-from-yaml-all-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- add example usage for from_yaml_all (https://github.com/ansible-collections/kubernetes.core/pull/505).
8 changes: 8 additions & 0 deletions plugins/modules/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@
state: present
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
- name: >-
(Alternative) Read definition file from the Ansible controller file system.
In this case, the definition file contains multiple YAML documents, separated by ---.
If the definition file has been encrypted with Ansible Vault it will automatically be decrypted.
kubernetes.core.k8s:
state: present
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml_all }}"
- name: Read definition template file from the Ansible controller file system
kubernetes.core.k8s:
state: present
Expand Down

0 comments on commit 08596fd

Please sign in to comment.