Is there a solution to this?
I am trying to add to PATH and can't keep ansible from evaluating a $
I've tried '\$' and several other things.
I'm trying to achieve the following:
MYPATH is an env variable on a remote host.
I want to add a string defined in vars/main.yml to a line in .bash_profile
export PATH=$PATH:$MYPATH
In full detail here
- name: Add git scripts to .bash_profile
lineinfile: dest="{{home_prefix}}/{{ansible_ssh_user}}/.bash_profile"
regexp="{{item.regexp}}"
line="{{item.line}}"
with_items:
- {
regexp: "roles/git/files",
line: '{{path_to_git_extras}}'
}
with path_to_git_extras defined in vars/main.yml
path_to_git_extras: 'PATH=\\$PATH:\\$ANSIBLE_21CT_HOME/roles/git/files'
# I thought jinja filters might work here but i get variable "string"
undefined
path_to_git_extras: '{{string("export
PATH=$PATH:$ANSIBLE_21CT_HOME/roles/git/files")}}'
The latter is what i really want. A function or something that says "Don't
evaluate anything inside here EVER"
I didn't see an issue on git. Still want one filed?
kesten
On Saturday, October 20, 2012 6:26:16 AM UTC-5, Michael DeHaan wrote:
>
> Hi Jānis,
>
> Please make sure there's a bug filed in github for this. It looks
> like we need to improve the string replacement code. If you can paste
> as much of your playbook as possible into the ticket that would be
> great.
>
> (You will probably have to indent each line in github by four spaces
> to get it to render correctly in the browser.)
>
> http://github.com/ansible/ansible, click on "issues".
>
> your problem *MAY* go away if you change that to $service_net_ip, but
> I can't be positive without trying it. In any event, paste the full
> playbook, redacting what you need to, and we can take a look.
>
> --Michael
>
> On Sat, Oct 20, 2012 at 5:17 AM, Jānis Ģeņģeris
> <[email protected] <javascript:>> wrote:
> > Somehow this is not working for me.
> >
> > Using this:
> > - net_status_match_02: "^[[:blank:]]+address ${service_net_ip}$"
> >
> > I get this error:
> > Traceback (most recent call last):
> > File "/home/j9/software/ansible/bin/ansible-playbook", line 164, in
> > <module>
> > sys.exit(main(sys.argv[1:]))
> > File "/home/j9/software/ansible/bin/ansible-playbook", line 135, in
> main
> > pb.run()
> > File "/home/j9/software/ansible/lib/ansible/playbook/__init__.py",
> line
> > 170, in run
> > play = Play(self, play_ds, play_basedir)
> > File "/home/j9/software/ansible/lib/ansible/playbook/play.py", line
> 83, in
> > __init__
> > self._tasks = self._load_tasks(self._ds, 'tasks')
> > File "/home/j9/software/ansible/lib/ansible/playbook/play.py", line
> 123,
> > in _load_tasks
> > results.append(Task(self,x,module_vars=task_vars))
> > File "/home/j9/software/ansible/lib/ansible/playbook/task.py", line
> 142,
> > in __init__
> > self.action = utils.template(None, self.action, self.module_vars)
> > File "/home/j9/software/ansible/lib/ansible/utils.py", line 390, in
> > template
> > text = varReplace(unicode(text), vars, expand_lists=expand_lists)
> > File "/home/j9/software/ansible/lib/ansible/utils.py", line 309, in
> > varReplace
> > replacement = varReplace(replacement, vars, depth=depth+1,
> > expand_lists=expand_lists)
> > File "/home/j9/software/ansible/lib/ansible/utils.py", line 296, in
> > varReplace
> > m = _varFind(raw)
> > File "/home/j9/software/ansible/lib/ansible/utils.py", line 249, in
> > _varFind
> > if text[var_start] == '{':
> > IndexError: string index out of range
> >
> > When using backslash escape:
> > - net_status_match_02: "^[[:blank:]]+address ${service_net_ip}\$"
> >
> > This error:
> > ERROR: Syntax Error while loading YAML script,
> > /home/j9/cfg/ansible/playbooks/network_config.yml
> > Note: The error may actually appear before this position: line 31,
> column 68
> >
> > - net_status_match_02: "^[[:blank:]]+address ${service_net_ip}\$"
> > ^
> >
> >
> > On Saturday, October 20, 2012 1:23:56 AM UTC+3, Daniel Hokka Zakrisson
> > wrote:
> >>
> >> Jānis Ģeņģeris wrote:
> >> > I have variable defined in playbook like this:
> >> >
> >> > vars:
> >> > - net_status_match_02: "^[[:blank:]]+address ${service_net_ip}\$"
> >> >
> >> > How to properly escape the '$' sign? The backslash is not working for
> >> > me.
> >>
> >> That depends entirely on what you want to do with it. Ansible's
> variable
> >> replacer will not touch any $ that is not followed by a valid variable
> >> name.
> >>
> >> Daniel
> >
> > --
> >
> >
>
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.