Sorry Michael, I will try to be more clear.

I am running Ansible 1.7.1 currently.

So my original site.yml is this:

$ cat site.yml.orig
---

- include: dept1-servers.yml
- include: dept2-servers.yml
- include: base-static-setup.yml

...which works fine.

The one producing the traceback is this:

$ cat site.yml.bad
---

- hosts: all
  tasks:
# Set up OS-specific groups
  - group_by: 
key=os-{{ansible_distribution}}-{{ansible_distribution_version}}

- hosts: "{{ distro | default('all') }}"
  include:
  - dept1-servers.yml
  - dept2-servers.yml
  - base-static-setup.yml

I also tested the following:

$ cat site.yml.test1 
---
- hosts: all
  tasks:
# Set up OS-specific groups
  - group_by: 
key=os-{{ansible_distribution}}-{{ansible_distribution_version}}

- include: am-servers.yml
- include: stor-servers.yml
- include: base-static-setup.yml

Which ran fine as well, so it must be the following block that is causing 
the fault:

- hosts: "{{ distro | default('all') }}"
  include:
  - dept1-servers.yml
  - dept2-servers.yml
  - base-static-setup.yml

All I am trying to do is to make the included playbooks run only for 
machines with the specified OS, if I specify the target OS on the 
ansible-playbook command line via the ' -e "distro=os-Fedora-20"' variable 
construct you gave me. That way I can always target a subset of my 
specified inventory by OS, if I want to run certain plays (say those with a 
specific tag) only against member servers with the specified OS. Otherwise, 
if I don't pass an " -e distro=<whatever>" variable, it will target all 
members of the inventory. Make sense?

- Will


On Friday, September 12, 2014 3:19:30 PM UTC-4, Michael DeHaan wrote:
>
> I'm unclear what you meant by "can I do X" specifically, what that meant 
> you could or couldn't do.
>
> A traceback in ansible is a bug though, so please figure out what the 
> minimum way to reproduce that is and file a ticket (provided you are using 
> at least 1.7.1 already and it can be reproduced there).
>
> If you can, checking the devel branch would also be useful.
>
>
>
>
>
> On Fri, Sep 12, 2014 at 2:29 PM, Willard Dennis <[email protected] 
> <javascript:>> wrote:
>
>> Hmmm, I guess not...
>>
>> $ ansible-playbook -i temp-stor-inv -u root -k site.yml --tags=mailserver 
>> -e "distro=os-Fedora-20"
>> SSH password: 
>> Traceback (most recent call last):
>>   File "/usr/bin/ansible-playbook", line 309, in <module>
>>     sys.exit(main(sys.argv[1:]))
>>   File "/usr/bin/ansible-playbook", line 191, in main
>>     force_handlers=options.force_handlers
>>   File "/usr/lib/pymodules/python2.7/ansible/playbook/__init__.py", line 
>> 180, in __init__
>>     (self.playbook, self.play_basedirs) = 
>> self._load_playbook_from_file(playbook, vars)
>>   File "/usr/lib/pymodules/python2.7/ansible/playbook/__init__.py", line 
>> 271, in _load_playbook_from_file
>>     inc_vars, inc_path = self._get_include_info(play, basedir, play_vars)
>>   File "/usr/lib/pymodules/python2.7/ansible/playbook/__init__.py", line 
>> 208, in _get_include_info
>>     tokens = shlex.split(play_ds.get('include', ''))
>>   File "/usr/lib/python2.7/shlex.py", line 279, in split
>>     return list(lex)
>>   File "/usr/lib/python2.7/shlex.py", line 269, in next
>>     token = self.get_token()
>>   File "/usr/lib/python2.7/shlex.py", line 96, in get_token
>>     raw = self.read_token()
>>   File "/usr/lib/python2.7/shlex.py", line 124, in read_token
>>     nextchar = self.instream.read(1)
>> AttributeError: 'list' object has no attribute 'read'
>>
>>
>> On Friday, September 12, 2014 2:15:47 PM UTC-4, Willard Dennis wrote:
>>>
>>> Thanks, Michael! But can I do the following?
>>>
>>> $ cat site.yml
>>> ---
>>>
>>> - hosts: all
>>>   tasks:
>>> # Set up OS-specific groups
>>>   - group_by: key=os-{{ansible_distribution}}-{{ansible_distribution_
>>> version}}
>>>
>>> - hosts: "{{ distro | default('all') }}"
>>>   include: 
>>>   - dept1-servers.yml
>>>   - dept2-servers.yml
>>>   - base-static-setup.yml
>>>
>>>
>>> Rather not change the individual playbooks if I can help it.
>>>
>>> Thanks,
>>> Will
>>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/98818c0c-5a9f-49de-ba20-ada11c535d30%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/98818c0c-5a9f-49de-ba20-ada11c535d30%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> 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/2782e8c9-a131-437a-9b4c-d97dad1b6613%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to