<p>My k8s.yaml inventory file is:</p>
<pre class="lang-yaml prettyprint-override"><code>plugin: k8s

connections:

- kubeconfig: '/Users/user1/Documents/Learning/ansible/kubeconfig.test.yaml'

context: 'user1@testeks.us-east-1.eksctl.io'
</code></pre>
<p>ansible playbook:</p>
<p>test_new.yml</p>
<pre class="lang-yaml prettyprint-override"><code>- hosts: localhost

tasks:

- name: Create a k8s namespace

k8s:

name: testing3

api_version: v1

kind: Namespace

state: present
</code></pre>
<p>Looks like the ansibleplaybook command is not picking up the inventory k8s.yaml.Also I am not sure why I am getting Warning invalid characters {'-' in group name warnings.</p>
<p>Please let me know if the above inventory file and ansible playbook files look good or are there anything I am missing?</p>
<pre class="lang-sh prettyprint-override"><code>ansible-playbook -vvvv -i k8s.yaml -vvv ./test_new.yml
No config file found; using defaults

setting up inventory plugins

host_list declined parsing /Users/user1/Documents/Learning/ansible/k8s.yaml as it did not pass its verify_file() method

script declined parsing /Users/user1/Documents/Learning/ansible/k8s.yaml as it did not pass its verify_file() method

Not replacing invalid character(s) &quot;{'-', '9'}&quot; in group name (909676E2B4F81625BF5994625D3353C9-yl4-us-east-1-eks-amazonaws-com)

[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

Not replacing invalid character(s) &quot;{'-'}&quot; in group name (namespace_add-ons)

Not replacing invalid character(s) &quot;{'-'}&quot; in group name (namespace_add-ons_pods)

Not replacing invalid character(s) &quot;{'.', '/', '-'}&quot; in group name (label_app.kubernetes.io/instance_aws-cluster-autoscaler)
</code></pre>

Rad4
<p>I'm not sure where you got that you need the Kubernetes parameters specified in your inventory file. If you look at the <a href="https://docs.ansible.com/ansible/latest/modules/k8s_module.html" rel="nofollow noreferrer">k8s module documentation</a> it says that <code>kubeconfig</code> and <code>context</code> are specified in the playbook or as environment variables.</p>
<p>Your <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html" rel="nofollow noreferrer">inventory</a> should look something like this:</p>
<pre class="lang-yaml prettyprint-override"><code>all:
  hosts:
    host.where.can.access.the.kubeapiserver.com:
</code></pre>
<p>Then your playbook:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: Create a k8s namespace
  k8s:
    name: testing3
    api_version: v1
    kind: Namespace
    state: present
    kubeconfig: '/Users/user1/Documents/Learning/ansible/kubeconfig.test.yaml' 👈 this can replaced by the K8S_AUTH_KUBECONFIG env variable
    context: 'user1@testeks.us-east-1.eksctl.io'  👈 this can replaced by the K8S_AUTH_CONTEXT env variable
</code></pre>
