Hi!
I have found out that some IOS devices have problems with gather_facts and 
ansible does that by default. So I disabled it with gather_facts=no and now 
ansible continues to the next step now without gathering facts and skips 
the ios_facts error.

Also I have changed some paramiko config on the ansible.cfg  like this:
[paramiko_connection]

# uncomment this line to cause the paramiko connection plugin to not record new 
host
# keys encountered.  Increases performance on new host additions.  Setting 
works independently of the
# host key checking setting above.
#record_host_keys=False

# by default, Ansible requests a pseudo-terminal for commands executed under 
sudo. Uncomment this
# line to disable this behaviour.
#pty=False

# paramiko will default to looking for SSH keys initially when trying to
# authenticate to remote devices.  This is a problem for some network devices
# that close the connection after a key failure.  Uncomment this line to
# disable the Paramiko look for keys function
look_for_keys = False

# When using persistent connections with Paramiko, the connection runs in a
# background process.  If the host doesn't already have a valid SSH key, by
# default Ansible will prompt to add the host key.  This will cause connections
# running in background processes to fail.  Uncomment this line to have
# Paramiko automatically add host keys.
host_key_auto_add = True
Note that these changes didn't made any difference.. So if its commented or 
not i get the same error - No Existing Session

This is my code now:
---
  - name: 
---------------   1. Applying Layer 2 Configuration   ---------------
    hosts: Snif_TEST
    gather_facts: no
    vars:
      ansible_become: yes
      ansible_become_method: enable
      ansible_user: ansible
      ansible_password: ansible
      ansible_network_os: ios
      ansible_connection: network_cli
    tasks:
    - include_vars:
        dir: /etc/ansible/roles/new_vlan/vars/
    - include_role:
        name: new_vlan
        tasks_from: show_vlan.yml
I have found out that it doesn't matter if I put the vars under all:vars or 
just vars on the playbook it produces the same results.

So after bypassing the gathering_facts error my current error is:
2020-01-21 10:26:27,529 p=ansible u=26571 | ansible-playbook 2.9.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ansible/.ansible/plugins/modules', 
u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-39)]
2020-01-21 10:26:27,530 p=ansible u=26571
 | Using /etc/ansible/ansible.cfg as config file
2020-01-21 10:26:27,531 p=ansible u=26571 | setting up inventory plugins
2020-01-21 10:26:27,543 p=ansible u=26571
 | host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not 
pass its verify_file() method
2020-01-21 10:26:27,543 p=ansible u=26571
 | script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not 
pass its verify_file() method
2020-01-21 10:26:27,548 p=ansible u=26571
 | Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin
2020-01-21 10:26:27,548 p=ansible u=26571 | setting up inventory plugins
2020-01-21 10:26:28,353 p=ansible u=26571
 | Loading callback plugin default of type stdout, v2.0
 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc
2020-01-21 10:26:28,452 p=ansible u=26571 | PLAYBOOK: new_vlan_playbook.yml
 
***********************************************************************************************************
2020-01-21 10:26:28,453 p=ansible u=26571 | 1 plays in new_vlan_playbook.yml
2020-01-21 10:26:28,468 p=ansible u=26571 | PLAY [---------------   1
. Applying Layer 2
 Configuration   ---------------] 
**************************************************************
2020-01-21 10:26:28,476 p=ansible u=26571 | META: ran handlers
2020-01-21 10:26:28,484 p=ansible u=26571
 | TASK [include_vars] 
***********************************************************************************************************************
2020-01-21 10:26:28,518 p=ansible u=26580
 | <R-TEST-SNIF> attempting to start connection
2020-01-21 10:26:28,518 p=ansible u=26580
 | <R-TEST-SNIF> using connection plugin network_cli
2020-01-21 10:26:29,116 p=ansible u=26580
 | <R-TEST-SNIF> local domain socket does not exist, starting it
2020-01-21 10:26:29,116 p=ansible u=26580
 | <R-TEST-SNIF> control socket path is /home/ansible/.ansible/pc/b2fb8201f6
2020-01-21 10:26:29,117 p=ansible u=26580
 | <R-TEST-SNIF> local domain socket listeners started successfully
