Yes, where you are defining "test" some of the items in that list are hash tables that don't have a value for "base", which is why you are getting that error.
Easiest would be to set it to empty string when it does not apply. However, it's a little weird that it says "str object", which seems to imply you have, probably in that "dirs" variable file, refined the variable "test" to a list of strings, as opposed to a list of hash elements. On Tue, Sep 9, 2014 at 7:12 PM, Patrick Ansible-ML < [email protected]> wrote: > Hi all, > > New to the list. Been playing with Ansible for a few hours and I could use > a hand in getting a task going. I've not figured out any of the YAML magic > so please excuse the undoubtedly spectacular errors :) > > Goal: create a task that installs a couple of directories in /home/patrick > and /root. > > --- > # file: roles/common/tasks/main.yml > > - name: dirs | Include vars > include_vars: main.yml > > - name: dirs | Create some directories > file: > dest: "{{ item.base }}/{{ item.usr }}/{{ item.dirs }}" > mode: 0750 > owner: "{{ item.usr }}" > group: "{{ item.usr }}" > state: directory > with_items: test > > --- > # file: roles/common/vars/main.yml > > test: > - usr: patrick > base: /home > - usr: root > base: / > - dirs: test1 > - dirs: test2 > > > When I run this with: > $ ansible-playbook -v -i stage site.yml > > I get: > TASK: [common | dirs | Create some directories] > ******************************* > fatal: [test.local] => One or more undefined variables: 'str object' has > no attribute 'base' > > I'm guessing that the issue is in vars/main.yml file but lots of Googling > and staring at Github/Galaxy examples did not reveal a solution. Can anyone > please enlighten me a bit? > > Thanks, > Patrick > > -- > 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 post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/ansible-project/540F8975.4090403%40puzzled.xs4all.nl. > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgx8pmaDrxoet%3DjrrbPdQVjRo9kv69kiFj2VF-DJ0azWSQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
