Strange variable issue

40 views
Skip to first unread message

Petr Sukharev

unread,
May 8, 2014, 1:27:55 PM5/8/14
to ansible...@googlegroups.com

Hi!

I have multiple projects and try to use ansible for all of them.

One of idea was to make my playbooks more flexible by specified variable files for each project. In this case i have one role - deploy software and multiple playbooks with config like this

<script src="https://gist.github.com/anonymous/35117b7088079fba8af4.js"></script>


But when i try to use some variables from dbvars file for hosts in db group - ansible say that cant find this variable. If i specified in this host group project_name - all work fine... It make me little confused, because i specified this variable for all hosts on top...

Petr Sukharev

unread,
May 8, 2014, 1:31:11 PM5/8/14
to ansible...@googlegroups.com

Try to insert nice code from playbook and fail :)

Here is current link

https://gist.github.com/anonymous/35117b7088079fba8af4

Dick Davies

unread,
May 9, 2014, 11:42:08 AM5/9/14
to ansible list
I might be missing something but using group_vars solves this problem
cleanly for me.

group_vars/all are 'globals'
group_vars/webservers are available to all webservers

and so on.
> --
> 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-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1d8f9386-ad46-4aa9-9f3c-172274e154da%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Petr Sukharev

unread,
May 9, 2014, 12:06:50 PM5/9/14
to ansible...@googlegroups.com, di...@hellooperator.net

Thanks for your reply!

I have multiple projects and each of them have webservers, bases or other groups. With your solution i need to use various names for this groups - test_app, prod1_app, prod2_app and others..  It will be real hard to manage all this group names

My point is - why variable from "all" section in playbook doesnt work in lower part of same playbook - for app or db hosts. And how to deal with it :)

Rénald Casagraude

unread,
May 9, 2014, 4:14:34 PM5/9/14
to ansible...@googlegroups.com
Do you need to use defaults/main.yml for sane defaults inside your role ?

R.

Sukharev Petr

unread,
May 10, 2014, 3:27:48 PM5/10/14
to ansible...@googlegroups.com
Сб. 10 мая 2014 00:14:34, Rénald Casagraude писал:
> Do you need to use defaults/main.yml for sane defaults inside your role ?
>
> R.
>

This file keep variables for role. I need variable for all host groups
in playbook. I think, best way is use -e key, or write this variable in
inventory file.. Hmm, try this solution tommorow...
Reply all
Reply to author
Forward
0 new messages