Thanks Kai for the help always..will check on this ...

On Tue, Dec 12, 2017 at 11:04 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On Tuesday, 12 December 2017 07.28.53 CET coach.r...@gmail.com wrote:
> > Hi,
> >
> > Trying to read the values from flat files and to use it as a variables in
> > the ansible playbook , for example
> >
> > the flatfile is
> > #cat output
> >
> >  example.com/development/testcaseone:v99
> >
> > I want to use above values as a variables in the playbook , just like
> > ---
> > - hosts:
> >   vars:
> >     rt1: example.com
> >     stage_name: development
> >     job_name: testcaseone
> >     version_number: v99
> >
> >
> > I tried with lookup ('file', /path/to/output) but it gives the entire
> > output of the value..
>
> Not tested but something like this might work.
>
>   - fetch:
>       src: /path/to/file
>     register: r
>
>   - set_fact:
>       rt1: '{{ (r.content | b64decode).split('/')[0] }}'
>       stage_name: '{{ (r.content | b64decode).split('/')[1] }}'
>       job_name: '{{ (r.content | b64decode).split('/')[2].split(':')[0]
> }}'
>       version_number: '{{ (r.content | b64decode).split('/')[2].split(':')[1]
> }}'
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/OipBBxJ_NNc/unsubscribe.
> To unsubscribe from this group and all its topics, 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/2024833.PQvOlT6LQd%40x1.
> 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/CALguqPJN4CbUp%2B%2BjqgdtZDQjwEW76JQfhscMc4MOfzZi822Zdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to