1

I'm trying to deploy application with Ansible on my Kubernetes cluster. I tried to use this module kubernetes cluster module but when i try to execute my example playbook copied from documentation I'm getting:

 [WARNING]: Host file not found: /etc/ansible/hosts

 [WARNING]: provided hosts list is empty, only localhost is available

ERROR! 'kubernetes' is not a valid attribute for a Play

The error appears to have been in '/home/holo/enterpryze/sources/devops/orchiestration/environment-cloud/ansible-playbook/kube.yaml':
line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Create a kubernetes namespace
  ^ here

How to add this module to make my example config working?

user3069488
  • 159
  • 2
  • 3
  • 18
  • Where did you place your kubernetes module? Check please your modules path in ansible.cfg. It has to look like library = /etc/ansible/library:/etc/ansible/library/module1 – Anton Makovetsky Jun 02 '17 at 14:36

1 Answers1

1

There's evidently a syntax error.

not a valid attribute for a Play

you should put module calls under tasks section (mind the indentation):

- hosts: server
  tasks:
    - name: mytask
      kubernetes:
Konstantin Suvorov
  • 3,836
  • 1
  • 11
  • 13
  • Thank you, it helped but right now im getting: "skipping: no hosts matched" i dont have any inventory. In kubernetes i do not need servers hosts/ips it just need to run this task. How can i force to run it anyway? – user3069488 Jun 02 '17 at 15:26
  • I can't edit previous comment. I tried to add just localhost as inventory but than it is trying to connect via ssh to it (but it is not necessary it need to connect to kubernetes not host with this module). – user3069488 Jun 02 '17 at 15:34
  • for cloud modules you usually want to use `hosts: localhost`. – Konstantin Suvorov Jun 02 '17 at 15:35