<p>I want to provision a cluster via successive resource application within a cluster.</p>

<p>At some point in time, I want to apply an <code>nginx</code> deployment, the one suited for the creation of <code>nginx</code> - based <a href="https://kubernetes.github.io/ingress-nginx/deploy/#prerequisite-generic-deployment-command" rel="nofollow noreferrer">ingresses</a>, so I want to run the following command in a shell:</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/mandatory.yaml
</code></pre>

<p>My question is how can I make this idempotent, i.e. not to fail when the resources exist.</p>

<p>Is the <code>k8s</code> <code>ansible</code> <a href="https://docs.ansible.com/ansible/latest/modules/k8s_module.html" rel="nofollow noreferrer">module</a> suited for this?</p>

<p><code>kubectl apply</code> won't throw an error if the resource already exists. It is suited for your need. <code>kubectl create</code> will throw error if resource exists. </p>
