I figured it out. I had the path to my kubeconfig set wrong and i was 
missing 'context' and namespace parameters. What finally worked:

- hosts: kube-master[0]
  become: no
  tasks:
    - name: Install simple app
      k8s:
        definition: '{{ item }}'
        kubeconfig: ~/.kube/config-dev
        context: dev
        namespace: default
        state: absent
      with_items: '{{ lookup("url", 
"https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml";, 
split_lines=False) | from_yaml_all | list }}'
      when: item is not none
      delegate_to: localhost



On Tuesday, February 4, 2020 at 11:50:56 PM UTC-5, Jason Gilfoil wrote:
>
> Hello,
>
> Trying to apply a yaml definition using the k8s module to my cluster. I've 
> never used this module before so i'm trying to work out if i'm just doing 
> something wrong or is this a bug?
>
> playbook:
>
> ---
>
> - hosts: kube-master[0]
>   become: no
>   tasks:
>     - name: Install simple app
>       k8s:
>         definition: "{{ lookup('file', 'redis-master-deployment.yaml') }}"
>         kubeconfig: .kube/config-dev
>       delegate_to: localhost
>
> redis-master-deployment.yaml comes from 
> https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml
>
> Error i'm getting:
>
> An exception occurred during task execution. To see the full traceback, 
> use -vvv. The error was: TypeError: argument of type 'NoneType' is not 
> iterable
> fatal: [core01-dev -> localhost]: FAILED! => changed=false
>   module_stderr: |-
>     Traceback (most recent call last):
>       File "<stdin>", line 114, in <module>
>       File "<stdin>", line 106, in _ansiballz_main
>       File "<stdin>", line 49, in invoke_module
>       File "/usr/lib/python3.5/imp.py", line 234, in load_module
>         return load_source(name, filename, file)
>       File "/usr/lib/python3.5/imp.py", line 170, in load_source
>         module = _exec(spec, sys.modules[name])
>       File "<frozen importlib._bootstrap>", line 626, in _exec
>       File "<frozen importlib._bootstrap_external>", line 665, in 
> exec_module
>       File "<frozen importlib._bootstrap>", line 222, in 
> _call_with_frames_removed
>       File "/tmp/ansible_k8s_payload__jlk6464/__main__.py", line 258, in 
> <module>
>       File "/tmp/ansible_k8s_payload__jlk6464/__main__.py", line 254, in 
> main
>       File 
> "/tmp/ansible_k8s_payload__jlk6464/ansible_k8s_payload.zip/ansible/module_utils/k8s/raw.py",
>  
> line 154, in execute_module
>       File 
> "/tmp/ansible_k8s_payload__jlk6464/ansible_k8s_payload.zip/ansible/module_utils/k8s/common.py",
>  
> line 180, in get_api_client
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 645, in load_kube_config
>         persist_config=persist_config)
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 613, in _get_kube_config_loader_for_yaml_file
>         **kwargs)
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 153, in __init__
>         self.set_active_context(active_context)
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 173, in set_active_context
>         context_name = self._config['current-context']
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 495, in __getitem__
>         v = self.safe_get(key)
>       File 
> "/home/vagrant/.local/lib/python3.5/site-packages/kubernetes/config/kube_config.py",
>  
> line 491, in safe_get
>         key in self.value):
>     TypeError: argument of type 'NoneType' is not iterable
>   module_stdout: ''
>   msg: |-
>     MODULE FAILURE
>     See stdout/stderr for the exact error
>   rc: 1
>
> Versions:
> vagrant@ansible:/vagrant$ ansible --version
> ansible 2.8.8
>   config file = /vagrant/ansible.cfg
>   configured module search path = ['/vagrant/library']
>   ansible python module location = 
> /home/vagrant/.local/lib/python3.5/site-packages/ansible
>   executable location = /home/vagrant/.local/bin/ansible
>   python version = 3.5.2 (default, Oct  8 2019, 13:06:37) [GCC 5.4.0 
> 20160609]
>
> vagrant@ansible:/vagrant$ python
> Python 3.5.2 (default, Oct  8 2019, 13:06:37)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import yaml
> >>> yaml.__version__
> '5.3'
> >>> import openshift
> >>> openshift.__version__
> '0.10.1'
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e776b418-889e-4594-becd-85a6c7eac17c%40googlegroups.com.

Reply via email to