Invalid characters were found in group names but not replaced ansible k8s
I'm not sure where you got that you need the Kubernetes parameters specified in your inventory file. If you look at the k8s module documentation it says that kubeconfig
and context
are specified in the playbook or as environment variables.
Your inventory should look something like this:
all: hosts: host.where.can.access.the.kubeapiserver.com:
Then your playbook:
- 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
Based on the formatting of your post, it looks like your inventory file contains improper syntax. It should look like this:
plugin: k8sconnections: - kubeconfig: '/Users/user1/Documents/Learning/ansible/kubeconfig.test.yaml' context: 'user1@testeks.us-east-1.eksctl.io'
Remember that spaces are important.
For deprecation warnings, be sure to read up on these issues:
https://github.com/ansible/ansible/issues/56930
https://github.com/kubernetes-sigs/kubespray/issues/4830
Usage of hyphens in inventory group names was deprecated in Ansible 2.8 due to Python parser errors when using dot syntax. Auto-transformation can be disabled by adding force_valid_group_names = never
to your Ansible config file. Similarly, deprecation warnings can be suppressed by adding deprecation_warnings = False
though this is not recommended.