Kubespray: Ansible: with_dict expects a dict

Created on 23 Jan 2020  路  11Comments  路  Source: kubernetes-sigs/kubespray

Environment:

  • Cloud provider or hardware configuration:
Ansible runs on hardware:
 - Intel i5-7400 (4) @ 3.500GHz
 - 8Gb RAM
Targets:
Scaleway, DEV1-S, 2 Cores/2Gb RAM
  • OS (printf "$(uname -srm)\n$(cat /etc/os-release)\n"):
Linux 5.4.12-arch1-1 x86_64
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux
  • Version of Ansible (ansible --version):
ansible 2.7.12
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/russia9/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.1 (default, Jan  8 2020, 23:09:20) [GCC 9.2.0]

Kubespray version (commit) (git rev-parse --short HEAD):
538f4dad

Network plugin used:
Calico

Copy of your inventory file:

all:
  hosts:
    node1:
      ansible_host: 51.15.193.138
      ip: 51.15.193.138
      access_ip: 51.15.193.138
      ansible_user: server
  children:
    kube-master:
      hosts:
        node1:
    kube-node:
      hosts:
        node1:
    etcd:
      hosts:
        node1:
    k8s-cluster:
      children:
        kube-master:
        kube-node:
    calico-rr:
      hosts: {}

Command used to invoke ansible:

ansible-playbook -i inventory/personal1/hosts.yml cluster.yml -b -v \
  --private-key=~/.ssh/id_ecdsa

Output of ansible run:
https://gist.github.com/Russia9/87726e1bcf550c34fd96abe6ae3c2d96

Anything else do we need to know:

When I try to run ansible to create a cluster, I get a with_dict expects a dict error.

kinbug lifecyclrotten

Most helpful comment

something something jinja2

try adding this to ansible.cfg:

[defaults]
jinja2_native=True

All 11 comments

Hi, seems there are troubles with python version on this task. Maybe duplicate of #5392 ?

Could you test with Python 3.5.8 and let us know ?

Getting this too. python 3.8 on host (Arch), 3.5.3 on CoreOS

something something jinja2

try adding this to ansible.cfg:

[defaults]
jinja2_native=True

something something jinja2

try adding this to ansible.cfg:

[defaults]
jinja2_native=True

Set ANSIBLE_JINJA2_NATIVE=True and then got following exception on:

- name: set fact for docker_version
  command: "docker version -f '{{ '{{' }}.Client.Version{{ '}}' }}'"
  register: installed_docker_version
  changed_when: false
Traceback (most recent call last):
  File "<stdin>", line 113, in <module>
  File "<stdin>", line 105, in _ansiballz_main
  File "<stdin>", line 48, in invoke_module
  File "/usr/lib64/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/lib64/python3.6/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 618, in _exec
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/tmp/ansible_command_payload_qk0rezjr/__main__.py", line 292, in <module>
  File "/tmp/ansible_command_payload_qk0rezjr/__main__.py", line 222, in main
  File "/usr/lib64/python3.6/shlex.py", line 305, in split
    return list(lex)
  File "/usr/lib64/python3.6/shlex.py", line 295, in __next__
    token = self.get_token()
  File "/usr/lib64/python3.6/shlex.py", line 105, in get_token
    raw = self.read_token()
  File "/usr/lib64/python3.6/shlex.py", line 187, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation

I just came across this problem, also on Arch with python 3.8. I created a virtual environment with Python 2.7, pip installed the requirements, and it worked.

I faced the same issue using Python 3.8. It's all right with Python 3.5.

I was using kubespray within alpine docker container. There is no bug after downgrading alpine to 3.10:

ansible 2.7.12
  config file = /opt/kubespray/ansible.cfg
  configured module search path = ['/opt/kubespray/library']
  ansible python module location = /usr/lib/python3.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.7.5 (default, Oct 17 2019, 12:25:15) [GCC 8.3.0]

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Was this page helpful?
0 / 5 - 0 ratings