Re: [ansible-project] How to use variables from one task in another task

2019-10-01 Thread Srinivas Naram
Hi Vladimir,

I have tried with your suggestion and got following error.

---
fatal: [172.19.251.173]: FAILED! => {"msg": "The conditional check
'hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS''
failed. The error was: error while evaluating conditional
(hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS'):
\"hostvars['hostname1']\" is undefined\n\n

--
Kindly help.

Thanks





On Mon, Sep 30, 2019 at 9:48 PM Vladimir Botka  wrote:

> On Mon, 30 Sep 2019 20:03:25 +0530
> Srinivas Naram  wrote:
>
> > *Trial1* :
> > when: {{hostvars['hostname1]['ansible_facts']['distribution']}} ==
> "CentOS"
>
> Try this one
>
>   when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
> 'CentOS'"
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6vtS6GBBFczMEKW9SGaopLkYZzeabb9WDaL5neS_H90A%40mail.gmail.com.


Re: [ansible-project] How to use variables from one task in another task

2019-10-01 Thread Srinivas Naram
Hi Vladimir,

hostname1 is defined in my inventory file. Here is the yml file snippet

- hosts: hostname2
  gather_facts: true
  tasks:
-
  file:
   path: "/home/ansible_user/controller3/file_name"
   state: touch
  when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
'CentOS'"

When I comment'when'this code runs fine. Please suggest.



On Tue, Oct 1, 2019 at 12:55 PM Vladimir Botka  wrote:

>
> > > > *Trial1* :
> > > > when: {{hostvars['hostname1]['ansible_facts']['distribution']}} ==
> > > > "CentOS"
> > >
> > > Try this one
> > > when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
> > > 'CentOS'"
>
> On Tue, 1 Oct 2019 12:41:22 +0530
> Srinivas Naram  wrote:
> > I have tried with your suggestion and got following error.
> > fatal: [172.19.251.173]: FAILED! => {"msg": "The conditional check
> > 'hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS''
> > failed. The error was: error while evaluating conditional
> > (hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS'):
> > \"hostvars['hostname1']\" is undefined\n\n
>
> Don't use undefined hostnames.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6YqWwuX0qbCpfTRmdrmc7i_y4dKwb6jSfCpPGnFsJ%3DPw%40mail.gmail.com.


Re: [ansible-project] How to use variables from one task in another task

2019-10-01 Thread Srinivas Naram
Hello

- debug:
 var: hostvars

shows all the hosts in my inventory file, so I believe my playbook has
access to all hosts. To hash out issue with inventory file, I modified my
code as below.

--

- hosts: *hostname2*
  tasks:
-
  file:
   path: "/home/ansible_user/from_controller3/file_name"
   state: touch
  when: "hostvars['*hostname2*']['ansible_facts']['distribution'] ==
'CentOS'"

-

*hostname2 *is mentioned near hosts and near when. I still get following
error

--
FAILED! => {"msg": "The conditional check
'hostvars['hostname2']['ansible_facts']['distribution'] == 'CentOS''
failed. The error was: error while evaluating conditional
(hostvars['hostname2']['ansible_facts']['distribution'] == 'CentOS'):
\"hostvars['hostname2']\" is undefined

--

Any thoughts ?


On Tue, Oct 1, 2019 at 5:00 PM Vladimir Botka  wrote:

> > > > > > *Trial1* :
> > > > > > when: {{hostvars['hostname1]['ansible_facts']['distribution']}}
> ==
> > > > > > "CentOS"
> > > > >
> > > > > Try this one
> > > > > when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
> > > > > 'CentOS'"
> > >
> > > On Tue, 1 Oct 2019 12:41:22 +0530
> > > Srinivas Naram  wrote:
> > > > I have tried with your suggestion and got following error.
> > > > fatal: [172.19.251.173]: FAILED! => {"msg": "The conditional check
> > > > 'hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS''
> > > > failed. The error was: error while evaluating conditional
> > > > (hostvars['hostname1']['ansible_facts']['distribution'] == 'CentOS'):
> > > > \"hostvars['hostname1']\" is undefined\n\n
>
> > > Don't use undefined hostnames.
>
> On Tue, 1 Oct 2019 14:44:59 +0530
> Srinivas Naram  wrote:
> > hostname1 is defined in my inventory file. Here is the yml file snippet
> >
> > - hosts: hostname2
> >   gather_facts: true
> >   tasks:
> > -
> >   file:
> >path: "/home/ansible_user/controller3/file_name"
> >state: touch
> >   when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
> > 'CentOS'"
> > When I comment'when'this code runs fine. Please suggest.
>
> The playbook is running at 'hostname2' only and knows nothing about
> 'hostname1' at all. You might want to take a look at
>
> - debug:
> var: hostvars
>
> Cheers,
>
> - vlado
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5E7tbyJHedA-kHp9PbU4rjgXneCF31N%2BKgnQ6HdRrzoA%40mail.gmail.com.


Re: [ansible-project] How to use variables from one task in another task

2019-10-01 Thread Srinivas Naram
Sure. Attached output of hostvars.

On Tue, Oct 1, 2019 at 7:41 PM Vladimir Botka  wrote:

> On Tue, 1 Oct 2019 18:39:54 +0530
> Srinivas Naram  wrote:
>
> > - debug:
> >  var: hostvars
> >
> > shows all the hosts in my inventory file, so I believe my playbook has
> > access to all hosts.
> > [...]
> > I still get following error
> > [...]
> > failed. The error was: error while evaluating conditional
> > (hostvars['hostname2']['ansible_facts']['distribution'] == 'CentOS'):
> > \"hostvars['hostname2']\" is undefined
> >
> > Any thoughts ?
>
> Sure. Attach the tarball with the output of "- debug: var=hostvars"
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5uJYqSoR8fe3UdFgwMUKYpBkuZTQ6RHvV8hScyZxzL%2Bg%40mail.gmail.com.


hostvars.log
Description: Binary data


[ansible-project] Connection via Citrix

2019-09-24 Thread Srinivas Naram
Hello Gurus,

Few devices in my customer environment can be connected via Citrix. How to 
connect to devices which are accessible only via Citrix using Ansible ?

Thanks
 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d1bff7ea-9805-47f1-98c7-b5677321d763%40googlegroups.com.


[ansible-project] How to use variables from one task in another task

2019-09-20 Thread Srinivas Naram
Hello Ansible Gurus,

I am new to Ansible and trying to get my hands dirty on playbooks. I wrote 
an yaml file to use a variable from one host tasks to another. Here is my 
code ( logically this code may not make sense in real world, I am trying to 
understand features in Ansible ) 


---
-
  hosts: modified_user1
  tasks:
-
  name: "test connection"
  ping: 
  register: result
-
  debug:
var: result
  when: result is succeeded
-
  file:
   path: "/home/ansible_user/from_controller3/file_name"
   state: touch
  when: result is succeeded

-
  hosts: modified_user2
  tasks:
- name: "create a file in the directory"
  file:
   path: "/home/ansible_user/from_controller4/file_name"
   state: touch
  when: result is succeeded
-
  debug:
   var: result



Is there a provision to pass 'result' variable to second host ?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5156200-9b84-49a3-837e-5b2dc4b9c39e%40googlegroups.com.


Re: [ansible-project] How to use variables from one task in another task

2019-09-30 Thread Srinivas Naram
Hi Kai,

I have been trying various ways to get my playbook working by using
hostvars.

Here are some of the ways I have tied, with no luck

*Trial1* :  when: {{
hostvars['hostname1]['ansible_facts']['distribution']}} == "CentOS"

*Trial2*: when: ansible_facts['hostname1']['distribution'] == "CentOS"

Can you help me with this?

Thanks
Srini.



On Sat, Sep 21, 2019 at 3:39 AM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 20.09.2019 09:37, Srinivas Naram wrote:
> > Is there a provision to pass 'result' variable to second host ?
> >
>
> No. But you can use hostvars to lookup variable for other hosts.
>
> --
> Kai Stian Olstad
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/37d13e89-37c6-ac12-4a53-81dfb7e997ac%40olstad.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4WFA1%3DyxHFAk_ZRvbg%2BSCs-tcF14mH8O_gwp%2BHGYAj1Q%40mail.gmail.com.


Re: [ansible-project] Facts overview

2019-10-18 Thread Srinivas Naram
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#caching-facts


HTH
Srini

On Fri, Oct 18, 2019 at 2:24 PM Andre Gronwald 
wrote:

> I read somewhere that it is possible to cache facts - is it possible as
> well to have those facts in an overview? my focus is on identifying old
> software packages. Is that possible?
>
> kind regards,
> andre
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/294d9e5c-bb27-455d-8065-7d2a4c17c912%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5TBxaHj7X6G87ET2DgpQDxLkJdcYcNjUK4o%3DLJ7_7nBA%40mail.gmail.com.


Re: [ansible-project] Connection via Citrix

2019-09-25 Thread Srinivas Naram
Hello,

Can you please provide more details on how you are moving forward with the
setup ? Is any documentation available to understand how this can be
achieved ?

TIA

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4JcTz1_y%3D7_a2oi2MbDEKwzKMn%3Dog_BsJbLF9UTWH1_A%40mail.gmail.com.


Re: [ansible-project] Re: How to use variables from one task in another task

2019-10-07 Thread Srinivas Naram
Hi All,

Thanks for your time and efforts to help me out with the issue. I
understood the mistak. I missed out making changes in the config file as
described in below link

https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#caching-facts


 TA



On Fri, Oct 4, 2019 at 12:04 PM Miroslav Windhouwer 
wrote:

> If I understand you correctly than try to do this. Make a folder host_var
> in your inventory folder. Than make a file with the exact same name as your
> host inside it,
>
> something like: inventory/host_var/host1.yaml
>
> Inside that file you'll put the vars and those you can you use global for
> that host.
>
> ---
> Name: host1
> Ip: x.x.x.x
> Path: ../.../
>
>
> Anything you need for that history can be placed inside it.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/28c98da5-f87e-4ea8-8765-a11049ec34af%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4FKqtFUv3HnPMND17GGdsnT_%3DJoivUGkfbVno3PVxYww%40mail.gmail.com.


[ansible-project] Re: How to use variables from one task in another task

2019-10-04 Thread Srinivas Naram
Hello Ansible Gurus,

Any inputs for me to resolve this issue. 

On Friday, September 20, 2019 at 1:07:20 PM UTC+5:30, Srinivas Naram wrote:
>
> Hello Ansible Gurus,
>
> I am new to Ansible and trying to get my hands dirty on playbooks. I wrote 
> an yaml file to use a variable from one host tasks to another. Here is my 
> code ( logically this code may not make sense in real world, I am trying to 
> understand features in Ansible ) 
>
>
> 
> ---
> -
>   hosts: modified_user1
>   tasks:
> -
>   name: "test connection"
>   ping: 
>   register: result
> -
>   debug:
> var: result
>   when: result is succeeded
> -
>   file:
>path: "/home/ansible_user/from_controller3/file_name"
>state: touch
>   when: result is succeeded
>
> -
>   hosts: modified_user2
>   tasks:
> - name: "create a file in the directory"
>   file:
>path: "/home/ansible_user/from_controller4/file_name"
>state: touch
>   when: result is succeeded
> -
>   debug:
>var: result
>
> 
>
> Is there a provision to pass 'result' variable to second host ?
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/80be1d22-9fa5-4325-9790-09eed1e192d3%40googlegroups.com.


Re: [ansible-project] How to use variables from one task in another task

2019-10-03 Thread Srinivas Naram
Kai,

I don't think it an issue with gather facts. Take a look at below code.

- hosts: *hostname2*
  tasks:
-
  file:
   path: "/home/ansible_user/from_controller3/file_name"
   state: touch
  when: "hostvars['*hostname2*']['ansible_facts']['distribution'] ==
'CentOS'"

-

*hostname2 *is mentioned near hosts and near when. I still get following
error

--
FAILED! => {"msg": "The conditional check
'hostvars['hostname2']['ansible_facts']['distribution'] == 'CentOS''
failed. The error was: error while evaluating conditional
(hostvars['hostname2']['ansible_facts']['distribution'] == 'CentOS'):
\"hostvars['hostname2']\" is undefined

Any thoughts ?

On Tue, Oct 1, 2019 at 11:04 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 01.10.2019 11:14, Srinivas Naram wrote:
> > hostname1 is defined in my inventory file. Here is the yml file snippet
> >
> > - hosts: hostname2
> >gather_facts: true
> >tasks:
> >  -
> >file:
> > path: "/home/ansible_user/controller3/file_name"
> > state: touch
> >when: "hostvars['hostname1']['ansible_facts']['distribution'] ==
> > 'CentOS'"
> >
> > When I comment'when'this code runs fine. Please suggest.
>
> The distribution variable is a gather facts variable, and when you run
> against hostname2 only that variable is not accessible because Ansible has
> not state between playbook run.
>
> One solution would be to use fact caching, or the easiest, just run gather
> facts on hostname1 first in the same playbook by adding following code
> before you play above.
>
> - hosts: hostname1
>   father_facts: true
>
>
>
> --
> Kai Stian Olstad
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bdf9a155-fd16-a635-7b01-6f4b6ec922db%40olstad.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5xVFBsXu4s94bFox9Jz6hgCxU1WSD4dt5fMKLfxY%3D2uA%40mail.gmail.com.


Re: [ansible-project] skip_reason": "Conditional result was False".

2019-10-11 Thread Srinivas Naram
Hi Manish,

I was facing same issue yesterday. To troubleshoot the issue I have
gathered the facts and observed that ansible_processor kind of variables
are list and have to be referenced with .0 or .1

try this out

ansible_processor. *0*


On Fri, Oct 11, 2019 at 4:07 PM Manish Kumar 
wrote:

> Hi All,
>
> I am trying to compare the output marked in yellow and proceed if
> condition is true   but it is skipping with skip_reason": "Conditional
> result was False".
>
> Please let me know how it can be achieved .
>
> ---
> - hosts: localhost
>   tasks:
>   - name: System details
> debug: msg="{{ item }}"
> with_items:
> - "{{ ansible_processor }}"
> - "{{ ansible_processor_cores }}"
> register: out
>   - name: verify
> debug: msg="passed"
> when: ansible_processor=="Intel(R) Xeon(R) Platinum 8175M CPU @
> 2.50GHz"
>
>
> ok: [localhost] => (item=None) => {
>
> "msg": "Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz"
>
> }
>
> ok: [localhost] => (item=None) => {
>
> "msg": 1
>
> }
>
>
>
> TASK [verify]
> **
>
> task path: /U01/automation/playbooks/Esm_java.yml:10
>
> skipping: [localhost] => {
>
> "skip_reason": "Conditional result was False"
>
> }
>
> META: ran handlers
>
> META: ran handlers
>
>
>
> PLAY RECAP
> *
>
> localhost  : ok=2changed=0unreachable=0
>  failed=0
>
>
>
> Thanks,
>
> Manish
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/941ab553-52b8-4661-8d0c-da9033d0b359%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6OCAzVitc_qb06aAY%2BHLD1zcvXAb%3DNzyArD8eaqsZUsg%40mail.gmail.com.


Re: [ansible-project] using hosts mentioned in inventory files in my tasks

2020-02-26 Thread Srinivas Naram
try {{ inventory_hostname }}

Regards
Srini

On Wed, Feb 26, 2020 at 4:49 PM Vishal Bobade 
wrote:

> Hello ,
>
> I have a inventory file with some 5-6 hosts and I want use them in some of
> my tasks/main.yml  file. Could some one please suggest how can I do that .
>
> Lets say below is my inventory file
>
> 
>
> [gameday]grafana.domain.netgitlab.domain.netsonarqube.domain.netartifactory.domain.netprometheus.domain.net
>
>
>
> I want to use them in some shell script which is going to be run as a part of 
> some tasks.
>
>
> for example below is some script where I want to replace 
> "sonarqube.dummy.domain.net" this with the one in inventory file which is 
> "sonarqube.domain.net"
>
>
> *shell script :*
>
>
> -->
>
> read -p "Enter a server name for Sonarqube : " SQ
>
> if [ -z "$SQ" ]; then
>
>  echo "DNS name for sonarqube not provided, cannot proceed"
>
>  exit 1
>
> else
>
>  sed -i s/sonarqube.dummy.domain.net/$SQ/g  /opt/sonarqube/*.json
>
> fi
>
> <-
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/915a168d-4b8f-4437-80e9-f45cf3af9d35%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6ZN-f_mtUXzc3NjARCB3Na69Ad_tiYyj8hAZhLWo%2Bd5g%40mail.gmail.com.


[ansible-project] Encrypted Password in Playbook

2020-01-20 Thread Srinivas Naram
Hi All,

I am trying to use Ansible vault encrypted password in my playbook and 
don't see clear documentation on how to use it.

Here is what I did so far -

In ansible.cfg I have set the 'vault_password_file'. 

I have all my playbooks in a directory called devplaybooks. I have created 
a sub-directory in devplaybooks directory with name 'vault' and executed 
following command

ansible-vault create passwords

Contents in passwords file : ansible_password= secret123

In my inventory file I have created host vars

[:vars]
ansible_user=root
ansible_password=!vault



When I execute the playbook it throws up an error

TASK [Gathering Facts] 

fatal: []: UNREACHABLE! => {"changed": false, "msg": "Invalid/incorrect 
username/password. Authentication failed.", "unreachable": true}



When I change the host vars to following the playbook is executing 
successfully


[:vars]
ansible_user=root
ansible_password= secret123



Can you please help me figure out my mistake or point me to right 
documentation. How does my playbook know my password file ?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a1b8bdc9-228d-405f-b37d-e90d1a108443%40googlegroups.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-21 Thread Srinivas Naram
Hello Vladimir,

Thanks for your reply.

I am trying to maintain password (encrypted using ansible-vault) and my
playbook (clear-text) in separate files. If I understand correctly the
below URL is suggesting to encrypt the password string and copy the same in
my playbook.

https://docs.ansible.com/ansible/latest/user_guide/vault.html#use-encrypt-string-to-create-encrypted-variables-to-embed-in-yaml


Am I reading this correctly? Please help.

On Tue, Jan 21, 2020 at 1:47 PM Vladimir Botka  wrote:

> On Mon, 20 Jan 2020 22:07:21 -0800 (PST)
> Srinivas Naram  wrote:
>
> > In my inventory file I have created host vars
> >
> > [:vars]
> > ansible_user=root
> > ansible_password=!vault
>
> The encrypted value of the variable is missing. See "Use encrypt_string to
> create encrypted variables to embed in yaml".
>
> https://docs.ansible.com/ansible/latest/user_guide/vault.html#use-encrypt-string-to-create-encrypted-variables-to-embed-in-yaml
>
> -vlado
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5ToCzB%2BgpD1sTke4mPB6R4d%2B4363e2%3DLJOowwvcqxGLg%40mail.gmail.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-21 Thread Srinivas Naram
Hello Vladimir

I have followed exactly same steps mentioned above and I see different
errors now.

My steps

- Set the Ansible Vault password file Env variable
- Create the vault encrypted file
- Create directories and copy files in specific location. My dir structure
playbooks
   |- vault
  |-testing.yml
  |-host_vars
   |- 192.168.249.107
|- test.yml

I get following error

Error - ERROR! failed to combine variables, expected dicts but got a 'dict'
and a 'AnsibleUnicode':{} "testing123:sensitive"

When I change the directory structure in host_vars to groupname
playbooks
   |- vault
  |-testing.yml
  |-host_vars
   |- ansible_enddevice_2
|- test.yml

I get different message

ok: [ 192.168.249.107 ] => { "testing123": "VARIABLE IS NOT DEFINED!" }

My inventory file structure

[ansible_enddevice_2]
192.168.249.107



On Tue, Jan 21, 2020 at 4:48 PM Vladimir Botka  wrote:

> On Tue, 21 Jan 2020 15:31:33 +0530
> Srinivas Naram  wrote:
>
> > I am trying to maintain password (encrypted using ansible-vault) and my
> > playbook (clear-text) in separate files.
>
> Below is a step-by-step scenario:
>
> 1) Let's assume the vault password has bee configured properly (you have
> set
> the 'vault_password_file' in ansible.cfg) . Let's use global variable here.
> For example
>
>   $ set | grep VAULT
>   ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt
>
> See "Providing Vault Passwords"
>
> https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords
>
> 2) Create a file foo.yml with variable(s). Encrypt the file. See the
> content.
>
>   $ cat foo.yml
>   test_var1: secret
>   $ ansible-vault encrypt foo.yml
>   $ cat foo.yml
>   $ANSIBLE_VAULT;1.1;AES256
>
> 3933376636373537313366326361306331333132626337343335343465353439623366373338
>
> 6438306562323262363965653336653362616136366439620a326533316463346437373066333433
>
> 3035333662373330376261363963613833366631386531633064323733313936663831393731
>
> 3036633964323235310a613766346633613765643832306539346137613731663865636564636164
>   61303534393363616263666564636366303861623131306536316432383230393736
>   $ ansible-vault view foo.yml
>   test_var1: secret1
>
> See "Encrypting Unencrypted Files"
>
> https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-unencrypted-files
>
> 3) Create inventory (fit the groups and hosts to your needs)
>
>   $ cat hosts
>   [test]
>   test_01
>
> 4) Put the encrypted file into the directory host_vars (fit the host to
> your
> needs)
>
>   $ mkdir -p host_vars/test_01
>   $ mv foo.yml host_vars/test_01/
>
> 5) Create and run playbook. See the variable was successfully decrypted.
>
>   $ cat test.yml
>   - hosts: test_01
> tasks:
> - debug:
> var: test_var1
>   $ ansible-playbook test1.yml
>   ok: [test_01] => { "test_var1": "secret1" }
>
> There are many variations how-to handle vault variables. If you have
> troubles
> report minimal, complete, reproducible example.
>
>
> HTH,
>
> -vlado
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5RRLrWxYfeX-LZTNXDRo8Bu7NTyr2itNGm3_B2jpw7VQ%40mail.gmail.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-24 Thread Srinivas Naram
Ok, I found the solution myself. Group or host variables should have
different directory. There is no need of explicit mention such as  in the playbook, but create a directory called group_vars or
host_vars in the directory where the playbook is placed.

these directories will have files with variables you want to define. File
structure should be in yml format.



On Thu, Jan 23, 2020 at 2:19 PM Srinivas Naram 
wrote:

> Suggestions please.
>
> On Wed, Jan 22, 2020 at 9:43 AM Srinivas Naram 
> wrote:
>
>> Any suggestions would be greatly appreciated.
>>
>> On Tue, Jan 21, 2020 at 8:05 PM Srinivas Naram 
>> wrote:
>>
>>> Hello Vladimir
>>>
>>> I have followed exactly same steps mentioned above and I see different
>>> errors now.
>>>
>>> My steps
>>>
>>> - Set the Ansible Vault password file Env variable
>>> - Create the vault encrypted file
>>> - Create directories and copy files in specific location. My dir
>>> structure
>>> playbooks
>>>|- vault
>>>   |-testing.yml
>>>   |-host_vars
>>>|- 192.168.249.107
>>> |- test.yml
>>>
>>> I get following error
>>>
>>> Error - ERROR! failed to combine variables, expected dicts but got a
>>> 'dict' and a 'AnsibleUnicode':{} "testing123:sensitive"
>>>
>>> When I change the directory structure in host_vars to groupname
>>> playbooks
>>>|- vault
>>>   |-testing.yml
>>>   |-host_vars
>>>|- ansible_enddevice_2
>>> |- test.yml
>>>
>>> I get different message
>>>
>>> ok: [ 192.168.249.107 ] => { "testing123": "VARIABLE IS NOT DEFINED!" }
>>>
>>> My inventory file structure
>>>
>>> [ansible_enddevice_2]
>>> 192.168.249.107
>>>
>>>
>>>
>>> On Tue, Jan 21, 2020 at 4:48 PM Vladimir Botka  wrote:
>>>
>>>> On Tue, 21 Jan 2020 15:31:33 +0530
>>>> Srinivas Naram  wrote:
>>>>
>>>> > I am trying to maintain password (encrypted using ansible-vault) and
>>>> my
>>>> > playbook (clear-text) in separate files.
>>>>
>>>> Below is a step-by-step scenario:
>>>>
>>>> 1) Let's assume the vault password has bee configured properly (you
>>>> have set
>>>> the 'vault_password_file' in ansible.cfg) . Let's use global variable
>>>> here.
>>>> For example
>>>>
>>>>   $ set | grep VAULT
>>>>   ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt
>>>>
>>>> See "Providing Vault Passwords"
>>>>
>>>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords
>>>>
>>>> 2) Create a file foo.yml with variable(s). Encrypt the file. See the
>>>> content.
>>>>
>>>>   $ cat foo.yml
>>>>   test_var1: secret
>>>>   $ ansible-vault encrypt foo.yml
>>>>   $ cat foo.yml
>>>>   $ANSIBLE_VAULT;1.1;AES256
>>>>
>>>> 3933376636373537313366326361306331333132626337343335343465353439623366373338
>>>>
>>>> 6438306562323262363965653336653362616136366439620a326533316463346437373066333433
>>>>
>>>> 3035333662373330376261363963613833366631386531633064323733313936663831393731
>>>>
>>>> 3036633964323235310a613766346633613765643832306539346137613731663865636564636164
>>>>   61303534393363616263666564636366303861623131306536316432383230393736
>>>>   $ ansible-vault view foo.yml
>>>>   test_var1: secret1
>>>>
>>>> See "Encrypting Unencrypted Files"
>>>>
>>>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-unencrypted-files
>>>>
>>>> 3) Create inventory (fit the groups and hosts to your needs)
>>>>
>>>>   $ cat hosts
>>>>   [test]
>>>>   test_01
>>>>
>>>> 4) Put the encrypted file into the directory host_vars (fit the host to
>>>> your
>>>> needs)
>>>>
>>>>   $ mkdir -p host_vars/test_01
>>>>   $ mv foo.yml host_vars/test_01/
>>>>
>>>> 5) Create and run playbook. See the variable was successfully decrypted.
>>>>
>>>>   $ cat test.yml
>>>>   - hosts: test_01
>>>> tasks:
>>>> - debug:
>>>> var: test_var1
>>>>   $ ansible-playbook test1.yml
>>>>   ok: [test_01] => { "test_var1": "secret1" }
>>>>
>>>> There are many variations how-to handle vault variables. If you have
>>>> troubles
>>>> report minimal, complete, reproducible example.
>>>>
>>>>
>>>> HTH,
>>>>
>>>> -vlado
>>>>
>>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P66fx-%3D8svSK_RW_DPgm6zB1J6tRRewDgk15sdbrfOj_w%40mail.gmail.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-23 Thread Srinivas Naram
Suggestions please.

On Wed, Jan 22, 2020 at 9:43 AM Srinivas Naram 
wrote:

> Any suggestions would be greatly appreciated.
>
> On Tue, Jan 21, 2020 at 8:05 PM Srinivas Naram 
> wrote:
>
>> Hello Vladimir
>>
>> I have followed exactly same steps mentioned above and I see different
>> errors now.
>>
>> My steps
>>
>> - Set the Ansible Vault password file Env variable
>> - Create the vault encrypted file
>> - Create directories and copy files in specific location. My dir structure
>> playbooks
>>|- vault
>>   |-testing.yml
>>   |-host_vars
>>|- 192.168.249.107
>> |- test.yml
>>
>> I get following error
>>
>> Error - ERROR! failed to combine variables, expected dicts but got a
>> 'dict' and a 'AnsibleUnicode':{} "testing123:sensitive"
>>
>> When I change the directory structure in host_vars to groupname
>> playbooks
>>|- vault
>>   |-testing.yml
>>   |-host_vars
>>|- ansible_enddevice_2
>> |- test.yml
>>
>> I get different message
>>
>> ok: [ 192.168.249.107 ] => { "testing123": "VARIABLE IS NOT DEFINED!" }
>>
>> My inventory file structure
>>
>> [ansible_enddevice_2]
>> 192.168.249.107
>>
>>
>>
>> On Tue, Jan 21, 2020 at 4:48 PM Vladimir Botka  wrote:
>>
>>> On Tue, 21 Jan 2020 15:31:33 +0530
>>> Srinivas Naram  wrote:
>>>
>>> > I am trying to maintain password (encrypted using ansible-vault) and my
>>> > playbook (clear-text) in separate files.
>>>
>>> Below is a step-by-step scenario:
>>>
>>> 1) Let's assume the vault password has bee configured properly (you have
>>> set
>>> the 'vault_password_file' in ansible.cfg) . Let's use global variable
>>> here.
>>> For example
>>>
>>>   $ set | grep VAULT
>>>   ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt
>>>
>>> See "Providing Vault Passwords"
>>>
>>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords
>>>
>>> 2) Create a file foo.yml with variable(s). Encrypt the file. See the
>>> content.
>>>
>>>   $ cat foo.yml
>>>   test_var1: secret
>>>   $ ansible-vault encrypt foo.yml
>>>   $ cat foo.yml
>>>   $ANSIBLE_VAULT;1.1;AES256
>>>
>>> 3933376636373537313366326361306331333132626337343335343465353439623366373338
>>>
>>> 6438306562323262363965653336653362616136366439620a326533316463346437373066333433
>>>
>>> 3035333662373330376261363963613833366631386531633064323733313936663831393731
>>>
>>> 3036633964323235310a613766346633613765643832306539346137613731663865636564636164
>>>   61303534393363616263666564636366303861623131306536316432383230393736
>>>   $ ansible-vault view foo.yml
>>>   test_var1: secret1
>>>
>>> See "Encrypting Unencrypted Files"
>>>
>>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-unencrypted-files
>>>
>>> 3) Create inventory (fit the groups and hosts to your needs)
>>>
>>>   $ cat hosts
>>>   [test]
>>>   test_01
>>>
>>> 4) Put the encrypted file into the directory host_vars (fit the host to
>>> your
>>> needs)
>>>
>>>   $ mkdir -p host_vars/test_01
>>>   $ mv foo.yml host_vars/test_01/
>>>
>>> 5) Create and run playbook. See the variable was successfully decrypted.
>>>
>>>   $ cat test.yml
>>>   - hosts: test_01
>>> tasks:
>>> - debug:
>>> var: test_var1
>>>   $ ansible-playbook test1.yml
>>>   ok: [test_01] => { "test_var1": "secret1" }
>>>
>>> There are many variations how-to handle vault variables. If you have
>>> troubles
>>> report minimal, complete, reproducible example.
>>>
>>>
>>> HTH,
>>>
>>> -vlado
>>>
>>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4rC1y2u_icMmZDJ9G3w0O4%3DKbPc4g6_%3DoHe8L%2BD6swPg%40mail.gmail.com.


Re: [ansible-project] ansible-playbook command prompt like yes/no while connecting to managed node for the first time

2020-02-19 Thread Srinivas Naram
In ansible.cfg try setting host_key_checking = false

On Thu, Feb 20, 2020 at 11:47 AM anilkumar panditi <
anilkumar.pand...@gmail.com> wrote:

> Hello, All
> My ansible-playbook  -i   -vv command prompt like
> yes/no while connecting to managed node for the first time. How can i avoid
> the prompting because i have aggregated all ansible-playbook commands in a
> shell script and running the shell script from UI.
>
> And playbook command prompt like yes/no while connecting to managed node
> for the first time, how can i avoid this.
>
> thanks
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/fbbfaef6-5ce0-4a38-91d5-05be5eca092f%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6eyu_qA-qeft%2Bz2bcmCCZxUZKbWnmdTkudUCGNVb4sug%40mail.gmail.com.


Re: [ansible-project] Re: How to configure prompt with 2 inputs

2020-01-13 Thread Srinivas Naram
Thanks for our reply Phil. It did not work though.

Any other suggestions ?

On Fri, Jan 10, 2020 at 10:25 PM Phil Griffiths 
wrote:

> try this?
>
>  name: reboot ios device
>   cli_command:
> command: reload
> prompt:
>   - Save?
>   - confirm
> answer:
>  - y
>  - y
>
>
>
> On Friday, 10 January 2020 14:28:23 UTC, Srinivas Naram wrote:
>>
>> Hello Gurus
>>
>> I am working on ios_command module. This modules facilitates in execute
>> commands on Cisco IOS devices.
>>
>> While running 'reload' command it is prompting for 2 inputs,
>>
>> "System configuration has been modified. Save? [yes/no]" > yes
>> "Proceed with reload? [confirm]   > return character here
>>
>> I tried using prompts, but looks like it does not support providing
>> answers for 2 questions in 1 command. Tried expect module (could not get
>> this working)
>>
>> Any suggestions?
>>
>> My code snippet:
>>
>> ios_command:
>>commands:
>>- command: 'reload'
>>  prompt:
>>  -  "System configuration has been modified. Save? [yes/no]"
>>  -  "Proceed with reload? [confirm]
>> answer:
>>- "\r"
>>- 'yes'
>>
>>
>>
>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5f7e1ebb-3cd3-4fa4-9d15-7814a9597e23%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/5f7e1ebb-3cd3-4fa4-9d15-7814a9597e23%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6a6Jee-mTLCAa5e1kf7torPhO%2BU4ucFkoPvg3cZ6SKqA%40mail.gmail.com.


Re: [ansible-project] Encrypted Password in Playbook

2020-01-21 Thread Srinivas Naram
Any suggestions would be greatly appreciated.

On Tue, Jan 21, 2020 at 8:05 PM Srinivas Naram 
wrote:

> Hello Vladimir
>
> I have followed exactly same steps mentioned above and I see different
> errors now.
>
> My steps
>
> - Set the Ansible Vault password file Env variable
> - Create the vault encrypted file
> - Create directories and copy files in specific location. My dir structure
> playbooks
>|- vault
>   |-testing.yml
>   |-host_vars
>|- 192.168.249.107
> |- test.yml
>
> I get following error
>
> Error - ERROR! failed to combine variables, expected dicts but got a
> 'dict' and a 'AnsibleUnicode':{} "testing123:sensitive"
>
> When I change the directory structure in host_vars to groupname
> playbooks
>|- vault
>   |-testing.yml
>   |-host_vars
>|- ansible_enddevice_2
> |- test.yml
>
> I get different message
>
> ok: [ 192.168.249.107 ] => { "testing123": "VARIABLE IS NOT DEFINED!" }
>
> My inventory file structure
>
> [ansible_enddevice_2]
> 192.168.249.107
>
>
>
> On Tue, Jan 21, 2020 at 4:48 PM Vladimir Botka  wrote:
>
>> On Tue, 21 Jan 2020 15:31:33 +0530
>> Srinivas Naram  wrote:
>>
>> > I am trying to maintain password (encrypted using ansible-vault) and my
>> > playbook (clear-text) in separate files.
>>
>> Below is a step-by-step scenario:
>>
>> 1) Let's assume the vault password has bee configured properly (you have
>> set
>> the 'vault_password_file' in ansible.cfg) . Let's use global variable
>> here.
>> For example
>>
>>   $ set | grep VAULT
>>   ANSIBLE_VAULT_PASSWORD_FILE=/home/admin/.vault_pass.txt
>>
>> See "Providing Vault Passwords"
>>
>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#providing-vault-passwords
>>
>> 2) Create a file foo.yml with variable(s). Encrypt the file. See the
>> content.
>>
>>   $ cat foo.yml
>>   test_var1: secret
>>   $ ansible-vault encrypt foo.yml
>>   $ cat foo.yml
>>   $ANSIBLE_VAULT;1.1;AES256
>>
>> 3933376636373537313366326361306331333132626337343335343465353439623366373338
>>
>> 6438306562323262363965653336653362616136366439620a326533316463346437373066333433
>>
>> 3035333662373330376261363963613833366631386531633064323733313936663831393731
>>
>> 3036633964323235310a613766346633613765643832306539346137613731663865636564636164
>>   61303534393363616263666564636366303861623131306536316432383230393736
>>   $ ansible-vault view foo.yml
>>   test_var1: secret1
>>
>> See "Encrypting Unencrypted Files"
>>
>> https://docs.ansible.com/ansible/latest/user_guide/vault.html#encrypting-unencrypted-files
>>
>> 3) Create inventory (fit the groups and hosts to your needs)
>>
>>   $ cat hosts
>>   [test]
>>   test_01
>>
>> 4) Put the encrypted file into the directory host_vars (fit the host to
>> your
>> needs)
>>
>>   $ mkdir -p host_vars/test_01
>>   $ mv foo.yml host_vars/test_01/
>>
>> 5) Create and run playbook. See the variable was successfully decrypted.
>>
>>   $ cat test.yml
>>   - hosts: test_01
>> tasks:
>> - debug:
>> var: test_var1
>>   $ ansible-playbook test1.yml
>>   ok: [test_01] => { "test_var1": "secret1" }
>>
>> There are many variations how-to handle vault variables. If you have
>> troubles
>> report minimal, complete, reproducible example.
>>
>>
>> HTH,
>>
>> -vlado
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4oxsd5pP-penfvwcKD7EZXmKLRgMCGY4dezCDSooOGNg%40mail.gmail.com.


[ansible-project] How to configure prompt with 2 inputs

2020-01-10 Thread Srinivas Naram
Hello Gurus

I am working on ios_command module. This modules facilitates in execute 
commands on Cisco IOS devices.

While running 'reload' command it is prompting for 2 inputs, 

"System configuration has been modified. Save? [yes/no]" > yes
"Proceed with reload? [confirm]   > return character here

I tried using prompts, but looks like it does not support providing answers 
for 2 questions in 1 command. Tried expect module (could not get this 
working)

Any suggestions?

My code snippet:

ios_command:
   commands:
   - command: 'reload'
 prompt:
 -  "System configuration has been modified. Save? [yes/no]" 
 -  "Proceed with reload? [confirm] 
answer:
   - "\r"
   - 'yes'


  

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/55decc88-5c4b-4e7a-a354-4f8a076384e7%40googlegroups.com.


Re: [ansible-project] Re: How to configure prompt with 2 inputs

2020-01-14 Thread Srinivas Naram
Thanks, that helped.

On Mon, Jan 13, 2020 at 9:55 PM Uriel  wrote:

> I think the only thing missing from @Phil's answer is check_all: True
>
> On Monday, January 13, 2020 at 2:51:48 AM UTC-6, Srinivas Naram wrote:
>>
>> Thanks for our reply Phil. It did not work though.
>>
>> Any other suggestions ?
>>
>> On Fri, Jan 10, 2020 at 10:25 PM Phil Griffiths 
>> wrote:
>>
>>> try this?
>>>
>>>  name: reboot ios device
>>>   cli_command:
>>> command: reload
>>> prompt:
>>>   - Save?
>>>   - confirm
>>> answer:
>>>  - y
>>>  - y
>>>
>>>
>>>
>>> On Friday, 10 January 2020 14:28:23 UTC, Srinivas Naram wrote:
>>>>
>>>> Hello Gurus
>>>>
>>>> I am working on ios_command module. This modules facilitates in execute
>>>> commands on Cisco IOS devices.
>>>>
>>>> While running 'reload' command it is prompting for 2 inputs,
>>>>
>>>> "System configuration has been modified. Save? [yes/no]" > yes
>>>> "Proceed with reload? [confirm]   > return character here
>>>>
>>>> I tried using prompts, but looks like it does not support providing
>>>> answers for 2 questions in 1 command. Tried expect module (could not get
>>>> this working)
>>>>
>>>> Any suggestions?
>>>>
>>>> My code snippet:
>>>>
>>>> ios_command:
>>>>commands:
>>>>- command: 'reload'
>>>>  prompt:
>>>>  -  "System configuration has been modified. Save?
>>>> [yes/no]"
>>>>  -  "Proceed with reload? [confirm]
>>>> answer:
>>>>- "\r"
>>>>- 'yes'
>>>>
>>>>
>>>>
>>>>
>>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/5f7e1ebb-3cd3-4fa4-9d15-7814a9597e23%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/5f7e1ebb-3cd3-4fa4-9d15-7814a9597e23%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/58df3013-6a9a-4aff-8ff2-233d0fcca48b%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/58df3013-6a9a-4aff-8ff2-233d0fcca48b%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6nA0PFeAUQSo1w3GiD6gTz30sAh8eRFE3e%2BF7qVEKZZg%40mail.gmail.com.


Re: [ansible-project] Playbook to reboot the machine infinite times

2020-04-16 Thread Srinivas Naram
Did you try using items ?

On Fri, Apr 17, 2020 at 11:07 AM Pavan Nr  wrote:

> Hi,
>
> Need help to create playbook, server need to reboot over night in loop,
> like 100 time's I need to reboot and It should stop and collect the event
> viewer logs.
>
> Do we have module already?
>
> Thanks,
> Pavan
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/9a9f36c2-5df1-4dbe-aaa1-4a47f5a6c766%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6%2Bpp9NyfepbdvMeXuOnQdXCD2sQui-4mWoswgWyC6abg%40mail.gmail.com.


Re: [ansible-project] telnet issue

2020-04-13 Thread Srinivas Naram
Some time back just to test telnet module, I tried telnet for devices which
had ssh as well as telnet access. However I was not successful and gave up.
If you get this working, kindly reply with the solution.

Thanks
Srinivas.

On Mon, Apr 13, 2020 at 1:44 PM Zaldy B  wrote:

> Hi Karl,
>
> Unfortunately, those devices that we have are old and uses telnet :)
>
> But other devices which are SSH enabled are being automated by ansible
>
> On Monday, April 13, 2020 at 4:05:53 AM UTC-4, Karl Auer wrote:
>>
>> Unless you have some specific reason for wanting to use telnet, the
>> obvious workaround is to use ssh instead
>>
>> Regards, K.
>>
>>
>> On Mon, Apr 13, 2020 at 5:51 PM Zaldy B  wrote:
>>
>>> Hi Karl,
>>>
>>> yes, I can connect to the device from my ansible server using telnet.  I
>>> can also connect to the device using my putty (outside of ansible) using
>>> telnet.
>>>
>>>
>>>
>>> On Monday, April 13, 2020 at 3:23:36 AM UTC-4, Karl Auer wrote:

 Can you connect to your IOS devices normally, i.e. outside Ansible?

 If yes, then I have no idea what's going on, but if not, get that
 working first before you try doing it with Ansible.

 Off the cuff theory is that the devices do not permit telnet
 connections...

 Regards, K.


 On Mon, Apr 13, 2020 at 5:07 PM Zaldy B  wrote:

> Hi Experts,
>
> I am just new with this one. I am trying to connect using telnet (ssh
> has no issue) to my IOS devices, but I am getting error when I run my
> playbook:
> --
>
>-
>
>name: Telnet do show version for IOS
>hosts: telnet_device
>gather_facts: false
>connection: local
>
>tasks:
>- name: show version
>   telnet:
>   user: cisco
>   password: cisco
>   login_prompt: "Username: "
>   prompts:
>   - "[>#]"
>   command:
>   - terminal length 0
>   - show version
>
> Error:
> PLAY [Telnet do show version for IOS]
> ***
>
> TASK [show version]
> *
> fatal: [telnet_device]: FAILED! => {"changed": true, "msg": "Telnet
> action failed: telnet connection closed", "output": []}
>
> PLAY RECAP
> **
> telnet_device : ok=0 changed=0 unreachable=0 failed=1 skipped=0
> rescued=0 ignored=0
>
>
>
> Any suggestions/comments is much appreciated.
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/60dd5a69-5a23-4c53-9bcf-08e5e8df6b44%40googlegroups.com
> 
> .
>


 --

 *Karl Auer* { manager, systems support }
 P: 1300 759 975
 E: ka...@2pisoftware.com
 2pisoftware.com

 GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
 Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E

>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/77abad3c-b5ad-45c5-a2e2-d5e8331f73b6%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>>
>> *Karl Auer* { manager, systems support }
>> P: 1300 759 975
>> E: ka...@2pisoftware.com
>> 2pisoftware.com
>>
>> GPG/PGP : DF6A 43E5 FB9D D884 C6CA CD7F 5278 212D E80F C107
>> Previous: 301B 1F4E 624D AD99 242C 7A68 EC24 7113 E854 4A4E
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6c9852f6-30a6-4326-b29a-d2d354a947f8%40googlegroups.com
> 

Re: [ansible-project] Playbook to reboot the machine infinite times

2020-04-17 Thread Srinivas Naram
https://docs.ansible.com/ansible/latest/plugins/lookup/items.html

On Fri, Apr 17, 2020 at 1:00 PM Pavan Nr  wrote:

> Hi Srinivas,
>
> i have not tried , can you share the links if possible.
>
> regards,
> Pavan
>
> On Friday, April 17, 2020 at 11:15:49 AM UTC+5:30, Srinivas Naram wrote:
>>
>> Did you try using items ?
>>
>> On Fri, Apr 17, 2020 at 11:07 AM Pavan Nr  wrote:
>>
>>> Hi,
>>>
>>> Need help to create playbook, server need to reboot over night in loop,
>>> like 100 time's I need to reboot and It should stop and collect the event
>>> viewer logs.
>>>
>>> Do we have module already?
>>>
>>> Thanks,
>>> Pavan
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/9a9f36c2-5df1-4dbe-aaa1-4a47f5a6c766%40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/9a9f36c2-5df1-4dbe-aaa1-4a47f5a6c766%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6d74ee75-c791-42bf-bdca-00cf491d7e84%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6d74ee75-c791-42bf-bdca-00cf491d7e84%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6AaC-P4A%3DJGNskLyAjNpTSY3K-2aVrNWwbvP4PJW_rFA%40mail.gmail.com.


Re: [ansible-project] Help with ios_command Module

2020-04-22 Thread Srinivas Naram
You can use ignore_errors=True

On Wed, Apr 22, 2020 at 6:48 PM Omar Hegazy 
wrote:

> Hello, i have 2 switches. I wanted to run a command (show arp) and check a
> specific output if exist or not on both. Then, i wanted to run a command
> (show arp) and display the output.
>
> The problem is that since the output i'm inspecting on first task doesn't
> exist on switch1  the next task (Display Output) is not performed for
> switch 1. i don't know why this dependency. I thought that there
> shouldn't be dependencies between tasks this way. How to overcome?
> --
>
>-
>
>hosts: SWITCHES
>
>tasks:
>-
>
>   name: run show and check to see if output contains value
>   ios_command:
>   commands: "show arp"
>   wait_for: result[0] contains aabb.cc00.3000
>   -
>
>   name: Get Shows
>   ios_command:
>   commands: "show arp"
>   register: Output
>   -
>
>   name: Display Output
>   debug:
>   msg: "{{ Output.stdout_lines[0] }}"
>
> Output:
>
> PLAY [SWITCHES]
> **
>
> TASK [run show version and check to see if output contains IOS]
> **
> ok: [switch2]
> fatal: [switch1]: FAILED! => {"changed": false, "failed_conditions":
> ["result[0] contains aabb.cc00.3000"], "msg": "One or more conditional
> statements have not been satisfied"}
>
> TASK [Get Shows]
> *
> ok: [switch2]
>
> TASK [Display Output]
> 
> ok: [switch2] => {
> "msg": [
> "Protocol Address Age (min) Hardware Addr Type Interface",
> "Internet 192.168.0.1 0 342c.c4ad.9a81 ARPA Ethernet0/0",
> "Internet 192.168.0.157 - aabb.cc00.3000 ARPA Ethernet0/0",
> "Internet 192.168.0.248 0 d4d2.5287.83ef ARPA Ethernet0/0"
> ]
> }
>
> PLAY RECAP
> ***
> switch1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0
> ignored=0
> switch2 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
> ignored=0
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2a134fb2-ebd2-46a7-b3a8-f141d95b4fef%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5Twu%2Bb2%3DaaAN_cd042KQhVDPdhR5hRSX5cT_DFfhD3QA%40mail.gmail.com.


Re: [ansible-project] Ansible not accepting When condition

2020-07-02 Thread Srinivas Naram
when is indented too much. Put it at the level where module name is
mentioned.

---
- name: using multiple conditions
  gather_facts: yes
  hosts: localhost
  connection: local
  tasks:
- package:
name: httpd
state: installed
  when:
- ansible_distribution == "RedHat"
- ansible_memfree_mb > 1512

On Thu, Jul 2, 2020 at 7:21 PM Jenisha T  wrote:

> Hi everyone,
> Below is my playbook
>
> ---
> - name: using multiple conditions
>   gather_facts: yes
>   hosts: localhost
>   connection: local
>   tasks:
> - package:
> name: httpd
> state: installed
> when:
>   - ansible_distribution == "RedHat"
>   - ansible_memfree_mb > 1512
>
> When I run this playbook I get below error
>
> https://pastebin.com/embed_iframe/BVRZKc5K;
> style="border:none;width:100%">
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/47b62adb-87ae-451c-b077-3cfeff5be26en%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5vRTJsf%2BveHerV5NrxX8%3D0FD0%3DQAFg%2BwAw4pzQbDvuiw%40mail.gmail.com.


Re: [ansible-project] Re: string not recognised in groups_vars/all

2020-06-30 Thread Srinivas Naram
Check out the syntax of 'all' file. I feel the indentation is not right.

On Tue, Jun 30, 2020 at 5:29 PM Johana Galarza Monta 
wrote:

> but that doesnt't respond to my answer on why this works when it is in the
> playbook... and not when it is in groups-vars
>
> On Tuesday, 30 June 2020 12:28:56 UTC+2, Johana Galarza Monta wrote:
>>
>> I have a the below in my groups vars, and in a role I am trying to add a
>> conditional on `module-a` such as when: " 'module-a' in module" but keeps
>> throwing me this error
>>
>> {"msg": "The conditional check ' 'module-a' in modules' failed. The error
>> was: error while evaluating conditional ( 'module-a' in modules): Unable to
>> look up a name or access an attribute in template string ({% if  'module-a
>> in modules %} True {% else %} False {% endif %}).\nMake sure your variable
>> name does not contain invalid characters like '-': argument of type
>> 'AnsibleUndefined' is not iterable.
>>
>>  but somehow it works when I put this in the playbook itself...
>>
>> Did anyone had such an issue? Or any idea why this works on the
>> playbook but not under gorup_vars/all...??
>>
>>  vars:
>>  module:
>> - module-a
>>
>>
>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e22740d1-18cb-4918-ae95-2f3df3ed0f21o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6RF-aU7wo5UP_JnSt1toJuc3uAJ9B194aQxs%2B5x6i56A%40mail.gmail.com.


Re: [ansible-project] Ansible Command is not completing in playbook

2020-07-08 Thread Srinivas Naram
What errors are you seeing when playbook exits ?

I presume that you are seeing a timeout error. This is because tcpdump is
taking too long to fill the file.

following link might help -
https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#timeout-issues

On Wed, Jul 8, 2020 at 12:22 PM Jitendra Deshmukh <
jitendra.deshmu...@gmail.com> wrote:

> Hi have play book to run tcpdump, play run simple command of tcpdump but
> the command is not getting completed and stuck in play book though command
> is running sucessfully on remote host but playbook not proceeding to next
> task,
>
> below is the play
>
>  - name: run non-local
>   command: tcpdump -n -i {(Interface}} host {{destination}} -s
> {{snaplen}} -C {{Filesize}} -W {{Filesize}} -w
> {{Path}}${HOSTNAME}_eth1.pcap -Z root
>   when: inventory_hostname == item and Destination_host != "local"
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/87a86422-ec84-439d-975d-e6d4feac6adao%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6y8h-kgMKvicYVYU8wngjcnS%3D1u6W_q-ZKZEaprSNqEg%40mail.gmail.com.


Re: [ansible-project] How to split value from list

2020-07-06 Thread Srinivas Naram
Did you try this ?

 user_name: "{{ my_string[0].split(':')[0] }}"

On Tue, Jul 7, 2020 at 10:52 AM Karl Auer  wrote:

> so what's wrong with:
>
> USR="jenisha"
> FOUND=`grep $USR /etc/passwd | cut -d: -f1`
> if [ -z "$FOUND" ] ; then
>echo "No such user: $USR"
> else
># do whatever...
> fi
>
> ?
>
> Regards, K.
>
>
> On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:
>
>> In my case cut doesn't work. I m searching for a particular user from a
>> password.
>> $ grep anil /etc/passwd
>>
>>
>> Best Regards
>> Jenisha T
>> Whatsapp: +91 07598087866
>>
>>
>>
>>
>>
>> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
>> wrote:
>>
>>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>>> > Hello Jenisha,
>>> >
>>> > Assuming that you are getting this value from /etc/passwd., try to
>>> change you command
>>> >
>>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>>> >
>>>
>>> cut -d : -f 1 is more concise and readable than your awk command.
>>>
>>> Otherwise I would really like to know why Jenisha resorts to reading the
>>> password file.
>>>
>>> Regards
>>>  racke
>>>
>>>
>>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser >> <mailto:dick.vis...@geant.org>> wrote:
>>> >
>>> > you should either use set_fact, or register. Both doesn't make
>>> sense.
>>> >
>>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T >> joyj...@gmail.com>> wrote:
>>> > >
>>> > > Hi
>>> > > Could you pls help me with the splitting value from the list. I
>>> need to extract first value anil before ('':')
>>> > >
>>> > >  grep_atm.stdout_lines output below
>>> > >
>>> > > ok: [localhost] => {
>>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>>> > > "
>>> > > }
>>> > >
>>> > > I tried,
>>> > > - set_fact:
>>> > >user_name: "{{ grep_atm.stdout_lines }}"
>>> > > register: user_name.split(':')[0]
>>> > >  - debug:
>>> > > var: user_name.split(':')[0]
>>> > >
>>> > > --
>>> > > 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 >> ansible-project%2bunsubscr...@googlegroups.com>.
>>> > > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>>> .
>>> >
>>> >
>>> >
>>> > --
>>> > Dick Visser
>>> > Trust & Identity Service Operations Manager
>>> > GÉANT
>>> >
>>> > --
>>> > 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 >> ansible-project%2bunsubscr...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>>> .
>>> >
>>> > --
>>> > 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 >> ansible-project+unsubscr...@googlegroups.com>.
>>> > To view this discussion on the web visit
>>> >
>>> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
>>> > <
>>> https://groups.google.com/d/msgid/ansible-proj

Re: [ansible-project] How to split value from list

2020-07-07 Thread Srinivas Naram
How do we incorporate if-else in set_fact ?

On Tue, Jul 7, 2020 at 11:26 AM Jenisha T  wrote:

> This logic works. Thankyou
>
> On Tuesday, 7 July 2020 at 10:52:51 UTC+5:30 Karl Auer wrote:
>
>> so what's wrong with:
>>
>> USR="jenisha"
>> FOUND=`grep $USR /etc/passwd | cut -d: -f1`
>> if [ -z "$FOUND" ] ; then
>>echo "No such user: $USR"
>> else
>># do whatever...
>> fi
>>
>> ?
>>
>> Regards, K.
>>
>>
>> On Tue, Jul 7, 2020 at 3:11 PM T. JENISHA  wrote:
>>
>>> In my case cut doesn't work. I m searching for a particular user from a
>>> password.
>>> $ grep anil /etc/passwd
>>>
>>>
>>> Best Regards
>>> Jenisha T
>>> Whatsapp: +91 07598087866 <+91%2075980%2087866>
>>>
>>>
>>>
>>>
>>>
>>> On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) 
>>> wrote:
>>>
>>>> On 7/6/20 3:32 PM, Srinivas Naram wrote:
>>>> > Hello Jenisha,
>>>> >
>>>> > Assuming that you are getting this value from /etc/passwd., try to
>>>> change you command
>>>> >
>>>> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
>>>> >
>>>>
>>>> cut -d : -f 1 is more concise and readable than your awk command.
>>>>
>>>> Otherwise I would really like to know why Jenisha resorts to reading
>>>> the password file.
>>>>
>>>> Regards
>>>>  racke
>>>>
>>>>
>>>> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser >>> <mailto:dick@geant.org>> wrote:
>>>> >
>>>> > you should either use set_fact, or register. Both doesn't make
>>>> sense.
>>>> >
>>>> > On Mon, 6 Jul 2020 at 13:44, Jenisha T >>> joy...@gmail.com>> wrote:
>>>> > >
>>>> > > Hi
>>>> > > Could you pls help me with the splitting value from the list. I
>>>> need to extract first value anil before ('':')
>>>> > >
>>>> > >  grep_atm.stdout_lines output below
>>>> > >
>>>> > > ok: [localhost] => {
>>>> > > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
>>>> > > "
>>>> > > }
>>>> > >
>>>> > > I tried,
>>>> > > - set_fact:
>>>> > >user_name: "{{ grep_atm.stdout_lines }}"
>>>> > > register: user_name.split(':')[0]
>>>> > >  - debug:
>>>> > > var: user_name.split(':')[0]
>>>> > >
>>>> > > --
>>>> > > 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-proje...@googlegroups.com >>> ansible-project%2bunsu...@googlegroups.com>.
>>>> > > To view this discussion on the web visit
>>>> >
>>>> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
>>>> .
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > Dick Visser
>>>> > Trust & Identity Service Operations Manager
>>>> > GÉANT
>>>> >
>>>> > --
>>>> > 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-proje...@googlegroups.com >>> ansible-project%2bunsu...@googlegroups.com>.
>>>> > To view this discussion on the web visit
>>>> >
>>>> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
>>>> .
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>&g

Re: [ansible-project] cisco ios connect ssh error

2020-07-07 Thread Srinivas Naram
Are you able to connect to Cisco Switch from Ansible server via ssh ? The
error says 'Connection Error'.

On Tue, Jul 7, 2020 at 1:03 PM Sandy Hung  wrote:

> I connect cisco switch run playbook show error msg
> please help thanks.
> fatal: [tpesw-01]: FAILED! => {
> "ansible_facts": {},
> "changed": false,
> "failed_modules": {
> "ios_facts": {
> "exception": "WARNING: The below traceback may *not* be
> related to the actual failure.\n  File
> \"/tmp/ansible_ios_facts_payload_8veYSP/ansible_ios_facts_payload.zip/ansible/module_utils/network/common/network.py\",
> line 229, in get_capabilities\ncapabilities =
> Connection(module._socket_path).get_capabilities()\n  File
> \"/tmp/ansible_ios_facts_payload_8veYSP/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\",
> line 185, in __rpc__\nraise ConnectionError(to_text(msg,
> errors='surrogate_then_replace'), code=code)\n",
> "failed": true,
> "invocation": {
> "module_args": {
> "auth_pass": null,
> "authorize": null,
> "gather_network_resources": null,
> "gather_subset": [
> "all"
> ],
> "host": null,
> "password": null,
> "port": null,
> "provider": null,
> "ssh_keyfile": null,
> "timeout": null,
> "username": null
> }
> },
> "msg": "[Errno -2] Name or service not known"
> }
> },
> "msg": "The following modules failed to execute: ios_facts\n"
> }
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7bf542cc-2a7a-45ba-b94d-9332327f7e6bn%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4jR8-OoF80TbjoYo42F7BgFUaZ7cTCvRLevRXudjiT2Q%40mail.gmail.com.


Re: [ansible-project] cisco ios connect ssh error

2020-07-07 Thread Srinivas Naram
Username, Password is null. How are you passing user credentials ?

Would it be possible to share playbook ?

On Tue, Jul 7, 2020 at 2:50 PM  wrote:

> Yes , I can connect ssh,but still show error
>
>
>
>
>
> “ssh sandy@
>
> Password:
>
>
>
>---  Global Limited ---
>
>
>
>   Unauthorized access is strictly prohibited *** tpesw-01#
>
> tpesw-01#   “
>
>
>
>
>
> fatal: [tpesw-01]: FAILED! => {
>
> "ansible_facts": {},
>
> "changed": false,
>
> "failed_modules": {
>
> "ios_facts": {
>
> "exception": "WARNING: The below traceback may *not* be
> related to t he actual failure.\n  File
> \"/tmp/ansible_ios_facts_payload_NZrxLz/ansible_ios_f
> acts_payload.zip/ansible/module_utils/network/common/network.py\", line
> 229, in  get_capabilities\ncapabilities =
> Connection(module._socket_path).get_capabil
> ities()\n  File
> \"/tmp/ansible_ios_facts_payload_NZrxLz/ansible_ios_facts_payloa
>  d.zip/ansible/module_utils/connection.py\", line 185, in
> __rpc__\nraise Conn ectionError(to_text(msg,
> errors='surrogate_then_replace'), code=code)\n",
>
> "failed": true,
>
> "invocation": {
>
> "module_args": {
>
> "auth_pass": null,
>
> "authorize": null,
>
> "gather_network_resources": null,
>
> "gather_subset": [
>
> "all"
>
> ],
>
> "host": null,
>
> "password": null,
>
> "port": null,
>
> "provider": null,
>
>     "ssh_keyfile": null,
>
> "timeout": null,
>
> "username": null
>
> }
>
> },
>
> "msg": "[Errno -2] Name or service not known"
>
> }
>
> },
>
> "msg": "The following modules failed to execute: ios_facts\n"
>
> }
>
> BR
>
>
>
>
>
> Sandy
>
>
>
> *From:* ansible-project@googlegroups.com 
> *On Behalf Of *Srinivas Naram
> *Sent:* Tuesday, July 7, 2020 3:49 PM
> *To:* ansible-project@googlegroups.com
> *Subject:* Re: [ansible-project] cisco ios connect ssh error
>
>
>
> Are you able to connect to Cisco Switch from Ansible server via ssh ? The
> error says 'Connection Error'.
>
>
>
> On Tue, Jul 7, 2020 at 1:03 PM Sandy Hung  wrote:
>
> I connect cisco switch run playbook show error msg
>
> please help thanks.
>
> fatal: [tpesw-01]: FAILED! => {
>
> "ansible_facts": {},
>
> "changed": false,
>
> "failed_modules": {
>
> "ios_facts": {
>
> "exception": "WARNING: The below traceback may *not* be
> related to the actual failure.\n  File
> \"/tmp/ansible_ios_facts_payload_8veYSP/ansible_ios_facts_payload.zip/ansible/module_utils/network/common/network.py\",
> line 229, in get_capabilities\ncapabilities =
> Connection(module._socket_path).get_capabilities()\n  File
> \"/tmp/ansible_ios_facts_payload_8veYSP/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py\",
> line 185, in __rpc__\nraise ConnectionError(to_text(msg,
> errors='surrogate_then_replace'), code=code)\n",
>
> "failed": true,
>
> "invocation": {
>
> "module_args": {
>
> "auth_pass": null,
>
> "authorize": null,
>
> "gather_network_resources": null,
>
> "gather_subset": [
>
> "all"
>
> ],
>
> "host": null,
>
> "password": null,
>
> "port": null,
>
> "provider": null,
>
> "ssh_keyfile": null,
>
> "timeout": null,
>
> "username": null
>
> }
>
> },
>
> 

Re: [ansible-project] How to split value from list

2020-07-06 Thread Srinivas Naram
Hello Jenisha,

Assuming that you are getting this value from /etc/passwd., try to change
you command

 tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'

On Mon, Jul 6, 2020 at 6:35 PM Dick Visser  wrote:

> you should either use set_fact, or register. Both doesn't make sense.
>
> On Mon, 6 Jul 2020 at 13:44, Jenisha T  wrote:
> >
> > Hi
> > Could you pls help me with the splitting value from the list. I need to
> extract first value anil before ('':')
> >
> >  grep_atm.stdout_lines output below
> >
> > ok: [localhost] => {
> > "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> > "
> > }
> >
> > I tried,
> > - set_fact:
> >user_name: "{{ grep_atm.stdout_lines }}"
> > register: user_name.split(':')[0]
> >  - debug:
> > var: user_name.split(':')[0]
> >
> > --
> > 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
>
>
>
> --
> Dick Visser
> Trust & Identity Service Operations Manager
> GÉANT
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com.


Re: [ansible-project] ansible check and diff mode not working

2020-07-15 Thread Srinivas Naram
Hello Shyam

It is how the output is displayed. In your output updates are showing the
difference in running config and your cfg file.

"updates": [
"configure ntp server add x.x.x.x"
],

I don't see any issue with the output. Did you try changing the ntp setting
on the device yourself and check out the difference in output ?

On Tue, Jul 14, 2020 at 11:16 PM Shyam Sunder 
wrote:

> Hi,
>
>
> I was going thru this post (
> https://blog.networktocode.com/post/generating-diff-with-ansible/) where
> its mentioned that we can use check and diff mode together. I am trying to
> use that for gold config audit (audit pre decided config against what is
> present on device) for Cisco and Extreme devices. Below is my playbook –
>
>
> # task to audit & heal ntp configuration
> - name: Set NTP template
>   ios_config:
>  src: "{{domain}}_{{ansible_network_os}}_ntp.cfg"
>  match: line
>   register: ntp_result
>
>
> Below is my template -
>
> ntp server 10.19.70.1
>
> *Ansible highlighting that it is going to change the config. Below is what
> result I am getting. Surprisingly I am not getting any config diff.*
>
>
> "ntp_result": {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": true,
> "commands": [
> "configure ntp server add x.x.x.x"
> ],
> "failed": false,
> "updates": [
> "configure ntp server add x.x.x.x"
> ],
> "warnings": [
> "unable to perform diff against running-config due to check
> mode"
> ]
> }
>
>
>
> *Why I am not getting config diff? Any idea what is wrong?*
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cc54e580-7642-4c51-a093-4a691b85cd2fo%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P6SRZp66MWxSQjcodyZF8Mj73k9ePzKArGFmH9Tdn6mqg%40mail.gmail.com.


Re: [ansible-project] Re: Need to add A record and PRT recored in Cisco switches

2020-07-15 Thread Srinivas Naram
Hello

Can you elaborate your issue and explain the steps taken so far.


On Wed, Jul 15, 2020 at 2:21 PM Balayuvaraj Magudapathi <
bala08yuva...@gmail.com> wrote:

> Hi,
>
> Can any help on this
>
>
>
> On Monday, 13 July 2020 16:48:40 UTC+5:30, Balayuvaraj Magudapathi wrote:
>>
>> Hey,
>>
>> In my environment i need to add a record and prt record in cisco switches
>> for 800 devices.
>>
>> Some share the docs for this project
>>
>> component Name : network module , cisco
>>
>>
>> Thanks
>>
>> Balayuvaraj
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b7c5fe8e-976d-4033-9eac-a24627a3b297o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P7CgtmQcODH6%2BnqxZQJkUt4M9nuwMcXgODo52JP4tXQEw%40mail.gmail.com.


Re: [ansible-project] Need help with registered variable

2020-07-10 Thread Srinivas Naram
Try by removing  quotes

result[results][0].content.data

On Fri, Jul 10, 2020 at 8:04 PM Rahul Kumar  wrote:

> Thanks Abhijeet ! I tried even result[‘results’][0].content.data but still
> it complains results is not dict attribute !
>
> On Fri, 10 Jul 2020 at 5:32 PM, Abhijeet Kasurde 
> wrote:
>
>> 'data' is inside 'content' you might want to check around that
>>
>>
>> On Fri, Jul 10, 2020 at 5:24 PM Rahul Kumar 
>> wrote:
>>
>>> I have a task output like this:
>>> - name: Print Response of status resource
>>>   debug:
>>> msg: " {{ result }}"
>>>
>>> ok: [node-3] => {
>>> "msg": " {'msg': u'All items completed', 'changed': False,
>>> 'results': [{'ansible_loop_var': u'item', 'failed': False, 'changed':
>>> False, u'content': {u'body': None, u'node': u'node-3',
>>> u'allServicesLocked': True, u'appServer': u'1', u'type': u'iMIME', u'data':
>>> True,]} "
>>> }
>>>
>>> But when i try to access like that in some task, it does not work:
>>> until : result['results'].data == True   , it complains saying dict does
>>> not have results attribute !
>>> Here result is my registered variable. As per above response , it should
>>> work fine ?
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/CAGH8rEyOHqmrA7diB3AznLqRncRaj_r539gA5-oZpkEwMrzwCA%40mail.gmail.com
>>> 
>>> .
>>
>>
>>>
>>
>> --
>> Thanks,
>> Abhijeet Kasurde
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAFwWkHpb0WcE8jKLcPsM2i1mzA_PX%2BGBRF7Jtefqtmp4wFC6Sw%40mail.gmail.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGH8rEwgRWxNLYf1WaxNyqb7e0gmEDyC4nMZnw_0wwUJa32_ew%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P7fK4PGzb7OKmfSyvsSB9tLSmipVNLoPW%3DPdfe7EwGzTA%40mail.gmail.com.


Re: [ansible-project] Regular Expression in ANSIBLE

2020-07-02 Thread Srinivas Naram
Hello - is this log file located in the server where Ansible is installed
or remote server ?

On Thu, Jul 2, 2020 at 5:25 AM Jenisha T  wrote:

> Hi
> I have output from log file as below. I need to extract the string shown
> in bold.
>
>  Communication Diagnostic Report
>
> ---
>
>
> User Name : username
>
> Directory : /path/to/dir
>
> Platform Architecture : Linux
>
> Version : x.0.00.x
>
> Host Name : abcdef1234
>
> Logical Name : *abcdef1234*
>
> Listen to Network Interface : *ANY
>
>
> processes status
>
> ==
>
> Listener : *Running as root *
>
>
> How to extract the value of Logical Name : *abcdef1234 *
>
> from the multiline string.
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cbdb83e6-d7b4-42ec-8d23-408736d0aeb2n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4X4NPOv%2B_QxQLtvELH%3DDomxCWr0weNY%2Bh1vLZnE7Pi3Q%40mail.gmail.com.


Re: [ansible-project] Regular Expression in ANSIBLE

2020-07-02 Thread Srinivas Naram
Not sure how you are initiating your playbooks. Here is what I did.

I initiated my playbooks from a shell script and parsed the output in the
script.

On Thu, Jul 2, 2020 at 2:03 PM Jenisha T  wrote:

>
> It's present in a remote server where the playbook is executed. I m facing
> the problem with extraction. Text present in register.
>
> On Thursday, 2 July 2020 at 12:41:37 UTC+5:30 sriniva...@gmail.com wrote:
>
>> Hello - is this log file located in the server where Ansible is installed
>> or remote server ?
>>
>> On Thu, Jul 2, 2020 at 5:25 AM Jenisha T  wrote:
>>
>>> Hi
>>> I have output from log file as below. I need to extract the string shown
>>> in bold.
>>>
>>>  Communication Diagnostic Report
>>>
>>> ---
>>>
>>>
>>> User Name : username
>>>
>>> Directory : /path/to/dir
>>>
>>> Platform Architecture : Linux
>>>
>>> Version : x.0.00.x
>>>
>>> Host Name : abcdef1234
>>>
>>> Logical Name : *abcdef1234*
>>>
>>> Listen to Network Interface : *ANY
>>>
>>>
>>> processes status
>>>
>>> ==
>>>
>>> Listener : *Running as root *
>>>
>>>
>>> How to extract the value of Logical Name : *abcdef1234 *
>>>
>>> from the multiline string.
>>>
>>>
>>> --
>>> 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-proje...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/cbdb83e6-d7b4-42ec-8d23-408736d0aeb2n%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/59adf33c-d9c4-4d74-83fc-2e07d2d8e5adn%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4Khqov%2B3OvwLLig6-s8sEiiGsS23KuhKMS%2BoHB7668hw%40mail.gmail.com.


Re: [ansible-project] How to structure variables to distinguish different environments

2020-07-02 Thread Srinivas Naram
There could be some distinction between both the environments. Can you use
gather_facts and get the differentiating value ?

if you are able to get it using gather_facts, you can use set_facts

Example

set_facts:
   nfs_server: xyx
when: ansible_distribution= 'CentOS'

set_fact:
   nfs_server: abc
when: ansible_distribution ='Ubuntu'

On Thu, Jul 2, 2020 at 12:26 AM Xinhuan Zheng 
wrote:

> Hello,
>
> I want to define a variable for playbook in *group_vars/server_genre*
> file. However, I don't know if Ansible can support something like
> server_genre@environment syntax notation. Here is the detail:
>
> *In inventory/environment*:
> ---
> [server_genre]
> myserver1.example.com
>
> *In group_vars/server_genre:*
> ---
> nfs_server: mynfsserver1.example.com
>
> *In server_genre.yml playbook:*
> ---
> - name: Playbook for server_genre
>   hosts: server_genre
>   gather_facts: yes
>
>   tasks:
>
>   - name: Install Nfs client
> package:
>   name: nfs-utils
>   state: present
>   - name: mount nfs
> mount:
>   path: /mymount
>   src: "{{ nfs_server }}"
>   fstype: nfs
>   opts: ro
>   state: mounted
>
> In a different environment, the variable {{ nfs_server }} will have
> different value, however, I can't separate the different values using one
> single group_var/server_genre file, unless Ansible supports something like
> group_vars/server_genre@enviornment.
>
> How do I accomplish the variable value distinction in my case?
>
> Thanks,
>
> - Xinhuan
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/96edc459-2fec-4626-b7ac-2dae6d330505o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5BygF3JiJAa6LXsMJ4798w6kH5OtVYJtRg5U-7uHnQog%40mail.gmail.com.


Re: [ansible-project] Re: ansible debug troubleshooting - script failing

2020-07-09 Thread Srinivas Naram
https://docs.ansible.com/ansible/latest/user_guide/connection_details.html

On Thu, Jul 9, 2020 at 8:36 AM stack flow  wrote:

> Thx. I was able to ssh from command line so this isn't network issue. is
> it because of python?
>
> TASK [show hostname]
> 
> Wednesday 08 July 2020  21:12:10 -0400 (0:00:00.090)   0:00:00.090
> 
> *[WARNING]: Platform darwin on host iosv-2 is using the discovered Python
> interpreter at /usr/bin/python, but future installation*
> *of another Python interpreter could change this. See*
> *https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html
> 
>  for
> more information.*
> *fatal: [iosv-2]: FAILED! => {"ansible_facts":
> {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false,
> "msg": "[Errno None] Unable to connect to port 22 on 10.10.100.31"}*
>
>
>  is it because of python? see below.
>
> *ljamm@ljamm 2_templates_conditionals % ansible --version*
> *ansible 2.9.10*
> *  config file = /etc/ansible/ansible.cfg*
> *  configured module search path =
> ['/Users/ljamm/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']*
> *  ansible python module location =
> /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible*
> *  executable location =
> /Library/Frameworks/Python.framework/Versions/3.7/bin/ansible*
> *  python version = 3.7.7 (v3.7.7:d7c567b08f, Mar 10 2020, 02:56:16)
> [Clang 6.0 (clang-600.0.57)]*
> *ljamm@ljamm 2_templates_conditionals %*
> *ljamm@ljamm 2_templates_conditionals % python --version*
> *Python 2.7.16*
> *ljamm@ljamm 2_templates_conditionals %*
>
> On Wednesday, July 8, 2020 at 10:24:30 PM UTC-4, ameya agashe wrote:
>>
>> This is a network related issue, and not related to ansible:
>>
>> *Unable to connect to port 22 on 10.10.100.31"*
>>
>> From Ansible controller try to ping or do telnet on the above machine on
>> port 22 and past the output here.
>>
>> Example:
>> telnet 10.10.100.31 22
>>
>> You are not able to reach that machine, that is causing the grief.
>>
>> Regards,
>> Ameya
>>
>>
>> On Thursday, 9 July 2020 11:14:09 UTC+10, stack flow wrote:
>>>
>>> I also keep on getting following msgs:
>>>
>>> TASK [show hostname]
>>> 
>>> Wednesday 08 July 2020  21:12:10 -0400 (0:00:00.090)   0:00:00.090
>>> 
>>> *[WARNING]: Platform darwin on host iosv-2 is using the discovered
>>> Python interpreter at /usr/bin/python, but future installation*
>>> *of another Python interpreter could change this. See*
>>> *https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html
>>> 
>>> for more information.*
>>> *fatal: [iosv-2]: FAILED! => {"ansible_facts":
>>> {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false,
>>> "msg": "[Errno None] Unable to connect to port 22 on 10.10.100.31"}*
>>>
>>>
>>> On Wednesday, July 8, 2020 at 9:09:33 PM UTC-4, stack flow wrote:


 Hello, I am new to ansible and its troubleshooting. my ansible script
 is failing. below is output. could you advise why is the script failing?




 *<10.10.100.59> attempting to start connection*
 *<10.10.100.59> using connection plugin network_cli*
 *<10.10.100.31> attempting to start connection*
 *<10.10.100.31> using connection plugin network_cli*
 *<10.10.100.59> local domain socket does not exist, starting it*
 *<10.10.100.59> control socket path is
 /Users/ljamm/.ansible/pc/f58522fe09*
 *<10.10.100.59> local domain socket listeners started successfully*
 *<10.10.100.31> local domain socket does not exist, starting it*
 *<10.10.100.59> loaded cliconf plugin ios from path
 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/plugins/cliconf/ios.py
 for network_os ios*
 *<10.10.100.31> control socket path is
 /Users/ljamm/.ansible/pc/91c938f5a6*
 *<10.10.100.59>*
 *<10.10.100.31> local domain socket listeners started successfully*
 *<10.10.100.59> local domain socket path is
 /Users/ljamm/.ansible/pc/f58522fe09*
 *<10.10.100.31> loaded cliconf plugin ios from path
 /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/plugins/cliconf/ios.py
 for network_os ios*
 *<10.10.100.31>*
 *<10.10.100.31> local domain socket path is
 /Users/ljamm/.ansible/pc/91c938f5a6*
 *[WARNING]: Ignoring timeout(10) for ios_facts*
 *[WARNING]: Ignoring timeout(10) for ios_facts*
 * Attempting python interpreter discovery*
 * Attempting python interpreter discovery*
 *<10.10.100.59> 

Re: [ansible-project] Sending ansible output to python function

2020-06-11 Thread Srinivas Naram
Did you try to initiate Ansible playbook from Python code and capture
Ansible output directly in the Python code ?

You can use os module for it. Try using os.system('ansible-playbook
 wrote:

> Hello,
>
> I have posted the following at
> https://stackoverflow.com/questions/62309274/how-to-have-ansible-send-output-to-a-python-function-in-a-custom-library,
> but I wanted to share here to get some more insight.
>
> I am a newbie at working with Ansible and Python and I am attempting to
> develop an Ansible playbook that will query several Cisco ASR5500's running
> current iOS software for CLI output of various show commands. I would like
> to take that output and send it to a python function in a custom library
> which will apply logic to see if the response from the ASR shows that it is
> healthy or not. Currently, I am sending the Ansible output to a file with
> the thought of having Python read the file and analyze each line. Here is a
> snippet from my playbook:
>
> - name: show card table # run "show card table" on node
>   ios_command:
> commands:
>   - show card table
>   register: output_cardTable- name: send output_cardTable to file # 
> send "show card table" to file
>   lineinfile:
> dest: /home/**my_user**/testoutput/{{ inventory_hostname }}_{{ my_time }}
> line: "{{ output_cardTable.stdout_lines }}"
> insertafter: EOF
>
> This snippet takes the output of "show card table" and sends it to a
> timestamped file as a multi-dimensional array (not sure why it's formatted
> like that, but that's another question for later). My first thought was to
> have Ansible run the checks and then have Python read the generated files
> for each node and apply its logic to determine the node's health.
>
>
> However, I would like to know if there is a way for Ansible to send the
> output of the task directly to a function in a imported Python library,
> similar to how RobotFramework can invoke a Python function from a library
> that has been declared. I do not know if such syntax exists, but Ansible is
> better at maintaining connections to multiple nodes concurrently, and
> RobotFramework is not the tool of choice for my organization.
>
>
> So, how would I write the task that sends the "output_cardTable" content
> to a python function, and how would I declare that function library in the
> header of the playbook so Ansible can see and use it?
>
>
> Any insight would be appreciated. Thank you.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6df3edc0-ac47-4c4d-92de-1ca1eadcd722o%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P7tCdat2ordierVDh6DOzbRdUPZUEPnNKVMXMbrPGUkYw%40mail.gmail.com.


Re: [ansible-project] Accessing Network Devices via Jump Hosts

2020-06-12 Thread Srinivas Naram
I have a similar question. In one of the environment, Application server
(in which ansible is installed) is located in Green network and actual
network devices are located in Red Network. Connection from Green network
to Red Network is only by a VPN connection. Is there a possibility in
Ansible to connect from Green net to red net via VPN ?

On Thu, Jun 11, 2020 at 11:40 PM Dick Visser  wrote:

>
> https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-configure-a-jump-host-to-access-servers-that-i-have-no-direct-access-to
>
>
> On Thu, 11 Jun 2020 at 19:17, Ashwajit Bhoutkar <
> bhoutkarashwa...@gmail.com> wrote:
>
>> Hi,
>>
>>
>> I've a general question related to Ansible for accessing the network
>> devices. While going through the ansible documentations, I understood that
>> the control host is directly connected to the network elements and send the
>> commands for configurations. However, in real world scenarios, these
>> network devices via a jump host, i.e the case in which the control machine
>> has to login to a linux machine first and from this linux machine, they ssh
>> is to be done to network devices. Is there a way to achieve this using
>> ansible?
>>
>>
>>
>> Thank You,
>>
>> Kind Regards,
>>
>> Ashwajit
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/f8bab3bc-1639-4be4-8f4c-48e0f45c9b9bo%40googlegroups.com
>> 
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwOydCFVpT8W9pdNTQfJ%2BGv0pucrZ8npZsCtBkm4ffbNYg%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P4Z-yGpLKt7fCX5UQm%3DbMuVogT9FYMW1M0jHA7oJvi6wA%40mail.gmail.com.