Debian Codegraph @

ansible_collections/kubernetes/core/docs/kubernetes.core.kustomize_lookup.rst

raw
1 .. _kubernetes.core.kustomize_lookup:
2
3
4 *************************
5 kubernetes.core.kustomize
6 *************************
7
8 **Build a set of kubernetes resources using a 'kustomization.yaml' file.**
9
10
11 Version added: 2.2.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - Uses the kustomize or the kubectl tool.
21 - Return the result of ``kustomize build`` or ``kubectl kustomize``.
22
23
24
25 Requirements
26 ------------
27 The below requirements are needed on the local Ansible controller node that executes this lookup.
28
29 - python >= 3.6
30
31
32 Parameters
33 ----------
34
35 .. raw:: html
36
37 <table border=0 cellpadding=0 class="documentation-table">
38 <tr>
39 <th colspan="1">Parameter</th>
40 <th>Choices/<font color="blue">Defaults</font></th>
41 <th>Configuration</th>
42 <th width="100%">Comments</th>
43 </tr>
44 <tr>
45 <td colspan="1">
46 <div class="ansibleOptionAnchor" id="parameter-"></div>
47 <b>binary_path</b>
48 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
49 <div style="font-size: small">
50 <span style="color: purple">-</span>
51 </div>
52 </td>
53 <td>
54 </td>
55 <td>
56 </td>
57 <td>
58 <div>The path of a kustomize or kubectl binary to use.</div>
59 </td>
60 </tr>
61 <tr>
62 <td colspan="1">
63 <div class="ansibleOptionAnchor" id="parameter-"></div>
64 <b>dir</b>
65 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
66 <div style="font-size: small">
67 <span style="color: purple">-</span>
68 </div>
69 </td>
70 <td>
71 <b>Default:</b><br/><div style="color: blue">"."</div>
72 </td>
73 <td>
74 </td>
75 <td>
76 <div>The directory path containing &#x27;kustomization.yaml&#x27;, or a git repository URL with a path suffix specifying same with respect to the repository root.</div>
77 <div>If omitted, &#x27;.&#x27; is assumed.</div>
78 </td>
79 </tr>
80 <tr>
81 <td colspan="1">
82 <div class="ansibleOptionAnchor" id="parameter-"></div>
83 <b>enable_helm</b>
84 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
85 <div style="font-size: small">
86 <span style="color: purple">-</span>
87 </div>
88 </td>
89 <td>
90 <b>Default:</b><br/><div style="color: blue">"False"</div>
91 </td>
92 <td>
93 </td>
94 <td>
95 <div>Enable the helm chart inflation generator</div>
96 </td>
97 </tr>
98 <tr>
99 <td colspan="1">
100 <div class="ansibleOptionAnchor" id="parameter-"></div>
101 <b>environment</b>
102 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
103 <div style="font-size: small">
104 <span style="color: purple">raw</span>
105 </div>
106 <div style="font-style: italic; font-size: small; color: darkgreen">added in 6.2.0</div>
107 </td>
108 <td>
109 <b>Default:</b><br/><div style="color: blue">{}</div>
110 </td>
111 <td>
112 </td>
113 <td>
114 <div>The environment variables to pass to the kustomize or kubectl command.</div>
115 <div>This can be a dictionary or a string in the format key=value, multiple pairs separated by space.</div>
116 </td>
117 </tr>
118 <tr>
119 <td colspan="1">
120 <div class="ansibleOptionAnchor" id="parameter-"></div>
121 <b>opt_dirs</b>
122 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
123 <div style="font-size: small">
124 <span style="color: purple">-</span>
125 </div>
126 </td>
127 <td>
128 </td>
129 <td>
130 </td>
131 <td>
132 <div>An optional list of directories to search for the executable in addition to PATH.</div>
133 </td>
134 </tr>
135 </table>
136 <br/>
137
138
139 Notes
140 -----
141
142 .. note::
143 - If both kustomize and kubectl are part of the PATH, kustomize will be used by the plugin.
144
145
146
147 Examples
148 --------
149
150 .. code-block:: yaml
151
152 - name: Run lookup using kustomize
153 ansible.builtin.set_fact:
154 resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kustomize') }}"
155
156 - name: Run lookup using kubectl kustomize
157 ansible.builtin.set_fact:
158 resources: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl') }}"
159
160 - name: Create kubernetes resources for lookup output
161 kubernetes.core.k8s:
162 definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization') }}"
163
164 - name: Create kubernetes resources for lookup output with `--enable-helm` set
165 kubernetes.core.k8s:
166 definition: "{{ lookup('kubernetes.core.kustomize', dir='/path/to/kustomization', enable_helm=True) }}"
167
168 - name: Create kubernetes resources for lookup output with environment variables in string format
169 kubernetes.core.k8s:
170 definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment='HTTP_PROXY=http://proxy.example.com:3128') }}"
171
172 - name: Create kubernetes resources for lookup output with environment variables in dict format
173 kubernetes.core.k8s:
174 definition: "{{ lookup('kubernetes.core.kustomize', binary_path='/path/to/kubectl', environment={'HTTP_PROXY': 'http://proxy.example.com:3128'}) }}"
175
176
177
178 Return Values
179 -------------
180 Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this lookup:
181
182 .. raw:: html
183
184 <table border=0 cellpadding=0 class="documentation-table">
185 <tr>
186 <th colspan="1">Key</th>
187 <th>Returned</th>
188 <th width="100%">Description</th>
189 </tr>
190 <tr>
191 <td colspan="1">
192 <div class="ansibleOptionAnchor" id="return-"></div>
193 <b>_list</b>
194 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
195 <div style="font-size: small">
196 <span style="color: purple">string</span>
197 </div>
198 </td>
199 <td></td>
200 <td>
201 <div>YAML string for the object definitions returned from the tool execution.</div>
202 <br/>
203 <div style="font-size: smaller"><b>Sample:</b></div>
204 <div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">{&#x27;kind&#x27;: &#x27;ConfigMap&#x27;, &#x27;apiVersion&#x27;: &#x27;v1&#x27;, &#x27;metadata&#x27;: {&#x27;name&#x27;: &#x27;my-config-map&#x27;, &#x27;namespace&#x27;: &#x27;default&#x27;}, &#x27;data&#x27;: {&#x27;key1&#x27;: &#x27;val1&#x27;}}</div>
205 </td>
206 </tr>
207 </table>
208 <br/><br/>
209
210
211 Status
212 ------
213
214
215 Authors
216 ~~~~~~~
217
218 - Aubin Bikouo (@abikouo)
219
220
221 .. hint::
222 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.