kubernetes.core.kustomize lookup – Build a set of kubernetes resources using a ‘kustomization.yaml’ file.

Note

This lookup plugin is part of the kubernetes.core collection (version 2.3.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install kubernetes.core.

To use it in a playbook, specify: kubernetes.core.kustomize.

New in version 2.2.0: of kubernetes.core

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 controller node that executes this lookup.

  • python >= 3.6

Parameters

Parameter

Comments

binary_path

string

The path of a kustomize or kubectl binary to use.

dir

string

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.

Default: “.”

opt_dirs

string

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

- name: Run lookup using kustomize
  set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"

- name: Run lookup using kubectl kustomize
  set_fact:
    resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"

- name: Create kubernetes resources for lookup output
  k8s:
    definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"

Return Values

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

Key

Description

_list

string

YAML string for the object definitions returned from the tool execution.

Returned: success

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

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.