Concatenation of vars ?

1,313 views
Skip to first unread message

ansibleguest

unread,
May 29, 2012, 7:34:32 AM5/29/12
to Ansible Project
Hi,

i am new to ansible and just rewrote some puppet-recipe with ansible
now...
I am looking for a way to reassign and also concatenate variables ?

user: myuser

vars:
base: /opt/productsuite

vars_files:
- vars/product.yml # this brings a piece of a directory-path
also: product: sqldb

tasks:
- action file path=$base/$user/$product/bin state=directory owner=
$user group=$group


So the directory string is long and i would like to replace it with a
new variable to make the playbook even shorter.
$thepath = "$base/$user/$product"
action file path=$thepath/bin state=directory owner=$user group=
$group

What i also cannot do is to invoke vars block a second time for
assignment of variables again which would help:
vars:
vars_files:
vars:

Some ideas ?

(ansible-0.3.1-1.el6, Centos 6.2)

Michael DeHaan

unread,
May 29, 2012, 8:05:11 AM5/29/12
to ansible...@googlegroups.com

On Tuesday, May 29, 2012 at 7:34 AM, ansibleguest wrote:

Hi,

i am new to ansible and just rewrote some puppet-recipe with ansible
now...
I am looking for a way to reassign and also concatenate variables ?

There's no way to add variables together and store them in other variables presently.

 

What i also cannot do is to invoke vars block a second time for
assignment of variables again which would help:
vars:
vars_files:
vars:

This isn't possible because a playbook is a YAML document and each play is a dictionary/hash data structure.

Each element can only occur once and are actually unordered, though there is some business logic that does handle order.

 
Reply all
Reply to author
Forward
0 new messages