use variable in remote job

23 views
Skip to first unread message

r.gro...@gmail.com

unread,
May 19, 2015, 11:16:57 AM5/19/15
to ansible...@googlegroups.com
hi group,

I have tried to expand a variable ('environment' in this case) inside a cron job specification, but it does not seem to be possible.
ansible version 1.7.2

--------------------
all.yml:

[all:vars]
environment=    test
-------------------------
roles/av/tasks/main.yml:

- name: install crontab for user av
  cron: user="av" name="avr" minute="30" hour="23" job="ENVIRONMENT={{ environment }} xvfb-run /usr/local/bin/validator" state="present" backup="yes"
  register: backup

-------------

The result is the crontab entry

30 23 * * * ENVIRONMENT={} xvfb-run /usr/local/bin/validator

while I should expect

30 23 * * * ENVIRONMENT=test xvfb-run /usr/local/bin/validator

Is it possible at all or am I trying to accomplish the impossible?

thanks, Ruud


Brian Coca

unread,
May 19, 2015, 11:18:36 AM5/19/15
to ansible...@googlegroups.com
environment is a keyword in ansible, it is not a good idea to use as a
variable name.

--
Brian Coca

r.gro...@gmail.com

unread,
May 20, 2015, 2:54:34 AM5/20/15
to ansible...@googlegroups.com
hi Brian,

it is always heart warming to see that problems that seem so big can have such simple solutions. Hopefully this applies to everyday life too. I will take a closer look on that.. ;)

thanks a lot, Ruud
Reply all
Reply to author
Forward
0 new messages