Error: One or more undefined variables: 'unicode object' has no attribute 'repo'

0 votes

I have an Ansible role "db" with a simple task:

- name: Check repos
  apt_repository: repo="{{ item.repo }}" state={{ item.state }}
  with_items:
  - "{{ apt_repos }}"

In /defaults/mail.yml:

apt_repos:

   # Percona
 - { state: present, repo: 'deb http://repo.percona.com/apt wheezy main', keyserver: 'keyserver.ubuntu.com', key: '1C4CBDCDCD2EFD2A', needkey: True }
 - { state: present, repo: 'deb-src http://repo.percona.com/apt wheezy main', needkey: False }

When I try to run this ansible-playbook:

---
- hosts: test
  roles:
  - db

I see an error:

fatal: [10.10.10.10] => One or more undefined variables: 'unicode object' has no attribute 'repo'
FATAL: all hosts have already failed -- aborting
Mar 14 in Ansible by Judith
180 views

1 answer to this question.

0 votes

Hey change this in your role

with_items: apt_repos

By referencing it as - "{{ apt_repos }}" the extra - is turning it into a list of lists.

answered Mar 14 by Haseeb

Related Questions In Ansible

0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
112 views
0 votes
1 answer
0 votes
1 answer