yumekiti-archive / ansible_zemi

0 stars 0 forks source link

`fix` connect error #1

Closed yumekiti closed 1 year ago

yumekiti commented 1 year ago
$ ansible-playbook -i hosts main.yml -vvvv
ansible-playbook [core 2.13.5]
  config file = None
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = True
No config file found; using defaults
setting up inventory plugins
host_list declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
script declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
auto declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
Parsed /home/ubuntu/codes/ansible_zemi/hosts inventory source with ini plugin
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
Loading collection cisco.ios from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios
Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/.local/lib/python3.10/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: main.yml *****************************************************************************************************************************************************************************************************
Positional arguments: main.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/ubuntu/codes/ansible_zemi/hosts',)
forks: 5
1 plays in main.yml

PLAY [cisco] ***********************************************************************************************************************************************************************************************************
META: ran handlers

TASK [send show version] ***********************************************************************************************************************************************************************************************
task path: /home/ubuntu/codes/ansible_zemi/main.yml:5
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/ansible/netcommon
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> attempting to start connection
<10.16.10.77> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<10.16.10.77> local domain socket does not exist, starting it
<10.16.10.77> control socket path is /home/ubuntu/.ansible/pc/37473572d9
<10.16.10.77> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<10.16.10.77> Loading collection ansible.netcommon from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/ansible/netcommon
<10.16.10.77> redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> Loading collection cisco.ios from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios
<10.16.10.77> redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> local domain socket listeners started successfully
<10.16.10.77> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os ios
<10.16.10.77> ssh type is set to auto
<10.16.10.77> autodetecting ssh_type
<10.16.10.77> ssh type is now set to libssh
<10.16.10.77> 
<10.16.10.77> local domain socket path is /home/ubuntu/.ansible/pc/37473572d9
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> Using network group action ios for ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: found ios_command  at /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_command.py
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: running ios_command
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: complete
The full traceback is:
  File "/home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py", line 97, in get_capabilities
    capabilities = Connection(module._socket_path).get_capabilities()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [10.16.10.77]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "show version"
            ],
            "interval": 1,
            "match": "all",
            "provider": null,
            "retries": 10,
            "wait_for": null
        }
    },
    "msg": "ssh connection failed: ssh connect failed: Failed to resolve hostname inventory_hostname (Temporary failure in name resolution)"
}