2020-01-21 10:26:29,117 p=ansible u=26580
 | <R-TEST-SNIF> loaded cliconf plugin ios from path /usr/lib/python2.7
/site-packages/ansible/plugins/cliconf/ios.py for network_os ios
2020-01-21 10:26:29,117 p=ansible u=26580 | network_os is set to ios
2020-01-21 10:26:29,117 p=ansible u=26580 | <R-TEST-SNIF> 
2020-01-21 10:26:29,118 p=ansible u=26580
 | <R-TEST-SNIF> local domain socket path is /home/ansible/.ansible/pc/
b2fb8201f6
2020-01-21 10:26:29,129 p=ansible u=26571 | ok: [R-TEST-SNIF] => {
    "ansible_facts": {
        "CONFIG_STATE": "absent", 
        "IP_ADDRESS": "{{ network_subnet ~ HOST_IP.stdout[0] }}", 
        "ansible_ssh_private_key_file": "/home/ansible/.ssh/id_rsa", 
        "network_subnet": "10.3.84.", 
        "vlan_id": 384, 
        "vlan_name": "TEST_VLAN_TEST"
    }, 
    "ansible_included_var_files": [
        "/etc/ansible/roles/new_vlan/vars/new_vlan_vars.yml"
    ], 
    "changed": false
}
2020-01-21 10:26:29,138 p=ansible u=26571
 | TASK [include_role : new_vlan] 
************************************************************************************************************
2020-01-21 10:26:29,518 p=ansible u=26571
 | TASK [new_vlan : ---------------   1
. Show VLAN   ----------------------] 
*****************************************************************
2020-01-21 10:26:29,549 p=ansible u=26592
 | <R-TEST-SNIF> attempting to start connection
2020-01-21 10:26:29,550 p=ansible u=26592
 | <R-TEST-SNIF> using connection plugin network_cli
2020-01-21 10:26:30,068 p=ansible u=26592
 | <R-TEST-SNIF> found existing local domain socket, using it!
2020-01-21 10:26:30,069 p=ansible u=26592
 | <R-TEST-SNIF> updating play_context for connection
2020-01-21 10:26:30,069 p=ansible u=26592 | <R-TEST-SNIF> 
2020-01-21 10:26:30,069 p=ansible u=26592
 | <R-TEST-SNIF> local domain socket path is /home/ansible/.ansible/pc/
b2fb8201f6
2020-01-21 10:26:30,085 p=ansible u=26588
 | <R-TEST-SNIF> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 
22 TO R-TEST-SNIF
2020-01-21 10:26:34,515 p=ansible u=26588
 | <R-TEST-SNIF> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 
22 TO R-TEST-SNIF
2020-01-21 10:26:40,946 p=ansible u=26588
 | <R-TEST-SNIF> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 
22 TO R-TEST-SNIF
2020-01-21 10:26:51,375 p=ansible u=26588
 | <R-TEST-SNIF> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 
22 TO R-TEST-SNIF
2020-01-21 10:26:53,772 p=ansible u=26588
 | Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/ansible/utils/jsonrpc.py", line 45
, in handle_request
    result = rpc_method(*args, **kwargs)
  File 
"/usr/lib/python2.7/site-packages/ansible/plugins/connection/__init__.py"
, line 34, in wrapped
    self._connect()
  File 
"/usr/lib/python2.7/site-packages/ansible/plugins/connection/network_cli.py"
, line 426, in _connect
    raise AnsibleConnectionFailure(to_text(e, errors='surrogate_or_strict'))
AnsibleConnectionFailure: No existing session

2020-01-21 10:26:53,785 p=ansible u=26571
 | fatal: [R-TEST-SNIF]: FAILED! => {
    "changed": false, 
    "msg": "No existing session"
}
2020-01-21 10:26:53,788 p=ansible u=26571
 | PLAY RECAP 
********************************************************************************************************************************
2020-01-21 10:26:53,789 p=ansible u=26571 | R-TEST-SNIF                : ok=
1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0
    ignored=0   



Any ideas?? im lost here its still not working!

-- 
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/040f3b40-211e-4870-b733-ce1f19ef25ef%40googlegroups.com.

Reply via email to