Re: [ansible-project] Having problems with a variable in vars_files

2019-02-18 Thread Sudarshan V
Have a look at
https://docs.ansible.com/ansible/latest/modules/include_vars_module.html


Cheers,
Sudarshan
0423356179


On Tue, Feb 19, 2019 at 9:39 AM Sudarshan V 
wrote:

> Ok, it is unclear what you are trying to accomplish.
> try import_vars
>
>
>
> Cheers,
> Sudarshan
> 0423356179
>
>
> On Mon, Feb 18, 2019 at 11:47 PM Brian O'Mahony 
> wrote:
>
>> I had tried that previous, and it is the same issue.
>>
>> --
>> 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/8b94c0e2-862f-43b4-b604-d589b1ac224d%40googlegroups.com
>> 
>> .
>> 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 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/CAGVXuK_6oXUeGihATMT%3DRzsDTZM%2B9zKsFbe-sYW3%3DE6FDNZWNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Having problems with a variable in vars_files

2019-02-18 Thread Sudarshan V
Ok, it is unclear what you are trying to accomplish.
try import_vars



Cheers,
Sudarshan
0423356179


On Mon, Feb 18, 2019 at 11:47 PM Brian O'Mahony  wrote:

> I had tried that previous, and it is the same issue.
>
> --
> 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/8b94c0e2-862f-43b4-b604-d589b1ac224d%40googlegroups.com
> 
> .
> 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 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/CAGVXuK9C2hvUAu74-wB_TjbhJ5%2Bqw-QfbWA6wRhKjEGJVe6kNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Having problems with a variable in vars_files

2019-02-18 Thread Brian O'Mahony
I had tried that previous, and it is the same issue.

-- 
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/8b94c0e2-862f-43b4-b604-d589b1ac224d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Having problems with a variable in vars_files

2019-02-15 Thread Sudarshan V
Hi,

Try

vars_files:
- vars/"{{ dcenv }}".yml
- vars/vault


Cheers,
Sudarshan
0423356179


On Fri, Feb 15, 2019 at 4:36 AM Brian O'Mahony  wrote:

> I am having an issue with referencing a variable in var_files module, and
> cant for the life of me figure it out. I am generating some vars in a
> playbook, and using setfact on them [basically awk shell commands to strip
> arts of the ansible control node hostname]
>
> If i debug the var before hand I can see it, but the play returns an
> undefined variable:
>
> *Playbook:*
> ---
> # Set DC and ENV vars before doing anything
> - import_playbook: generate_predeploy_vars.yml
> - name: Debug
>   hosts: localhost
>   tasks:
> - debug: var=dcenv
> - name: Test Inventory
>   gather_facts: yes
>   vars_files:
> - "vars/{{ dcenv }}.yml"
> - vars/vault
>   hosts: localhost
>   tasks:
> - ping:
>
> *Output:*
>
> PLAY [Get DC and ENV variables from Ansible Controller hostname]
> **
>
> TASK [shell]
> **
> changed: [localhost]
>
> TASK [shell]
> **
> changed: [localhost]
>
> TASK [set_fact]
> ***
> ok: [localhost]
>
> PLAY [Debug]
> **
>
> TASK [Gathering Facts]
> 
> ok: [localhost]
>
> TASK [debug]
> **
> ok: [localhost] =>
>   dcenv: my-prod
>
> PLAY [Test Inventory]
> *
> ERROR! an undefined variable was found when attempting to template the
> vars_files item 'vars/{{ dcenv }}.yml'
>
> --
> 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/226f2ba4-f84b-416f-9374-4960044a31dd%40googlegroups.com
> 
> .
> 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 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/CAGVXuK-8BwphRFz5%3DLMw7gAKAu6KosVJ54f41H%3DJmuhfHhMs7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Having problems with a variable in vars_files

2019-02-14 Thread Brian O'Mahony
I am having an issue with referencing a variable in var_files module, and 
cant for the life of me figure it out. I am generating some vars in a 
playbook, and using setfact on them [basically awk shell commands to strip 
arts of the ansible control node hostname]

If i debug the var before hand I can see it, but the play returns an 
undefined variable:

*Playbook:*
---
# Set DC and ENV vars before doing anything
- import_playbook: generate_predeploy_vars.yml
- name: Debug
  hosts: localhost
  tasks:
- debug: var=dcenv
- name: Test Inventory
  gather_facts: yes
  vars_files:
- "vars/{{ dcenv }}.yml"
- vars/vault
  hosts: localhost
  tasks:
- ping:

*Output:*

PLAY [Get DC and ENV variables from Ansible Controller hostname] 
**

TASK [shell] 
**
changed: [localhost]

TASK [shell] 
**
changed: [localhost]

TASK [set_fact] 
***
ok: [localhost]

PLAY [Debug] 
**

TASK [Gathering Facts] 

ok: [localhost]

TASK [debug] 
**
ok: [localhost] =>
  dcenv: my-prod

PLAY [Test Inventory] 
*
ERROR! an undefined variable was found when attempting to template the 
vars_files item 'vars/{{ dcenv }}.yml'

-- 
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/226f2ba4-f84b-416f-9374-4960044a31dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.