[ansible-project] ansible-playbook for getting orion managed nodes
Hi! Can anyone help me build this playbook? how can i fetch this information from my orion windows-based server? -- 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/960d266b-26f4-45b7-9819-17e0fbfbc993%40googlegroups.com.
[ansible-project] win_shell module with multiple lines not working
*Hi guys*. *This is my code*: --- - name: Multi-line shell win_shell: ## Creating Scopes Add-DhcpServerv4Scope -Name "{{ hebrew_site_name }}" -StartRange "{{ DHCP_computers_segment }}.61" -EndRange "{{ DHCP_computers_segment }}.243" -SubnetMask "255.255.255.0" -LeaseDuration "8.00:00:00" Add-DhcpServerv4Scope -Name "{{ hebrew_site_name }} טלפוניה" -StartRange "{{ DHCP_telephony_segment }}.61" -EndRange "{{ DHCP_telephony_segment }}.243" -SubnetMask "255.255.255.0" -LeaseDuration "8.00:00:00" *Error*: 2020-02-23 13:33:51,237 p=54513 u=ansible n=ansible | PLAY [--- Creating VLAN 2,5 IP pools on dhcp1 ---] 2020-02-23 13:33:51,251 p=54513 u=ansible n=ansible | TASK [set_fact] *** 2020-02-23 13:33:51,270 p=54513 u=ansible n=ansible | ok: [dhcp-test] 2020-02-23 13:33:51,275 p=54513 u=ansible n=ansible | TASK [include_vars] *** 2020-02-23 13:33:51,293 p=54513 u=ansible n=ansible | ok: [dhcp-test] 2020-02-23 13:33:51,297 p=54513 u=ansible n=ansible | TASK [include_role : new_branch] ** 2020-02-23 13:33:51,612 p=54513 u=ansible n=ansible | TASK [new_branch : Multi-line shell] ** 2020-02-23 13:33:51,742 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | Starting new HTTPS connection (1 ): dhcp-test 2020-02-23 13:33:51,767 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 401 0 2020-02-23 13:33:51,770 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | Resetting dropped connection: dhcp-test 2020-02-23 13:33:51,794 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 401 0 2020-02-23 13:33:51,872 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 1629 2020-02-23 13:33:51,884 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 847 2020-02-23 13:33:52,443 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 753 2020-02-23 13:33:53,177 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 998 2020-02-23 13:33:57,774 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 3575 2020-02-23 13:33:57,779 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 757 2020-02-23 13:33:57,784 p=54528 u=ansible n= requests.packages.urllib3.connectionpool | "POST /wsman HTTP/1.1" 200 602 2020-02-23 13:33:57,789 p=54513 u=ansible n=ansible | fatal: [dhcp-test]: FAILED! => {"changed": true, "cmd": "Add-DhcpServerv4Scope -Name \"אור-יהודה-מומה\" -StartRange \"10.90.88.61\" -EndRange \ "10.90.88.243\" -SubnetMask \"255.255.255.0\" -LeaseDuration \"8.00:00:00\" Add-DhcpServerv4Scope -Name \"אור-יהודה-מומה טלפוניה\" -StartRange \ "10.95.88.61\" -EndRange \"10.95.88.243\" -SubnetMask \"255.255.255.0\" -LeaseDuration \"8.00:00:00\"", "delta": "0:00:03.656283", "end": " 2020-02-23 11:33:57.948151", "msg": "non-zero return code", "rc": 1, "start": "2020-02-23 11:33:54.291867", "stderr" : "Add-DhcpServerv4Scope : Cannot bind parameter because parameter 'Name' is specified more than once. To provide \r\nmultiple values to parameters that can accept multiple values, use the array syntax. For example, \"-parameter \r\nvalue1,value2,value3\".\r\nAt line:1 char:239\r\n+ ... 55. 0\" -LeaseDuration \"8.00:00:00\" Add-DhcpServerv4Scope -Name \"אור-יה ...\r\n+ ~\r\n+ CategoryInfo : InvalidArgument: (:) [Add-DhcpServerv4Scope], ParameterBindingException \r\n+ FullyQualifiedErrorId : ParameterAlreadyBound,Add-DhcpServerv4Scope", "stderr_lines": [" Add-DhcpServerv4Scope : Cannot bind parameter because parameter 'Name' is specified more than once. To provide ", " multiple values to parameters that can accept multiple values, use the array syntax. For example, \"-parameter ", "value1,value2,value3\".", "At line:1 char:239 ", "+ ... 55.0\" -LeaseDuration \"8.00:00:00\" Add-DhcpServerv4Scope -Name \"אור-יה ...", "+ ~" , "+ CategoryInfo : InvalidArgument: (:) [Add-DhcpServerv4Scope], ParameterBindingException", "+ FullyQualifiedErrorId : ParameterAlreadyBound,Add-DhcpServerv4Scope"], "stdout": "", " stdout_lines": []} 2020-02-23 13:33:57,791 p=54513 u=ansible n=ansible | PLAY RECAP 2020-02-23 13:33:57,791 p=54513 u=ansible n=ansible | dhcp-test : ok=2changed=0 unreachable=0
[ansible-project] Re: ansible ping failure to windows host
Hi Thanks for your answer. Thanks to you my problem is solved. I had to install certificate in the windows host side and then use ntlm transport and ignore cert_validation. These made it work. -- 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/59df3036-d633-4717-a814-f71cf7290be4%40googlegroups.com.
[ansible-project] ansible ping failure to windows host
Hi guys! I have issues with ansible ping (python module validation) with Windows Server 2019 host. This is the result: [ansible@Netauto-Dev new_branch]$ ansible dhcp-test -m ping - 2020-02-20 14:37:56,686 p=ansible u=123991 | ansible 2.9.1 config file = /etc/ansible/ansible.cfg configured module search path = [u'/etc/ansible/my_modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] 2020-02-20 14:37:56,686 p=ansible u=123991 | Using /etc/ansible/ansible.cfg as config file 2020-02-20 14:37:56,687 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,697 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,697 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,702 p=ansible u=123991 | Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin 2020-02-20 14:37:56,703 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,703 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,703 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,708 p=ansible u=123991 | Parsed /etc/ansible/inventory/SNIF_AGGREGATOR.yml inventory source with yaml plugin 2020-02-20 14:37:56,708 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,708 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,709 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,710 p=ansible u=123991 | Skipping empty key (hosts) in group (AVAYA) 2020-02-20 14:37:56,711 p=ansible u=123991 | Parsed /etc/ansible/inventory/avaya.yml inventory source with yaml plugin 2020-02-20 14:37:56,711 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,711 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,711 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,868 p=ansible u=123991 | Parsed /etc/ansible/inventory/branch_switch.yml inventory source with yaml plugin 2020-02-20 14:37:56,868 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,869 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,869 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,876 p=ansible u=123991 | Parsed /etc/ansible/inventory/nexus.yml inventory source with yaml plugin 2020-02-20 14:37:56,876 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,876 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,876 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,913 p=ansible u=123991 | Parsed /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml inventory source with yaml plugin 2020-02-20 14:37:56,914 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,914 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,914 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,970 p=ansible u=123991 | Parsed /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml inventory source with yaml plugin 2020-02-20 14:37:56,971 p=ansible u=123991 | setting up inventory plugins 2020-02-20 14:37:56,971 p=ansible u=123991 | host_list declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,971 p=ansible u=123991 | script declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method 2020-02-20 14:37:56,974 p=ansible u=123991 | Skipping empty key (hosts) in group (snif_router_SoM_10M) 2020-02-20 14:37:56,975 p=ansible u=123991 | Parsed
[ansible-project] Ansible for Windows Server DHCP feature (dhcpmgmt.msc)
Hi, I want to create ansible automation for create IPv4 pools on Windows Server 2019 operating system. This is where I want to add the pool: [image: Capture.PNG] >From what I understand I have two options I could do that: 1. Is to the find dhcpmgmt built-in Ansible module which is capable to create pools (don't know if this kind of module even exist) 2. Is to send PowerShell commands to the dhcp server (dhcp1) and configure the pool through that. I need help in: 1. Does Ansible module exist for creating pools on dhcp windows servers? If it does can I get some references? 2. How do I configure windows servers with PowerShell commands? What module to use and how does the code for the task should look like? Thanks in advance, YP -- 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/dd95577a-47dc-4cc0-a860-82449554f7b5%40googlegroups.com.
Re: [ansible-project] Problem with Conditional variable
Hi guys! Solved. Solution: qos_policy: "{{ 'qos-nested-50m' if bandwidth_mb == 50 else 'qos-nested-new-' ~ bandwidth_mb ~ 'm' }}" Thanks for all replys. Peace out. -- 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/f02e567b-0d47-4897-9deb-2bd37b1f2801%40googlegroups.com.
Re: [ansible-project] Problem with Conditional variable
Hi! Both solutions given are not working for some reason.. Any other suggestions? -- 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/a2b539aa-3d78-48e4-95f8-333bba97e0d3%40googlegroups.com.
[ansible-project] Problem with Conditional variable
*Hi!* *I want to make the variable qos_policy set on conditional basis:* *If bandwidth_mb == '50'* * then qos_policy == 'qos-nested-50'* *else* * qos_policy == 'qos-nested-new-50'* *My code is this (not working):* qos_policy: "{{ 'qos-nested-new-' + bandwidth_mb }}" qos_policy: "{{ 'qos-nested-' + bandwidth_mb }}" when: - bandwidth_mb == "50" bandwidth_mb: "some number" *Error:* [ansible@Netauto-Dev new_branch]$ ansible-playbook test_new_branch_playbook.yml PLAY [TEST5_TLV5] * TASK [include_vars] *** ok: [R-TEST5-TLV5] TASK [include_role : new_branch] ** ERROR! Syntax Error while loading YAML. did not find expected key The error appears to be in '/etc/ansible/roles/new_branch/tasks/configure_som_tlv5.yml': line 8, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - qos_policy: "{{ 'qos-nested-' + bandwidth_mb }}" when: ^ here PLAY RECAP R-TEST5-TLV5 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 *What is the problem?* -- 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/353c9445-4a49-4222-b98b-8a9bdf6d939c%40googlegroups.com.
[ansible-project] Conditional variables
*Hi!* *I want to make the variable qos_policy set on conditional basis:* *If bandwidth_mb == '50'* * then qos_policy == 'qos-nested-'* *else* * qos_policy == 'qos-nested-new-'* *My code is this (not working):* qos_policy: "{{ 'qos-nested-new-' + bandwidth_mb }}" qos_policy: "{{ 'qos-nested-' + bandwidth_mb }}" when: - bandwidth_mb == "50" bandwidth_mb: "some number" *Error:* [ansible@Netauto-Dev new_branch]$ ansible-playbook test_new_branch_playbook.yml PLAY [TEST5_TLV5] * TASK [include_vars] *** ok: [R-TEST5-TLV5] TASK [include_role : new_branch] ** ERROR! Syntax Error while loading YAML. did not find expected key The error appears to be in '/etc/ansible/roles/new_branch/tasks/configure_som_tlv5.yml': line 8, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - qos_policy: "{{ 'qos-nested-' + bandwidth_mb }}" when: ^ here PLAY RECAP R-TEST5-TLV5 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 *What is the problem?* -- 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/8a211591-b2a7-4ebd-87ff-1060b80b9f02%40googlegroups.com.
Re: [ansible-project] Re: Ansible passwordless login not working
Yea you are right. I am hitting this bug and I can't see myself pulling this off. I'll just go with the pubkey method although I wanted to avoid it because I have lots of network devices. But no choice here because Ansible is not going to work without SSH keys on these IOS versions. FYI, This code is working perfectly on NXOS switches I've got without touching the SSH keys. Also, I read that this bug hits only IOS version 15.7 and below and does not apply on NXOS/IOS-XE/IOS 15.8 or higher. Thank you Phil and Vladimir for your help. I'll just go for Public Key authentication. Peace out <3 -- 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/0ac6c1b2-54ef-4305-bb60-96897cddf7a4%40googlegroups.com.
Re: [ansible-project] Re: Ansible passwordless login not working
[ansible@Netauto-Dev new_vlan]$ ansible -m ios_command -e commands='sh ip int br' -i /etc/ansible/inventory/ R-TEST-SNIF -e 'ansible_connection=network_cli' -e 'ansible_network_os=ios' -e 'remote_user=ansible' -k SSH password: [WARNING]: Found variable using reserved name: remote_user R-TEST-SNIF | FAILED! => { "changed": false, "msg": "No existing session" This is my result.. I think I dont understand a couple of things: 1. Why do you have to remove the SSH keys from the router? should'nt it use the SSH keys as primary method and then fallback to using password? 2. What exactly did you do on the cisco device to remove the keys? (although I dont beleive it is a solution for me since I cant remove SSH keys on devices in my real network) 3. There isn't a way to do password authentication without removing SSH keys? -- 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/02bb6e11-cfd3-41fe-b52e-7fc8433a1991%40googlegroups.com.
[ansible-project] Re: Ansible passwordless login not working
Hi! To simplify stuff I am troubleshooting this problem with the command below: ansible -m ios_command -e commands='sh ip int br' -i /etc/ansible/inventory/ R-TEST-SNIF -e 'ansible_connection=network_cli' -e 'ansible_network_os=ios' -u ansible -k It will make it easier to troubleshoot this problem without messing around with multiple files and folders. - It runs the ios_command module on the host R-TEST-SNIF that is located on the inventory folder. -e is extra_vars and those are ansible_connection & ansible_network_os. -u for username = ansible, -k for prompting SSH Password. Result is the same - No Existing Sessions. Below im attaching proof that ping works and SSH by cli is working to the remote router and the ansible does not. [image: Capture.PNG] *Suggestions?* -- 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/9320b24b-6542-4de2-9077-561a4092b33d%40googlegroups.com.
[ansible-project] Re: Ansible passwordless login not working
1. Yes. remote_user is already set on ansible.cfg file: # SSH timeout #timeout = 10 # default user to use for playbooks if user is not specified # (/usr/bin/ansible will use current user as default) remote_user = ansible # logging is off by default unless this path is defined # if so defined, consider logrotate log_path = /etc/ansible/ansiout.log 2. ip ssh server authenticate user password is enabled on the remote device. Here is the output: [image: Capture.PNG] 3. I have already tested the vars on the inventory file like you suggested and instead I also tried to define the vars on the playbook itself (all info is in the last 2 messages I posted here) The result was the same for either situation - No existing Session. Anyway since u still think it matters, I have now moved the vars definition to [all:vars] so consider it done. 4. ansible ping works. Here are both results of : - current status with your suggestions about the vars on inventory, remote_user, show ip ssh - ping result [image: Capture.PNG] If ping works it means that the code is ok and its something with authentication but i'm not sure what... everything seems good but 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/32b21cee-cfb4-4d2b-a63c-746e6c2478b1%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
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 | attempting to start connection 2020-01-21 10:26:28,518 p=ansible u=26580 | using connection plugin network_cli 2020-01-21 10:26:29,116 p=ansible u=26580 | local domain socket does not exist, starting it 2020-01-21 10:26:29,116 p=ansible u=26580 | control socket path is /home/ansible/.ansible/pc/b2fb8201f6 2020-01-21 10:26:29,117 p=ansible u=26580 | local domain socket listeners started successfully 2020-01-21 10:26:29,117 p=ansible u=26580 | 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 | 2020-01-21 10:26:29,118 p=ansible u=26580 |
Re: [ansible-project] Ansible passwordless login not working
*Hi Phil,* *Thank you for your help.* *Playbook:* - name: --- 1. Applying Layer 2 Configuration --- hosts: Snif_TEST connection: network_cli tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: show_vlan.yml *It's seems that after I set these variables under the inventory file like this:* all: children: POC_ENV: hosts: TEST-NXOS2: TEST-NXOS3: Snif_TEST: hosts: R-TEST-SNIF: vars: ansible_network_os: ios ansible_password: ansible ansible_become: yes ansible_become_method: enable ansible_user: ansible *All other variables are equal to null except ansible_connection/ansible_network_os for some reason. Here is the output:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml - 2020-01-21 09:25:53,934 p=ansible u=23836 | 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 09:25:53,935 p=ansible u=23836 | Using /etc/ansible/ansible.cfg as config file 2020-01-21 09:25:53,936 p=ansible u=23836 | setting up inventory plugins 2020-01-21 09:25:53,947 p=ansible u=23836 | host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method 2020-01-21 09:25:53,947 p=ansible u=23836 | script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method 2020-01-21 09:25:53,953 p=ansible u=23836 | Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin 2020-01-21 09:25:53,954 p=ansible u=23836 | setting up inventory plugins 2020-01-21 09:25:55,045 p=ansible u=23836 | Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc 2020-01-21 09:25:55,138 p=ansible u=23836 | PLAYBOOK: new_vlan_playbook.yml *** 2020-01-21 09:25:55,139 p=ansible u=23836 | 1 plays in new_vlan_playbook.yml 2020-01-21 09:25:55,145 p=ansible u=23836 | PLAY [--- 1 . Applying Layer 2 Configuration ---] ** 2020-01-21 09:25:55,159 p=ansible u=23836 | TASK [Gathering Facts] 2020-01-21 09:25:55,202 p=ansible u=23847 | attempting to start connection 2020-01-21 09:25:55,203 p=ansible u=23847 | using connection plugin network_cli 2020-01-21 09:25:55,843 p=ansible u=23847 | local domain socket does not exist, starting it 2020-01-21 09:25:55,843 p=ansible u=23847 | control socket path is /home/ansible/.ansible/pc/e8627bbe23 2020-01-21 09:25:55,844 p=ansible u=23847 | local domain socket listeners started successfully 2020-01-21 09:25:55,844 p=ansible u=23847 | loaded cliconf plugin ios from path /usr/lib/python2.7 /site-packages/ansible/plugins/cliconf/ios.py for network_os ios 2020-01-21 09:25:55,844 p=ansible u=23847 | network_os is set to ios 2020-01-21 09:25:55,845 p=ansible u=23847 | 2020-01-21 09:25:55,845 p=ansible u=23847 | local domain socket path is /home/ansible/.ansible/pc/ e8627bbe23 2020-01-21 09:25:55,853 p=ansible u=23847 | [WARNING]: Ignoring timeout(10 ) for ios_facts 2020-01-21 09:25:55,854 p=ansible u=23847 | ESTABLISH LOCAL CONNECTION FOR USER: ansible 2020-01-21 09:25:55,855 p=ansible u=23847 | EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp/ansible-local-23836IRvmI3/ansible-tmp-1579591555.85-45205629859053 `" && echo ansible-tmp-1579591555.85-45205629859053="` echo /home/ansible/.ansible/tmp/ansible-local-23836IRvmI3/ansible-tmp-1579591555.85-45205629859053 `" ) && sleep 0' 2020-01-21 09:25:56,725 p=ansible u=23847 | Attempting python interpreter discovery 2020-01-21 09:25:56,726 p=ansible u=23847 | EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0' 2020-01-21 09:25:56,748 p=ansible u=23847 | EXEC /bin/sh -c '/usr/bin/python && sleep 0' 2020-01-21 09:25:56,822 p=ansible u=23847 | Using module file /usr/lib/python2.7 /site-packages/ansible/modules/network/ios/ios_facts.py 2020-01-21
Re: [ansible-project] Ansible passwordless login not working
I think it has something to do with the publickey and that ansible tries to authenticate using the public key as primary method of authentication. For some reason it doesn't takes the username and password and just attempt SSH with it. I think that because of the log 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/db3d5b87-468a-450c-bf37-1a7dc26ec309%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
Hi again. Anyone have any idea? -- 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/e669ab37-a0b7-4508-a129-e771ca18926c%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
Hi Douglas, This is the result of --ask-pass: [image: Capture.PNG] I have no idea what that means haha. What do you think? -- 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/1b6b38ae-78ab-498f-b087-38df4eef2a17%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
*I have no idea what to do next.. also ping check fails..* [image: Capture.PNG] *Again, if im adding the publickey for passwordless authentication Ansible works.. but without it its not..* *This is the configuration on the router side:* R-TEST-SNIF#sh run Building configuration... Current configuration : 1474 bytes ! ! Last configuration change at 07:42:41 EST Wed Jan 15 2020 ! version 15.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R-TEST-SNIF ! boot-start-marker boot-end-marker ! aqm-register-fnf ! ! no aaa new-model clock timezone EST -5 0 mmi polling-interval 60 no mmi auto-configure no mmi pvc mmi snmp-timeout 180 ! ! ! ! ! ! ! ! ! ! ip domain name EVE ip cef no ipv6 cef ! multilink bundle-name authenticated ! ! ! ! ! ! ! ! username ansible privilege 15 password 0 ansible ! redundancy ! ! ip ssh version 2 ! ! ! ! ! ! ! ! ! ! ! ! ip forward-protocol nd ! ! no ip http server no ip http secure-server ! ! ! ! control-plane ! ! ! ! ! ! ! ! line con 0 exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 exec-timeout 0 0 logging synchronous login local transport input telnet ssh transport output telnet ssh ! ! end *crypto key rsa generate proof:* R-TEST-SNIF# show crypto key mypubkey rsa % Key pair was generated at: 05:35:04 EST Jan 15 2020 Key name: R-TEST-SNIF.EVE Key type: RSA KEYS Storage Device: private-config Usage: General Purpose Key Key is not exportable. Key Data: 307C300D 06092A86 4886F70D 01010105 00036B00 30680261 00A5F2FB C8D19FA7 E19B9A1E 92976C47 174482FA 788CEA72 85AEF6E9 F0336651 CFE2DA99 316C94A2 45A9C27F A2E37D40 C2EE2A39 81B2C4C9 E3BB751C 20CD8C2A 1A632617 AE46F329 05CC6D09 483607CB 20DBC972 C2A92124 63FD1EFB E9A66E8C 07020301 0001 % Key pair was generated at: 05:35:04 EST Jan 15 2020 Key name: R-TEST-SNIF.EVE.server Key type: RSA KEYS Temporary key Usage: Encryption Key Key is not exportable. Key Data: 306C300D 06092A86 4886F70D 01010105 00035B00 30580251 00AC4D25 1A615FB6 1FFEFF70 1A0C72A8 C9C26E3A C4F9AA7D 8C47CE5B 0FCC59A7 CADA0BC8 C173D620 26E5445E 65BBAAF2 915B844C 71B0D855 ADB5BBBC 68314F14 3F891C0D 8162B869 C227A0B0 C4592A93 5F020301 0001 *Its probably some command missing on the router side.. * *anyone have any idea what is missing?* -- 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/8a9ba6ec-a380-4c6f-94e3-0d40f93c8aa6%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
I'm not sure that "connection: network_cli" because not matter what i do I get the same error... Its just not working. How is it SSH problem if I can add a public key or just regulary SSH and its working? that proves that its not an SSH problem on my remote machine and leaves the fault in the ansible code side.. Any other ideas? -- 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/b9eb97d9-87d6-48fe-8077-4f0b3c78f3dd%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
*Hi Vladimir,* *with this code on the playbook:* --- - name: --- 1. Applying Layer 2 Configuration --- hosts: Snif_TEST connection: network_cli tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: show_vlan.yml *And on the vars file:* ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_user: ansible ansible_password: ansible *This is the result:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml PLAY [--- 1. Applying Layer 2 Configuration ---] ** TASK [Gathering Facts] fatal: [R-TEST-SNIF]: FAILED! => {"msg": "Unable to automatically determine host network os. Please manually configure ansible_network_os value for this host"} *With this code on the playbook:* --- - name: --- 1. Applying Layer 2 Configuration --- hosts: Snif_TEST tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: show_vlan.yml *And on the vars file:* ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_connection: network_cli ansible_network_os: ios ansible_user: ansible ansible_password: ansible *This is the result:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml PLAY [--- 1. Applying Layer 2 Configuration ---] ** TASK [Gathering Facts] fatal: [R-TEST-SNIF]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added 'r-test-snif,10.70.54.102' (RSA) to the list of known hosts.\r\nPermission denied (publickey,keyboard-interactive,password).", "unreachable": true} PLAY RECAP R-TEST-SNIF: ok=0changed=0unreachable=1 failed=0skipped=0rescued=0ignored=0 *Keep in mind that in anytime I have no problem with sshing to the machine. example:* [image: Capture.PNG] *Also remember that I always can add the pubkey configuration to the router and run ansible successfuly.* *Have any idea what to do next?* -- 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/bb69793a-cf26-4db4-8e0d-20f58d00f087%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
*Oh. of course.* *The router is virtual image - IOL.* *Cisco IOS Software Version 15.4(1)T (I86BI_LINUX-ADVENTERPRISEK9-M)* *Full code is:* */etc/ansible/roles/new_vlan/new_vlan_playbook.yml:* --- - name: --- 1. Applying Layer 2 Configuration --- hosts: Snif_TEST connection: local tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: show_vlan.yml */etc/ansible/roles/new_vlan/tasks/show_vlan.yml* --- - name: --- 1. Show VLAN -- ios_command: commands: - show ip int br register: show_vlan - debug: msg="{{ show_vlan.stdout_lines }}" * /etc/ansible/roles/new_vlan/vars/new_vlan_vars.yml* ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_user: ansible ansible_password: ansible */etc/ansible/inventory/POC_ENV.yml* all: children: POC_ENV: hosts: TEST-NXOS2: TEST-NXOS3: Snif_TEST: hosts: R-TEST-SNIF: *Ill mention again that when i add this configuration on the router ansible works perfectly:* ip ssh pubkey-chain username ansible key-string ssh-rsa B3NzaC1yc2EDAQABAAABAQDuKpCznL9Gb7L/jVypzsHxFcceKBL2Xg0Enjr5XnGtaAsycD+ToiXYANzn2J21z3IqxyVG7NELLkW03CCclBVMCkdbzD8sRaVuIZCjYdzD4KX7O8goBXnz0+sPO4FhccSBhMfAO/IphliQ0oFBM26OG8UsxZISI5/04GdObk6AwM7jDk6Fga1Wcmqpo0P2XfarXckbL0LxAYEaGr5JR6X4p n+0x4C/DuOIIKQuvDyiaWTlD+ewRW6kMUUgo8AnVcHekZG+7GDzS4yVuAKZ73pl+Pe8EBa2eUP4FSE1ZXqnQvunKyGo7ifrZCcbikAnkB2is48Y67E3c21ZxhSkI36P ansible@Netauto-Dev *What do you think?* -- 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/a7f6c8a5-e945-4fa0-a3e6-ce11934427ac%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
Hi Vladimir, The device is a router, and I have made few more checks: 1. If im sshing normaly with ansible:ansible credentials it works 2. If im installing ssh keypair (publickey on the router) the ansible is working. Problem occurs once I take off the public key from the router and try to ssh with username + password instead of username + pubkey. I have even tryed to add the ansible_connection feature like this: ansible_connection: network_cli ansible_network_os: ios ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_user: ansible ansible_password: ansible And this is the error: [image: Capture.PNG] I have no idea what to do -- 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/7c3b0d67-6a7b-4bb2-bc68-a7ecce4a4023%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
> > Hi Vladimir, The device is a router, and I have made few more checks: 1. If im sshing normaly with ansible:ansible credentials it works 2. If im installing ssh keypair (publickey on the router) the ansible is working. Problem occurs once I take off the public key from the router and try to ssh with username + password instead of username + pubkey. I have even tryed to add the ansible_connection feature and this is the error: [image: Capture.PNG] I have no idea what to do -- 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/a2232f9d-f8de-4b63-a1d6-ad60507dcd4e%40googlegroups.com.
Re: [ansible-project] Ansible passwordless login not working
*Hi,* *Thank you for your answer. but its still not working* *This is how my code looks like now:* ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_user: ansible ansible_password: ansible *And here is my error now:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml -v 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)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/SNIF_AGGREGATOR.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (avaya) Parsed /etc/ansible/inventory/avaya.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/branch_switch.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/nexus.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_10M) Parsed /etc/ansible/inventory/snif_router_SoM_10M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_20M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_20M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_20M) Parsed /etc/ansible/inventory/snif_router_SoM_20M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_40M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_40M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_40M) Parsed /etc/ansible/inventory/snif_router_SoM_40M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_all.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_all.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_all.yml inventory source with yaml plugin Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc PLAYBOOK: new_vlan_playbook.yml
Re: [ansible-project] Ansible passwordless login not working
*Hi,* *Thank you for your answer. but its still not working* *any idea why? * *here is my error now:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml -v 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)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/SNIF_AGGREGATOR.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (avaya) Parsed /etc/ansible/inventory/avaya.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/branch_switch.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/nexus.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_10M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_10M) Parsed /etc/ansible/inventory/snif_router_SoM_10M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_20M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_20M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_20M) Parsed /etc/ansible/inventory/snif_router_SoM_20M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_SoM_40M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_SoM_40M.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (snif_router_SoM_40M) Parsed /etc/ansible/inventory/snif_router_SoM_40M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_all.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_all.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_all.yml inventory source with yaml plugin Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc PLAYBOOK: new_vlan_playbook.yml *** Positional arguments: new_vlan_playbook.yml become_method: sudo inventory:
[ansible-project] Ansible passwordless login not working
*Hi!!* *Here is my code on my /etc/ansible/roles/new_vlan/vars/new_vlan_vars.yml file:* ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=~/.ssh/known_hosts ansible_user: ansible ansible_pass: ansible *I want to disable the SSH authenticity of host check, and I dont want to use public and private keys for ssh.. I want to specify the username and password as modules/variables w/e...* *Its not working I think ansible doesn't use the username and password ansible for some reason.* *This is my error:* [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml PLAY [--- 1. Applying Layer 2 Configuration ---] ** TASK [Gathering Facts] ok: [R-TEST-SNIF] TASK [include_vars] *** ok: [R-TEST-SNIF] TASK [include_role : new_vlan] TASK [new_vlan : --- 1. Show VLAN --] * fatal: [R-TEST-SNIF]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 10 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."} PLAY RECAP R-TEST-SNIF: ok=2changed=0unreachable=0 failed=1skipped=0rescued=0ignored=0 [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ [ansible@Netauto-Dev new_vlan]$ ansible-playbook new_vlan_playbook.yml -v 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)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/SNIF_AGGREGATOR.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/SNIF_AGGREGATOR.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method Skipping empty key (hosts) in group (avaya) Parsed /etc/ansible/inventory/avaya.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/branch_switch.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/nexus.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/nexus.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/snif_router_IPVPN_20M_50M.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/snif_router_IPVPN_8M_10M_200M.yml as it did not pass its verify_file() method Parsed
[ansible-project] Re: Setting conditionals properly - not working
Solved. Solution: - ios_config: lines: - interface Ethernet0/1.{{ vlan_id }} - encapsulation dot1q {{ vlan_id }} - ip address {{ wan_ip }} - no shutdown save_when: "{{ do_write }}" when: CONFIG_STATE == "present" Thanks to me :D -- 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/1373adbc-f165-4b35-9359-8ed78640cc5d%40googlegroups.com.
[ansible-project] Re: Setting conditionals properly - not working
Solved. Solution: - ios_config: lines: - interface Ethernet0/1.{{ vlan_id }} - encapsulation dot1q {{ vlan_id }} - ip address {{ wan_ip }} - no shutdown save_when: "{{ do_write }}" when: CONFIG_STATE == "present" בתאריך יום רביעי, 8 בינואר 2020 בשעה 09:58:16 UTC+2, מאת Yehuda Pinhas: > > Hi again! > > This is the code of the task configure_som_tlv5 inside the role new_branch: > - ios_config: > lines: > - interface Ethernet0/1.{{ vlan_id }} > - encapsulation dot1q {{ vlan_id }} > - ip address {{ wan_ip }} > - no shutdown > save_when: "{{ do_write }}" > when: (ansible_facts['CONFIG_STATE'] == "present") > > What I'm trying to code here is to execute the ios_config module only when > the variable CONFIG_STATE equals to the string present. > > Error im receiving is: > > [image: Capture.PNG] > > > Any clue why my conditional check fails? > The same error is received whether CONFIG_STATE is present or anything > else.. > > Thx in advance, > YP > > > -- 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/e01eedf9-622a-4b7e-81bb-8699841718ab%40googlegroups.com.
[ansible-project] Setting conditionals properly - not working
Hi again! This is the code of the task configure_som_tlv5 inside the role new_branch: - ios_config: lines: - interface Ethernet0/1.{{ vlan_id }} - encapsulation dot1q {{ vlan_id }} - ip address {{ wan_ip }} - no shutdown save_when: "{{ do_write }}" when: (ansible_facts['CONFIG_STATE'] == "present") What I'm trying to code here is to execute the ios_config module only when the variable CONFIG_STATE equals to the string present. Error im receiving is: [image: Capture.PNG] Any clue why my conditional check fails? The same error is received whether CONFIG_STATE is present or anything else.. Thx in advance, YP -- 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/2b49a902-1ad9-47d4-aa67-326138d26fc1%40googlegroups.com.
Re: [ansible-project] Changing variable value based on another variable value
Thank you vladimir! working now בתאריך יום שלישי, 7 בינואר 2020 בשעה 16:34:47 UTC+2, מאת Vladimir Botka: > > On Tue, 7 Jan 2020 05:41:12 -0800 (PST) > Yehuda Pinhas > wrote: > > > qos_policy: qos-nested-new-10m > >when: "{{ bandwidth_mb }} == '10'" > > qos_policy: qos-nested-new-20m > >when: "{{ bandwidth_mb }} == '20'" > > > > Modify: > > bandwidth_mb: 10 > > > > *I'm trying to create a condition for the qos_policy variable:* > > if bandwidth_mb = 10 then qos_policy = qos-nested-new-10m > > if bandwidth_mb = 20 then qos_policy = qos-nested-new-20m > > Concatenate the strings. For example > > - hosts: localhost > vars: > bandwidth_mb: 10 > tasks: > - set_fact: > qos_policy: "{{ 'qos-nested-new-' + > bandwidth_mb|string + > 'm' }}" > - debug: > var: qos_policy > > gives > > ok: [localhost] => { > "qos_policy": "qos-nested-new-10m" > } > > > *The errors im receiving on all my previous attempts to do this code > are:* > > 1. invalid syntax > >when: "{{ bandwidth_mb }} == '10'" > > The conditions are expanded by default. Try > > - debug: > msg: Bandwidth is 10 MB > when: bandwidth_mb == 10 > > 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/abdff5a4-65bb-4137-ae62-f5194000f1a1%40googlegroups.com.
[ansible-project] Changing variable value based on another variable value
Hi guys! This is my code: --- qos_policy: qos-nested-new-10m when: "{{ bandwidth_mb }} == '10'" qos_policy: qos-nested-new-20m when: "{{ bandwidth_mb }} == '20'" Modify: bandwidth_mb: 10 *I'm trying to create a condition for the qos_policy variable:* if bandwidth_mb = 10 then qos_policy = qos-nested-new-10m if bandwidth_mb = 20 then qos_policy = qos-nested-new-20m *Just for clarification:* • bandwidth_mb & qos_policy are variables • qos-nested-new-10m & qos-nested-new-20m are strings *The errors im receiving on all my previous attempts to do this code are:* 1. invalid syntax 2. duplicate value for qos_policy applying only the last value (always qos-nested-new-20m) I receive these errors seperatly, depending on how I change the code but its still not working like it should. What am I doing wrong here? Thanks in advance, YP -- 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/0d21767a-703e-4b9f-810c-dfb5aed5bf0a%40googlegroups.com.
Re: [ansible-project] Ansible error when running for multiple hosts in inventory file
Hi Vladimir, Thank you! working now. בתאריך יום שני, 6 בינואר 2020 בשעה 18:29:10 UTC+2, מאת Vladimir Botka: > > On Mon, 6 Jan 2020 05:22:37 -0800 (PST) > Yehuda Pinhas > wrote: > > > all: > > children: > > POC_ENV: > > hosts: > > TEST-NXOS2 > > TEST-NXOS3 > > Colon ':' is missing after the hostnames. Fix the inventory > > all: > children: > POC_ENV: > hosts: > TEST-NXOS2: > TEST-NXOS3: > > Without the colons the lines are concatenated. This is the reason of the > error > > 'fatal: [TEST-NXOS2 TEST-NXOS3]: FAILED! ...' > > 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/15fa0cb2-0c8c-4032-8b03-61d9d7921032%40googlegroups.com.
[ansible-project] Ansible error when running for multiple hosts in inventory file
Hi guys! Inventory POC_ENV.yml file: all: children: POC_ENV: hosts: TEST-NXOS2 TEST-NXOS3 vars: ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible Playbook new_vlan_playbook.yml file: --- - name: --- 1. Applying Layer 2 Configuration --- hosts: POC_ENV connection: local tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: add_vlan.yml - name: --- 3. Applying Layer 3 Configuration --- hosts: POC_ENV connection: local tasks: - include_vars: dir: /etc/ansible/roles/new_vlan/vars/ - include_role: name: new_vlan tasks_from: create_svi.yml # Final result = create VLAN and SVI for predefined group When im running my code when my inventory file mentions only one of the machines TEST-NXOS2/TEST-NXOS3 the code is working perfectly. But when adding a second host (doesn't matter if NXOS2 or 3 is added) the code fails with this error: [image: ansible ping proof.PNG] Working run proof on one host: [image: ansible ping proof.PNG] What am I missing here? Am I supposed to tell it to run for each line in POC_ENV.yml file or is it already supposed to know it? because from what I understand ansible is supposed to run on all hosts in parallel and not itterate one by one.. Thanks in advance, YP -- 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/86afaa6c-f080-46a7-b6c1-552142c773f2%40googlegroups.com.
[ansible-project] Re: Need help on building ansible inventory file properly
Last question. How can I do that correctly? --- - name: Playing VLAN Configuration hosts: POC_ENV connection: local vars: vlan_id: 999 vlan_name: TEST_VLAN_TEST tasks: - include_role: name: vlan_creation tasks_from: show_vlan.yml tasks_from: add_vlan.yml # Final result = run show_vlan on requested predefined group My goal is to run multiple tasks that located inside vlan_creation. One is show_vlan.yml and second is add_vlan.yml Currently this is not working and its ignoring show_vlan.yml task and performs only the last task which is add_vlan.yml. -- 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/c580443a-29e5-412e-aa50-80858864f3e7%40googlegroups.com.
[ansible-project] Re: Need help on building ansible inventory file properly
Hi Jon, Thank you so much, it's working now. Also, much thanks Vladimir for his assistance. Take care. -- 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/e092255a-6f06-4c85-962b-6474e0ecb2e4%40googlegroups.com.
[ansible-project] Re: Need help on building ansible inventory file properly
*Hi,* *I have followed the instruction and it's working so my inventories are now working like I wanted. My end goal is to ssh to the specified machine in POC_ENV inventory (TEST-AGG-SW) and run the command "show vlan brief" and return it to stdout.* *For some reason it is not working and im not even sure if my code runs the show vlan br but not post it to stdout or not sure if it even performs the SSH to the switch or not.* *My configuration:* *This is my playbook:* --- - name: Playing VLAN Configuration hosts: POC_ENV connection: local vars: vlan_id: 999 vlan_name: TEST_VLAN_TEST tasks: - include_role: name: vlan_creation # Final result = run show_vlan on requested predefined group *This is the inventory file that he take the switch TEST-AGG-SW from:* all: children: POC_ENV: hosts: TEST-AGG-SW vars: ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible *This is the role that is located on /etc/ansible/roles/vlan_creation/tasks/show_vlan.yml:* --- - name: Show VLAN ios_command: commands: show vlan brief register: show_vlan - debug: msg="{{ show_vlan.stdout }}" *Basically, all it does its the execute the show vlan brief command on the switch and register it in show_vlan variable and supposed to print it to my screen with stdout_lines.* *The playbook result and the playbook result with -v is posted below this sentence.* [ansible@Netauto-Dev ansible]$ ansible-playbook playbook.yml PLAY [Playing VLAN Configuration] * TASK [Gathering Facts] ok: [TEST-AGG-SW] TASK [include_role : vlan_creation] *** PLAY RECAP TEST-AGG-SW: ok=1changed=0unreachable=0 failed=0skipped=0rescued=0ignored=0 [ansible@Netauto-Dev ansible]$ [ansible@Netauto-Dev ansible]$ ansible-playbook -v playbook.yml 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)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /etc/ansible/inventory/DC_Jaffa.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/DC_Jaffa.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/DC_Jaffa.yml inventory source with ini plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/DC_PT.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/DC_PT.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/DC_PT.yml inventory source with ini plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/POC_ENV.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/POC_ENV.yml inventory source with yaml plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/avaya.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/avaya.yml inventory source with ini plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/branch_router.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/branch_router.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/branch_router.yml inventory source with ini plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method script declined parsing /etc/ansible/inventory/branch_switch.yml as it did not pass its verify_file() method Parsed /etc/ansible/inventory/branch_switch.yml inventory source with ini plugin setting up inventory plugins host_list declined parsing /etc/ansible/inventory/megalab.yml as it did not pass its verify_file() method script declined parsing
[ansible-project] Re: Need help on building ansible inventory file properly
Hi Hawkesworth, I have followed your instruction and it's working so my inventories are now working like I wanted. My end goal is to run show_vlan.yml role on the requested inventory but im getting syntax problem on my include_role module. (ansible now fetching the right hosts from the right inventory just like I wanted so the inventory problem is behind us) About the role configuration, This is my playbook: --- - name: Playing VLAN Configuration hosts: POC_ENV connection: local vars: ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible vlan_id: 999 vlan_name: TEST_VLAN_TEST tasks: - include_role: name: show_vlan # Final result = run show_vlan on requested predefined group This is the role that is located on /etc/ansible/roles/tasks/show_vlan.yml: --- - name: Show VLAN ios_command: commands: show vlan brief register: show_vlan - debug: var=show_vlan.stdout_lines Basically, all it does its the execute the show vlan brief command on the switch and register it in show_vlan variable and supposed to print it to my screen with stdout_lines. As you can see in the error below it is failing for some reason, seems that its failing to find the role show_vlan that I have requested: [image: Ansible add vlans errors.PNG] What am I missing? Thanks in advance! מאת J Hawkesworth: > > I suggest doing this: > > mkdir /etc/ansible/inventory > # copy POC_ENV.yml, avaya.yml, nexus.yml to /etc/ansible/inventory > changing your ansible.cfg so that it looks for inventory in > > /etc/ansible/inventory > > IIRC that will load all the inventory files in that directory > > I have not tried this using .yaml format inventory file but it works fine > using ini format so I suspect it will work ok using .yaml format inventory. > > If you run > ansible-playbook -vv a_test_playbook.yml > > the first few lines will show you where it is looking for inventory and > what plugins it is using to parse and load your inventory. > > Hope this helps, > > Jon > > On Tuesday, December 31, 2019 at 10:13:25 AM UTC, Yehuda Pinhas wrote: >> >> Hi J Hawkesworth, >> Can you explain exactly in which file do I need to add what code? >> >> Considering I have the inventories POC_ENV.yml, avaya.yml, nexus.yml for >> example. What file do I need to edit? the ansible.cfg and the inventory >> file? can you provide the exact solution? >> >> currently my ansible.cfg file directs to /etc/ansible/inventory.yml >> >> and my inventory.yml is empty (which is the master inventory as i >> understand and from it I am supposed to direct ansible to each one of the >> inventories mentioned above such as POC_ENV.yml,etc.) >> >> >> >> >> >> J Hawkesworth: >>> >>> I suggest using a directory that contains the files you need to build up >>> your inventory. You can also use symlinks I think >>> This is described in the documentation in the section starting >>> '*Aggregating >>> inventory sources with a directory' *here: >>> >>> https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#using-multiple-inventory-sources >>> >>> I think this might be a simpler way to achieve what you want rather than >>> using add_host and including lots of inventory files directly into your >>> playbook. >>> >>> It does depend on not having hostnames that clash of course. >>> >>> Hope this helps, >>> >>> Jon >>> >>>> >>>> -- 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/efed4aa7-01eb-4b0e-be00-5aa3d74090a6%40googlegroups.com.
[ansible-project] Re: Need help on building ansible inventory file properly
Hi Hawkesworth, I have followed your instruction and it's working so my inventories are now working like I wanted. My end goal is to run show_vlan.yml role on the requested inventory but im getting syntax problem on my include_role module. (ansible now fetching the right hosts from the right inventory just like I wanted so the inventory problem is behind us) About the role configuration, This is my playbook: - name: Loading Ansible Environment hosts: POC_ENV connection: local vars: vlan_id: 999 vlan_name: TEST_VLAN_TEST ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible - name: Playing VLAN Configuration include_role: name: show_vlan.yml # Final result = run show_vlan on requested predefined group This is my show_vlan.yml file that is located on /etc/ansible/roles/show_vlan.yml: - name: Show VLAN ios_command: commands: show vlan brief register: show_vlan - debug: var=show_vlan.stdout_lines basically, all it does its the execute the show vlan brief command on the switch and register it in show_vlan variable. As you can see in the error below it is failing on syntax problem: [image: Ansible add vlans errors.PNG] What is wrong in my playbook.yml file? and can you please tell me if my show_vlan.yml located properly on my directory and if it is configured correctly. Thanks in advance.! מאת J Hawkesworth: > > I suggest doing this: > > mkdir /etc/ansible/inventory > # copy POC_ENV.yml, avaya.yml, nexus.yml to /etc/ansible/inventory > changing your ansible.cfg so that it looks for inventory in > > /etc/ansible/inventory > > IIRC that will load all the inventory files in that directory > > I have not tried this using .yaml format inventory file but it works fine > using ini format so I suspect it will work ok using .yaml format inventory. > > If you run > ansible-playbook -vv a_test_playbook.yml > > the first few lines will show you where it is looking for inventory and > what plugins it is using to parse and load your inventory. > > Hope this helps, > > Jon > > On Tuesday, December 31, 2019 at 10:13:25 AM UTC, Yehuda Pinhas wrote: >> >> Hi J Hawkesworth, >> Can you explain exactly in which file do I need to add what code? >> >> Considering I have the inventories POC_ENV.yml, avaya.yml, nexus.yml for >> example. What file do I need to edit? the ansible.cfg and the inventory >> file? can you provide the exact solution? >> >> currently my ansible.cfg file directs to /etc/ansible/inventory.yml >> >> and my inventory.yml is empty (which is the master inventory as i >> understand and from it I am supposed to direct ansible to each one of the >> inventories mentioned above such as POC_ENV.yml,etc.) >> >> >> >> >> >> J Hawkesworth: >>> >>> I suggest using a directory that contains the files you need to build up >>> your inventory. You can also use symlinks I think >>> This is described in the documentation in the section starting >>> '*Aggregating >>> inventory sources with a directory' *here: >>> >>> https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#using-multiple-inventory-sources >>> >>> I think this might be a simpler way to achieve what you want rather than >>> using add_host and including lots of inventory files directly into your >>> playbook. >>> >>> It does depend on not having hostnames that clash of course. >>> >>> Hope this helps, >>> >>> Jon >>> >>>> >>>> -- 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/b3a6afcc-75ae-4a79-9850-92bd069647ac%40googlegroups.com.
[ansible-project] Re: Need help on building ansible inventory file properly
Hi J Hawkesworth, Can you explain exactly in which file do I need to add what code? Considering I have the inventories POC_ENV.yml, avaya.yml, nexus.yml for example. What file do I need to edit? the ansible.cfg and the inventory file? can you provide the exact solution? currently my ansible.cfg file directs to /etc/ansible/inventory.yml and my inventory.yml is empty (which is the master inventory as i understand and from it I am supposed to direct ansible to each one of the inventories mentioned above such as POC_ENV.yml,etc.) J Hawkesworth: > > I suggest using a directory that contains the files you need to build up > your inventory. You can also use symlinks I think > This is described in the documentation in the section starting '*Aggregating > inventory sources with a directory' *here: > > https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#using-multiple-inventory-sources > > I think this might be a simpler way to achieve what you want rather than > using add_host and including lots of inventory files directly into your > playbook. > > It does depend on not having hostnames that clash of course. > > Hope this helps, > > Jon > >> >> -- 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/0445ecf9-c3ca-4617-ba4a-4cbee6caee66%40googlegroups.com.
Re: [ansible-project] Need help on building ansible inventory file properly
> > > Alright! Thanks for your help so far, now it's working without errors. Ignore previous messages and lets talk about the current status. The result I get is: [image: Ansible add vlans errors.PNG] The result I'm expecting to see is that the ansible will run on each line inside POC_ENV.yml the task show_vlan. The task show_vlan redirects to the "roles" folder where there is a show_vlan.yml file with the commands I want to execute on the remote host (from POC_ENV per line) I want to store the result of the show_vlan.yml in a variable and print it. This is the show_vlan.yml content: - name: Show VLAN ios_command: commands: show vlan brief register: show_vlan - debug: var=show_vlan.stdout_lines What am I missing next? -- 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/98275919-5960-4ef1-a81f-1fd55cfe3fed%40googlegroups.com.
Re: [ansible-project] Need help on building ansible inventory file properly
> > Alright so this is how my playbook looks like now: - name: Playing VLAN Configuration hosts: localhost # connection: local vars: vlan_id: 999 vlan_name: TEST_VLAN_TEST my_hosts: - group: 'POC_ENV' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/POC_ENV.yml').splitlines() }}" - group: 'Nexus' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/nexus.yml').splitlines() }}" - group: 'switch' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/switch.yml').splitlines() }}" - group: 'avaya' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/avaya.yml').splitlines() }}" - group: 'branch_switch' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/branch_switch.yml').splitlines() }}" - group: 'branch_router' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/branch_router.yml').splitlines() }}" - group: 'megalab' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/megalab.yml').splitlines() }}" - group: 'DC_Jaffa' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/DC_Jaffa.yml').splitlines() }}" - group: 'DC_PT' hosts: "{{ lookup('file','/etc/ansible/ansible_inventories/DC_PT.yml').splitlines() }}" tasks: - add_host: name: "{{ item.1 }}" groups: "{{ item.0.group }}" ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible loop: "{{ lookup('subelements', my_hosts, 'hosts') }}" - hosts: POC_ENV tasks: - debug: msg: "{{ msg.split('\n') }}" vars: msg: | host [{{ inventory_hostname }}] key [{{ ansible_ssh_private_key_file}}] args [{{ ansible_ssh_common_args }}] user [{{ ansible_user }}] - include_role: name: show_vlan # Final result = run show_vlan on requested predefined group These are the errors that i'm receiving when running the command: $ ansible-playbook myplaybook.yml [image: Ansible add vlans errors.PNG] Notes: - Please note that my ansible.cfg files directs to a inventory.yml file while I have many inventories (listed in the playbook code POC_ENV.yml, avaya.yml, etc. This is the settings on ansible.cfg: inventory = /etc/ansible/inventory.yml I'm not sure how to proceed, Thanks in advance. -- 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/2c48b744-c297-496b-ae9d-6712f4227e21%40googlegroups.com.
Re: [ansible-project] Need help on building ansible inventory file properly
> > Hi, > Can you please take a look on my errors and try to help me figuring out why I am getting them? This is my inventory code: - hosts: localhost vars: my_hosts: - group: 'POC_ENV' hosts: "{{ lookup('file', '/home/ansible/MACCABI/hosts/POC_ENV.yml').splitlines() }}" vars: ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa ansible_ssh_common_args: -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ansible_user: ansible This is my playbook code (task is to add a VLAN): name: Playing VLAN Configuration hosts: POC-ENV connection: local vars: vlan_id: 999 vlan_name: TEST_VLAN_TEST tasks: - include_role: name: add_vlan name: show_vlan This is the errors I get: [image: Ansible add vlans errors.PNG] 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/512c2e73-247b-400c-a6d9-fe5afb947d1f%40googlegroups.com.
Re: [ansible-project] Need help on building ansible inventory file properly
> > Hi again, Thanks a lot for your reply. I still don't understand what these code lines used for in my case: tasks: - add_host: name: "{{ item.1 }}" groups: "{{ item.0.group }}" loop: "{{ lookup('subelements', my_hosts, 'hosts') }}" can you please explain? I understand that you have wrote for me a lookup on the files mentioned for each lines which is exactly what I wanted. Now my intensions will be to copy and paste hosts of each environment to the appropriate host 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/2ce19398-e468-4f09-ae29-2f3104e81595%40googlegroups.com.
[ansible-project] Need help on building ansible inventory file properly
Hi, I have been searching all over the internet and there isn't any good documentation that explains how to build my inventory properly. The official documentation is bad and there aren't any example on inet that I could find. Can you please help me? I need to build inventory file that contains 6 groups total and each group will have around 100 hosts in it.. this is what I currently have. all: hosts: POC-ENV: hosts: ansible_host: /home/ansible/MACCABI/hosts/POC-ENV_list.yml Nexus: hosts: ansible_host: /home/ansible/MACCABI/hosts/nexus_list.yml Switches: hosts: ansible_host: /home/ansible/MACCABI/hosts/switch_list.yml Avaya: hosts: ansible_host: /home/ansible/MACCABI/avaya_list.yml Branch-Switches: hosts: ansible_host: /home/ansible/MACCABI/branch-switch_list.yml Branch-Routers: hosts: ansible_host: /home/ansible/MACCABI/branch-router_list.yml As you can see there are 6 groups: POC-ENV, Nexus, Switches, Avaya, Branch-Switches, Branch-Routers and I am trying to list all the hosts in a file and direct the inventory to read it from there since I have so many. What am I doing wrong? can you fix my code? Thanks for the helpers. -- 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/b719223a-57ff-49b4-8efa-56fcf01d1bee%40googlegroups.com.