Re: [ansible-project] Ansible find module , can path parameter include regex ?

2018-05-27 Thread Saranya Nagaraj
Thank you Kai , I'll try that out.

On May 25, 2018 11:43 PM, "Kai Stian Olstad" <
ansible-project+l...@olstad.com> wrote:

> On 25.05.2018 14:36, Saranya N wrote:
>
>> I'm trying to find files dit.xml under particular directories.
>>
>> Rather than mentioning the directories as a list like below
>>
>> Path : [ /opt/local/version_v1.3.1 , /opt/local/version_v1.3.0 ]
>>
>> I tried /opt/local/version_v1.3.* and it didn't work.
>>
>> Actually I have dit.xml files under /opt/local/version_v1.5.0 which I
>> don't want to modify.
>>
>> That's y looking for regex for paths.
>>
>> Is it possible? Kindly suggest
>>
>
> Since it's not in the documentation it's not supported.
>
> What you could do is first a find that finds the directories and exclude
> the once you don't want.
> The result of that find is used in the second find to find the correct
> files.
>
> --
> 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/to
> pic/ansible-project/1wMwHzLp7-g/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/ms
> gid/ansible-project/72011b5e9189631b41d1d59d3dfdb94d%40olstad.com.
> 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/CAPYop%2BgkiN%2B%2BVwyhNNG4EiJFXBqp2%3DSUOzhvzAtrJH8mi%2BUPzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Capture the stdout result in a variable, using regex and pass it to the next task

2019-01-14 Thread Saranya Nagaraj
Thankyou Kai Stian , that worked !

On Jan 10, 2019 11:31 PM, "Kai Stian Olstad" <
ansible-project+l...@olstad.com> wrote:

On Thursday, 10 January 2019 18:48:19 CET Saranya N wrote:
> One task in my playbook produces output sample of different types like
below
>
>
> stdout_lines
>
> ex: 1
>
> [
> "_ _ _"
> "farm/dt-tk-1/env: agent_tcp"
> ]
>
> ex: 2
>
>
> [
> "_ _ _"
> "test/xc-yh-1/qa: agent_tcp"
> ]
>
>
> etc
>
>
> I need to capture the second line regex:
>
> test/xc-yh-1/qa
>
> farm/dt-tk-1/env
>
> I need to capture the above part. Im aware I can use set_fact with regex
> but Im having difficulty in forming regex. Can someone kindly help

You don't need any regexp, just add this to your stdout_lines

  .stdout_lines.1.split(':').0

-- 
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/A6S4hbCGqZI/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/2330303.j3Vt51A68T%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/CAPYop%2Bg5vNL4znsNRDjUvSsRnz%2Bc1CPb8RxnG%3DioDRD-sWUbWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Convert a text file with list of strings into yml help

2019-03-21 Thread Saranya Nagaraj
Thank you Kai. That helped.

On Mar 20, 2019 2:04 AM, "Kai Stian Olstad" 
wrote:

> On 19.03.2019 20:09, Saranya N wrote:
> > I'm having a text file with lots of strings like below.
> >
> > Cat test.txt
> > String1
> > String2
> > .
> > .
> > .
> > Etc
> >
> > I literally have 2k of strings on that file.
> >
> > I want to convert to yank like below.
> >
> > _ _ _
> >
> > Listofstrings:
> >- string1
> >- string2
> >
> > ...etc
> >
> >
> > I can achieve this via shell script but is there an ansible way of doing
> it using lineinfile or anything else?
> >
> > I know I can achieve via jinja2​ tempalte as well but I don't know how
> to loop over the strings in the text file in j2 template.
>
> You can create a variable with the list like so
>
>   - set_fact:
>   listofstrings: '{{ listofstrings | default([])  + [item] }}'
> with_lines: cat test.txt
>
> and then you can do all sort of thing with the variable listofstrings in
> Ansible.
>
>
> --
> 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/il1LDL5H4xQ/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/ae70bfbe-7a63-28e0-53e9-fb7fa7a74470%40olstad.com.
> 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/CAPYop%2Bi6TreCSgPau8i7QESVJikaJEkehxmCtm6WmkOyq8xOwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] How to capture/filter stdout_lines

2019-04-11 Thread Saranya Nagaraj
Thankyou Sebastian