PLAY RECAP *************************************************************************************************************************************************************************************************************
10.16.10.77                : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
yumekiti commented 1 year ago
$ pip list | grep ansible
ansible                6.5.0
ansible-base           2.10.8
ansible-core           2.13.5
ansible-pylibssh       1.0.0
yumekiti commented 1 year ago
$ ansible --version
ansible [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = True
yumekiti commented 1 year ago

パッケージ周り怪しいので再インストールする。

sudo apt remove ansible
sudo apt purge ansible

sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
$ pip list | grep ansible
ansible                6.5.0
ansible-core           2.13.5
ansible-pylibssh       1.0.0
$ ansible --version 
ansible [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = Tru
yumekiti commented 1 year ago

直ったwww

$ ansible-playbook -i hosts main.yml -vvvv
ansible-playbook [core 2.13.5]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
  jinja version = 3.0.3
  libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
script declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
auto declined parsing /home/ubuntu/codes/ansible_zemi/hosts as it did not pass its verify_file() method
Parsed /home/ubuntu/codes/ansible_zemi/hosts inventory source with ini plugin
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
Loading collection cisco.ios from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios
Loading callback plugin default of type stdout, v2.0 from /home/ubuntu/.local/lib/python3.10/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: main.yml *****************************************************************************************************************************************************************************************************
Positional arguments: main.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/ubuntu/codes/ansible_zemi/hosts',)
forks: 5
1 plays in main.yml

PLAY [cisco] ***********************************************************************************************************************************************************************************************************
META: ran handlers

TASK [send show version] ***********************************************************************************************************************************************************************************************
task path: /home/ubuntu/codes/ansible_zemi/main.yml:5
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/ansible/netcommon
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> attempting to start connection
<10.16.10.77> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/bin/ansible-connection
<10.16.10.77> local domain socket does not exist, starting it
<10.16.10.77> control socket path is /home/ubuntu/.ansible/pc/335cd5e3b5
<10.16.10.77> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<10.16.10.77> Loading collection ansible.netcommon from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/ansible/netcommon
<10.16.10.77> redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> Loading collection cisco.ios from /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios
<10.16.10.77> redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> local domain socket listeners started successfully
<10.16.10.77> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os ios
<10.16.10.77> ssh type is set to auto
<10.16.10.77> autodetecting ssh_type
<10.16.10.77> ssh type is now set to libssh
<10.16.10.77> 
<10.16.10.77> local domain socket path is /home/ubuntu/.ansible/pc/335cd5e3b5
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> Using network group action ios for ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: found ios_command  at /home/ubuntu/.local/lib/python3.10/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_command.py
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: running ios_command
<10.16.10.77> ANSIBLE_NETWORK_IMPORT_MODULES: complete
ok: [10.16.10.77] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "show version"
            ],
            "interval": 1,
            "match": "all",
            "provider": null,
            "retries": 10,
            "wait_for": null
        }
    },
    "stdout": [
        "Cisco IOS XE Software, Version 16.08.01\nCisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1, RELEASE SOFTWARE (fc3)\nTechnical Support: http://www.cisco.com/techsupport\nCopyright (c) 1986-2018 by Cisco Systems, Inc.\nCompiled Tue 27-Mar-18 13:43 by mcpre\n\n\nCisco IOS-XE software, Copyright (c) 2005-2018 by cisco Systems, Inc.\nAll rights reserved.  Certain components of Cisco IOS-XE software are\nlicensed under the GNU General Public License (\"GPL\") Version 2.0.  The\nsoftware code licensed under GPL Version 2.0 is free software that comes\nwith ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such\nGPL code under the terms of GPL Version 2.0.  For more details, see the\ndocumentation or \"License Notice\" file accompanying the IOS-XE software,\nor the applicable URL provided on the flyer accompanying the IOS-XE\nsoftware.\n\n\nROM: IOS-XE ROMMON\n\nR1 uptime is 2 hours, 39 minutes\nUptime for this control processor is 2 hours, 42 minutes\nSystem returned to ROM by PowerOn\nSystem restarted at 01:33:16 UTC Thu Oct 27 2022\nSystem image file is \"bootflash:isr4300-universalk9.16.08.01.SPA.bin\"\nLast reload reason: PowerOn\n\n\n\nThis product contains cryptographic features and is subject to United\nStates and local country laws governing import, export, transfer and\nuse. Delivery of Cisco cryptographic products does not imply\nthird-party authority to import, export, distribute or use encryption.\nImporters, exporters, distributors and users are responsible for\ncompliance with U.S. and local country laws. By using this product you\nagree to comply with applicable laws and regulations. If you are unable\nto comply with U.S. and local laws, return this product immediately.\n\nA summary of U.S. laws governing Cisco cryptographic products may be found at:\nhttp://www.cisco.com/wwl/export/crypto/tool/stqrg.html\n\nIf you require further assistance please contact us by sending email to\nexport@cisco.com.\n\n\n\nSuite License Information for Module:'esg' \n\n--------------------------------------------------------------------------------\nSuite                 Suite Current         Type           Suite Next reboot     \n--------------------------------------------------------------------------------\nFoundationSuiteK9     None                  None           None                  \nsecurityk9\nappxk9\n\nAdvUCSuiteK9          None                  None           None                  \nuck9\ncme-srst\ncube\n\n\nTechnology Package License Information: \n\n-----------------------------------------------------------------\nTechnology    Technology-package           Technology-package\n              Current       Type           Next reboot  \n------------------------------------------------------------------\nappxk9           None             None             None\nuck9             None             None             None\nsecurityk9       securityk9       Permanent        securityk9\nipbase           ipbasek9         Permanent        ipbasek9\n\ncisco ISR4331/K9 (1RU) processor with 1788457K/6147K bytes of memory.\nProcessor board ID FDO2516M1AS\n3 Gigabit Ethernet interfaces\n32768K bytes of non-volatile configuration memory.\n4194304K bytes of physical memory.\n3207167K bytes of flash memory at bootflash:.\n0K bytes of WebUI ODM Files at webui:.\n\nConfiguration register is 0x2102"
    ],
    "stdout_lines": [
        [
            "Cisco IOS XE Software, Version 16.08.01",
            "Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.8.1, RELEASE SOFTWARE (fc3)",
            "Technical Support: http://www.cisco.com/techsupport",
            "Copyright (c) 1986-2018 by Cisco Systems, Inc.",
            "Compiled Tue 27-Mar-18 13:43 by mcpre",
            "",
            "",
            "Cisco IOS-XE software, Copyright (c) 2005-2018 by cisco Systems, Inc.",
            "All rights reserved.  Certain components of Cisco IOS-XE software are",
            "licensed under the GNU General Public License (\"GPL\") Version 2.0.  The",
            "software code licensed under GPL Version 2.0 is free software that comes",
            "with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such",
            "GPL code under the terms of GPL Version 2.0.  For more details, see the",
            "documentation or \"License Notice\" file accompanying the IOS-XE software,",
            "or the applicable URL provided on the flyer accompanying the IOS-XE",
            "software.",
            "",
            "",
            "ROM: IOS-XE ROMMON",
            "",
            "R1 uptime is 2 hours, 39 minutes",
            "Uptime for this control processor is 2 hours, 42 minutes",
            "System returned to ROM by PowerOn",
            "System restarted at 01:33:16 UTC Thu Oct 27 2022",
            "System image file is \"bootflash:isr4300-universalk9.16.08.01.SPA.bin\"",
            "Last reload reason: PowerOn",
            "",
            "",
            "",
            "This product contains cryptographic features and is subject to United",
            "States and local country laws governing import, export, transfer and",
            "use. Delivery of Cisco cryptographic products does not imply",
            "third-party authority to import, export, distribute or use encryption.",
            "Importers, exporters, distributors and users are responsible for",
            "compliance with U.S. and local country laws. By using this product you",
            "agree to comply with applicable laws and regulations. If you are unable",
            "to comply with U.S. and local laws, return this product immediately.",
            "",
            "A summary of U.S. laws governing Cisco cryptographic products may be found at:",
            "http://www.cisco.com/wwl/export/crypto/tool/stqrg.html",
            "",
            "If you require further assistance please contact us by sending email to",
            "export@cisco.com.",
            "",
            "",
            "",
            "Suite License Information for Module:'esg' ",
            "",
            "--------------------------------------------------------------------------------",
            "Suite                 Suite Current         Type           Suite Next reboot     ",
            "--------------------------------------------------------------------------------",
            "FoundationSuiteK9     None                  None           None                  ",
            "securityk9",
            "appxk9",
            "",
            "AdvUCSuiteK9          None                  None           None                  ",
            "uck9",
            "cme-srst",
            "cube",
            "",
            "",
            "Technology Package License Information: ",
            "",
            "-----------------------------------------------------------------",
            "Technology    Technology-package           Technology-package",
            "              Current       Type           Next reboot  ",
            "------------------------------------------------------------------",
            "appxk9           None             None             None",
            "uck9             None             None             None",
            "securityk9       securityk9       Permanent        securityk9",
            "ipbase           ipbasek9         Permanent        ipbasek9",
            "",
            "cisco ISR4331/K9 (1RU) processor with 1788457K/6147K bytes of memory.",
            "Processor board ID FDO2516M1AS",
            "3 Gigabit Ethernet interfaces",
            "32768K bytes of non-volatile configuration memory.",
            "4194304K bytes of physical memory.",
            "3207167K bytes of flash memory at bootflash:.",
            "0K bytes of WebUI ODM Files at webui:.",
            "",
            "Configuration register is 0x2102"
        ]
    ]
}
META: ran handlers
META: ran handlers

PLAY RECAP *************************************************************************************************************************************************************************************************************
10.16.10.77                : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0