diff --git a/changelogs/fragments/505-add-from-yaml-all-example.yml b/changelogs/fragments/505-add-from-yaml-all-example.yml new file mode 100644 index 00000000..12773ccc --- /dev/null +++ b/changelogs/fragments/505-add-from-yaml-all-example.yml @@ -0,0 +1,3 @@ +--- +trivial: + - add example usage for from_yaml_all (https://github.com/ansible-collections/kubernetes.core/pull/505). diff --git a/plugins/modules/k8s.py b/plugins/modules/k8s.py index 31e5099e..9b284d15 100644 --- a/plugins/modules/k8s.py +++ b/plugins/modules/k8s.py @@ -232,6 +232,14 @@ EXAMPLES = r""" 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