Skip to content

Latest commit

 

History

History
194 lines (155 loc) · 6.51 KB

kubernetes.core.kustomize_lookup.rst

File metadata and controls

194 lines (155 loc) · 6.51 KB

kubernetes.core.kustomize

Build a set of kubernetes resources using a 'kustomization.yaml' file.

Version added: 2.2.0

  • Uses the kustomize or the kubectl tool.
  • Return the result of kustomize build or kubectl kustomize.

The below requirements are needed on the local Ansible controller node that executes this lookup.

  • python >= 3.6
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
opt_dirs
-
An optional list of directories to search for the executable in addition to PATH.

Note

  • If both kustomize and kubectl are part of the PATH, kustomize will be used by the plugin.
- 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) }}"

Common return values are documented here, the following are the fields unique to this lookup:

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'}}


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.