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, 2019 in Ansible by Judith
3,533 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, 2019 by Haseeb

Related Questions In Ansible

0 votes
1 answer

Error saying "One or more undefined variables: 'ansible_facts' is undefined"

The command you've executed basically means run ...READ MORE

answered Jan 17, 2019 in Ansible by Karen
4,624 views
+1 vote
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP