Re: [ansible-project] Re: group_vars behavior changed in 2.1?
OK, I see that this behavior change is being shown as a bug fix in 2.1.2: * Fixed a bug where a group_vars or host_vars directory in the current > working directory would be used (and would take precedence) over those in > the inventory and/or playbook directory. It would be nice if the group_vars directory in the current working directory was used as before. - David On Wednesday, August 24, 2016 at 7:37:11 AM UTC+3, David Resnick wrote: > > Is it possible that previously Ansible looked for group_vars in the > current directory (i.e. a sub-directory of the current one)? > > Because of multiple inventory files, I put inventory files in a > sub-directory; in this structure: > > project/ > ├── group_vars/ > │ └── all.yml > ├── playbooks/ > │ └── deploy.yml > └── inventory/ > ├── staging > └── production > > I run like this > > project$ ansible-playbook -i inventory/staging playbooks/deploy.yml > > In 2.1.0 variables defined in group_vars were picked up; in 2.1.1 they are > not. > > Is there any way to configure a "group_vars path" to allow using this > structure in 2.1.1? From your previous answer, I'm guessing there isn't. > > - David > > On Tuesday, August 23, 2016 at 4:34:45 PM UTC+3, Brian Coca wrote: >> >> Ansible has no concept of 'project', group/host_vars MUST be adjacent to >> either inventory or the play and should be picked up automatically if they >> match an group or host from inventory. >> >> The vars_files will look for relative paths in a 'vars/' directory >> adjacent to play or relative to the play, vars_files does not look into >> group/host_vars. >> >> >> -- >> Brian Coca >> > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/853f1582-3c66-4467-b56c-1f62677cb18c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Re: group_vars behavior changed in 2.1?
Is it possible that previously Ansible looked for group_vars in the current directory (i.e. a sub-directory of the current one)? Because of multiple inventory files, I put inventory files in a sub-directory; in this structure: project/ ├── group_vars/ │ └── all.yml ├── playbooks/ │ └── deploy.yml └── inventory/ ├── staging └── production I run like this project$ ansible-playbook -i inventory/staging playbooks/deploy.yml In 2.1.0 variables defined in group_vars were picked up; in 2.1.1 they are not. Is there any way to configure a "group_vars path" to allow using this structure in 2.1.1? From your previous answer, I'm guessing there isn't. - David On Tuesday, August 23, 2016 at 4:34:45 PM UTC+3, Brian Coca wrote: > > Ansible has no concept of 'project', group/host_vars MUST be adjacent to > either inventory or the play and should be picked up automatically if they > match an group or host from inventory. > > The vars_files will look for relative paths in a 'vars/' directory > adjacent to play or relative to the play, vars_files does not look into > group/host_vars. > > > -- > Brian Coca > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ef7fd2a8-9e8d-4a21-9a1f-c68f1cfa75aa%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ansible-project] Re: group_vars behavior changed in 2.1?
Ansible has no concept of 'project', group/host_vars MUST be adjacent to either inventory or the play and should be picked up automatically if they match an group or host from inventory. The vars_files will look for relative paths in a 'vars/' directory adjacent to play or relative to the play, vars_files does not look into group/host_vars. -- Brian Coca -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACVha7eii_d7-EkqLxJi_8TsehUVLVcT3RZx4ok-LcQYVkvdww%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: group_vars behavior changed in 2.1?
I ran into this issue as well. I decided to write an action plugin called include_vars_dir. This will sort the files in alphabetical order and include them. This also works in a role as well. I am in the process of writing a test suite, before making the PR. If you are interested in checking the code before the PR is made https://github.com/linuxdynasty/ld-ansible-plugins/blob/master/action_plugins/include_vars_dir.py I know some of this functionality is possible with using fileglob and include_vars. I needed something that I can control the depth of the directory as well. - name: include all yml files in group_vars/all and all nested directories include_vars_dir: dir: 'group_vars/all' - name: include all yml files in group_vars/services include_vars_dir: dir: 'group_vars/services' depth: 1 - name: include only bastion.yml files include_vars_dir: dir: 'vars' files_matching: 'bastion.yml' - name: include only all yml files exception bastion.yml include_vars_dir: dir: 'vars' ignore_files: 'bastion.yml' that instead of using include_vars with fileglob. On Thursday, August 18, 2016 at 9:41:27 AM UTC-7, Vincent Jørgensen wrote: > > Hi all, I have an ansible project with a groups_vars directory, with a > subdirectory called all beneath it, like so: > /project/group_vars/all/ami.yml > /project/group_vars/all/dns.yml > /project/group_vars/all/key.yml > > Previously, I didn't have to specify in my playbook the path to each > variable file (amis dns and keys change often enough that it's handy to > keep them separate). But since moving to 2.1.1.0, ansible can't find the > files under all, so I've had to resort to this: > - hosts: localhost > ... > vars_files: > - "{{ base_dir }}/group_vars/all/dns.yml" > - "{{ base_dir }}/group_vars/all/ami.yml" > - "{{ base_dir }}/group_vars/all/key.yml" > tasks: > - ... > > > Did this feature go away? It isn't the end of the world, but I liked that > feature, that all could be directory or a file. Thanks. \V > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ce223a5e-8d1d-4354-ba78-06440f5259e8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ansible-project] Re: group_vars behavior changed in 2.1?
I just posted about this too, it looks like a bug to me. - David On Thursday, August 18, 2016 at 7:41:27 PM UTC+3, Vincent Jørgensen wrote: > > Hi all, I have an ansible project with a groups_vars directory, with a > subdirectory called all beneath it, like so: > /project/group_vars/all/ami.yml > /project/group_vars/all/dns.yml > /project/group_vars/all/key.yml > > Previously, I didn't have to specify in my playbook the path to each > variable file (amis dns and keys change often enough that it's handy to > keep them separate). But since moving to 2.1.1.0, ansible can't find the > files under all, so I've had to resort to this: > - hosts: localhost > ... > vars_files: > - "{{ base_dir }}/group_vars/all/dns.yml" > - "{{ base_dir }}/group_vars/all/ami.yml" > - "{{ base_dir }}/group_vars/all/key.yml" > tasks: > - ... > > > Did this feature go away? It isn't the end of the world, but I liked that > feature, that all could be directory or a file. Thanks. \V > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ce1020e4-332e-4016-ab2c-ce411f2f2948%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.