.. _kubernetes.core.kustomize_lookup: ************************* kubernetes.core.kustomize ************************* **Build a set of kubernetes resources using a 'kustomization.yaml' file.** Version added: 2.2.0 .. contents:: :local: :depth: 1 Synopsis -------- - Uses the kustomize or the kubectl tool. - Return the result of ``kustomize build`` or ``kubectl kustomize``. Requirements ------------ The below requirements are needed on the local Ansible controller node that executes this lookup. - python >= 3.6 Parameters ---------- .. raw:: html
Parameter Choices/Defaults Configuration Comments
binary_path
-
The path of a kustomize or kubectl binary to use.
dir
-
Default:
"."
The directory path containing 'kustomization.yaml', or a git repository URL with a path suffix specifying same with respect to the repository root.
If omitted, '.' is assumed.
enable_helm
-
Default:
"False"
Enable the helm chart inflation generator
environment
raw
added in 6.2.0
Default:
{}
The environment variables to pass to the kustomize or kubectl command.
This can be a dictionary or a string in the format key=value, multiple pairs separated by space.
opt_dirs
-
An optional list of directories to search for the executable in addition to PATH.

Notes ----- .. note:: - If both kustomize and kubectl are part of the PATH, kustomize will be used by the plugin. Examples -------- .. code-block:: yaml - name: Run lookup using kustomize ansible.builtin.set_fact: resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}" - name: Run lookup using kubectl kustomize ansible.builtin.set_fact: resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}" - name: Create kubernetes resources for lookup output kubernetes.core.k8s: definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}" - name: Create kubernetes resources for lookup output with `--enable-helm` set kubernetes.core.k8s: definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}" - name: Create kubernetes resources for lookup output with environment variables in string format kubernetes.core.k8s: definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}" - name: Create kubernetes resources for lookup output with environment variables in dict format kubernetes.core.k8s: definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}" Return Values ------------- Common return values are documented `here `_, the following are the fields unique to this lookup: .. raw:: html
Key Returned Description
_list
string
YAML string for the object definitions returned from the tool execution.

Sample:
{'kind': 'ConfigMap', 'apiVersion': 'v1', 'metadata': {'name': 'my-config-map', 'namespace': 'default'}, 'data': {'key1': 'val1'}}


Status ------ Authors ~~~~~~~ - Aubin Bikouo (@abikouo) .. hint:: Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.