On Apr 10, 2019 11:16 AM, "Sebastian Meyer"  wrote:

> On 10.04.19 04:38, Saranya N wrote:
> > Stdout_lines that I get contains strings , json in different lines.
> >
> > I want to capture the last line and copy those contents to a a new Json
> file.
> >
> > How do I capture the last line from the registered variable.
> >
> > I tried this and it didn't work.
> >
> > "{{ Regvar.stdout_lines | last }}"
>
> Try
>
> {{ regvar.stdout_lines[-1] }}
>
> >
>
> --
> Sebastian Meyer
> Linux Consultant & Trainer
> Mail: me...@b1-systems.de
>
> B1 Systems GmbH
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
>

-- 
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/CAPYop%2BjADFu4U8jYsFdsssywmdkc1%2B13PkkyLkhfzuTUwYZi-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Choose inventory hosts.ini file based on condition

2019-06-03 Thread Saranya Nagaraj
Sorry that prod / Prod is a typo.
I'm basically using same at both places.

On Jun 3, 2019 5:38 PM, "Wawrzek Niewodniczanski"  wrote:

> On Tue, 28 May 2019 at 16:31, Saranya N  wrote:
> >
> > I have different staging environments under inventory.
> >
> [...]
> >  Prod/
> >group_vars
> >hosts.ini
> >
> [...]
> > When I run my ansible playbook like this it doesn't work. How can I do
> this?
> >
> > ansible-playbook -i inventory/{{ env }}/ -e "env=prod"
> >
>
> Is it 'prod' or 'Prod'?
>
> I'm not sure if that (having {{ env }} in path) can work. AFAIR you
> need a path to the hosts files. Have you tried ansible-playbook -i
> inventory/Prod/hosts.ini?
>
> Wawrzek
> --
> Dr  Wawrzyniec Niewodniczańskior Wawrzek for short
>   PhD in Quantum Chemistry  & MSc in Molecular Engineering
>WWW: http://wawrzek.name E-MAIL: j...@wawrzek.name
>   Linux User #177124
>
> --
> 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/GcxV5MRlGrg/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/CAC7-vpABq7GXHvCjRqZFYeEu8-3ACurLnRefqGtYUigTQiPO-A%
> 40mail.gmail.com.
> 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/CAPYop%2BiBkOEA_SMk7zt7EQCG%2B1CNFa4OaZ%3DsROHE9RrKsOQzQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Generate a sequence in a playbook using the inventory host group length

2019-04-23 Thread Saranya Nagaraj
Hi Brian,
Thankyou for the response.
This generates a list of numbers.

But I want a string like this "0,1,2,3"

I kind of tried python join n didn't work.

Can you please assist.

On Apr 23, 2019 7:48 AM, "Brian Coca"  wrote:

> mysequence: "{{range(0, groups['Test']|length + 1)|list }}"
>
> --
> --
> Brian Coca
>
> --
> 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/qJ2gUMCXYvw/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/CACVha7eJQhOg9QmMnSit1j6m1iOEB
> 0k8t%3D4OOEUavzBwO7M-bQ%40mail.gmail.com.
> 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/CAPYop%2BgkCrqcxrVyoqShjaui84_%3DQ-F7BVW_tM3DyEN34aOT8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Generate a sequence in a playbook using the inventory host group length

2019-04-23 Thread Saranya Nagaraj
Thankyou much Kai

On Apr 23, 2019 2:06 PM, "Kai Stian Olstad" 
wrote:

> On 23.04.2019 10:20, Saranya Nagaraj wrote:
>
>> Hi Brian,
>> Thankyou for the response.
>> This generates a list of numbers.
>>
>> But I want a string like this "0,1,2,3"
>>
>> I kind of tried python join n didn't work.
>>
>
> use the join filter
>
> {{range(0, groups['Test']|length + 1)|list | join(',') }}
>
> --
> 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/to
> pic/ansible-project/qJ2gUMCXYvw/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/ms
> gid/ansible-project/794b2d8e9863562062e4f826b58cfb36%40olstad.com.
> 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/CAPYop%2Bi4PvoT_ta9Pqw9rJffJp0xs5N6eAibq5Av-NbudsFc8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.