※当サイトの記事には、広告・プロモーションが含まれます。

Ansibleでsshpassを利用した多段SSHでkex_exchange_identificationが出るのだが...

scienceportal.jst.go.jp

 神経細胞などの働きを光で制御する「光遺伝学」の手法を活用し、目の難病「網膜色素変性症」で失われた視覚の再生を目指す遺伝子治療薬の臨床試験(治験)を始めた、と慶應義塾大学と名古屋工業大学の共同研究グループが発表した。光遺伝学の臨床応用は国内初という。

光遺伝学を活用し、目の難病の視覚再生目指す 慶大など国内初の治験を開始 | Science Portal - 科学技術の最新情報サイト「サイエンスポータル」

⇧ amazing...

Ansibleでsshpassを利用した多段SSHでkex_exchange_identificationが出るのだが...

Ansibleでの多段SSHについては、

docs.ansible.com

⇧ 公式のドキュメントに説明があるのだが、何やら一向に「パスワード認証」が実行されないという...

『kex_exchange_identification』のエラーの原因は、ネットの情報を調べた感じでは、錯綜し過ぎていて、原因を特定するための調査の仕方が全く分からない...

とりあえず、自分の環境では、「パスワード認証」が利用されていないことだけは、何となく分かったのだが、

serverfault.com

⇧ 上記サイト様のように「SSHクライアント」側の設定をしてみたりするも、変わらずに「公開鍵認証」が利用されてしまうという...

とりあえず、埒が明かないので、

rheb.hatenablog.com

⇧ 上記サイト様を参考に、デバッグログを出してみる。

■AnsibleのPlaybookの実行結果

ts0818@ansible-controller:~/work/ansible$ ANSIBLE_DEBUG=true ansible-playbook -i inventory/hosts.yml test_ssh_jump_playbook.yml -vvvv
  8923 1741407211.01167: starting run
ansible-playbook [core 2.13.13]
  config file = /home/ts0818/work/ansible/ansible.cfg
  configured module search path = ['/home/ts0818/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ts0818/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ts0818/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ts0818/.local/bin/ansible-playbook
  python version = 3.8.10 (default, Feb  4 2025, 15:02:54) [GCC 9.4.0]
  jinja version = 3.1.6
  libyaml = True
Using /home/ts0818/work/ansible/ansible.cfg as config file
  8923 1741407211.02083: Added group all to inventory
  8923 1741407211.02114: Added group ungrouped to inventory
  8923 1741407211.02159: Group all now contains ungrouped
  8923 1741407211.02198: Examining possible inventory source: /home/ts0818/work/ansible/inventory/hosts.yml
setting up inventory plugins
  8923 1741407211.02509: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/cache
  8923 1741407211.02670: Loading CacheModule 'memory' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/cache/memory.py
  8923 1741407211.02826: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory
  8923 1741407211.03034: Loading InventoryModule 'host_list' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/host_list.py
  8923 1741407211.03165: Loaded config def from plugin (inventory/script)
  8923 1741407211.03200: Loading InventoryModule 'script' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/script.py
  8923 1741407211.03346: Loading InventoryModule 'auto' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/auto.py
  8923 1741407211.03606: Loaded config def from plugin (inventory/yaml)
  8923 1741407211.03724: Loading InventoryModule 'yaml' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/yaml.py
  8923 1741407211.04075: Loading InventoryModule 'ini' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/ini.py
  8923 1741407211.04352: Loading InventoryModule 'toml' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/toml.py
  8923 1741407211.04408: Attempting to use plugin host_list (/home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/host_list.py)
host_list declined parsing /home/ts0818/work/ansible/inventory/hosts.yml as it did not pass its verify_file() method
  8923 1741407211.04542: Attempting to use plugin script (/home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/script.py)
script declined parsing /home/ts0818/work/ansible/inventory/hosts.yml as it did not pass its verify_file() method
  8923 1741407211.04679: Attempting to use plugin auto (/home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/auto.py)
  8923 1741407211.04738: Loading data from /home/ts0818/work/ansible/inventory/hosts.yml
  8923 1741407211.05100: /home/ts0818/work/ansible/inventory/hosts.yml was not parsable by auto
  8923 1741407211.05377: Attempting to use plugin yaml (/home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/inventory/yaml.py)
  8923 1741407211.05521: Loading data from /home/ts0818/work/ansible/inventory/hosts.yml
  8923 1741407211.05622: group all already in inventory
  8923 1741407211.05698: set inventory_file for nijyo
  8923 1741407211.05752: set inventory_dir for nijyo
  8923 1741407211.05787: Added host nijyo to inventory
  8923 1741407211.05833: Added host nijyo to group all
Parsed /home/ts0818/work/ansible/inventory/hosts.yml inventory source with yaml plugin
  8923 1741407211.05900: Reconcile groups and hosts in inventory.
  8923 1741407211.05979: Group ungrouped now contains nijyo
  8923 1741407211.06776: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments
  8923 1741407211.06955: Loading ModuleDocFragment 'vars_plugin_staging' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/vars_plugin_staging.py
  8923 1741407211.07146: Loaded config def from plugin (vars/host_group_vars)
  8923 1741407211.07190: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py
  8923 1741407211.07349: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.07503: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.07592: Loading CacheModule 'memory' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/cache/memory.py (found_in_cache=True, class_only=False)
  8923 1741407211.09356: Loading ModuleDocFragment 'connection_pipelining' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/connection_pipelining.py
  8923 1741407211.09470: Loaded config def from plugin (connection/local)
  8923 1741407211.09504: Loading Connection 'local' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/local.py (found_in_cache=False, class_only=True)
  8923 1741407211.09983: Loaded config def from plugin (connection/paramiko_ssh)
  8923 1741407211.10055: Loading Connection 'paramiko_ssh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/paramiko_ssh.py (found_in_cache=False, class_only=True)
  8923 1741407211.11116: Loading ModuleDocFragment 'connection_pipelining' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/connection_pipelining.py (found_in_cache=True, class_only=False)
  8923 1741407211.11182: Loaded config def from plugin (connection/psrp)
  8923 1741407211.11320: Loading Connection 'psrp' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/psrp.py (found_in_cache=False, class_only=True)
  8923 1741407211.12422: Loading ModuleDocFragment 'connection_pipelining' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/connection_pipelining.py (found_in_cache=True, class_only=False)
  8923 1741407211.12589: Loaded config def from plugin (connection/ssh)
  8923 1741407211.12636: Loading Connection 'ssh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/ssh.py (found_in_cache=False, class_only=True)
  8923 1741407211.13632: Loading ModuleDocFragment 'connection_pipelining' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/connection_pipelining.py (found_in_cache=True, class_only=False)
  8923 1741407211.13737: Loaded config def from plugin (connection/winrm)
  8923 1741407211.13778: Loading Connection 'winrm' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/winrm.py (found_in_cache=False, class_only=True)
  8923 1741407211.14089: Loading ModuleDocFragment 'shell_windows' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/shell_windows.py
  8923 1741407211.14244: Loaded config def from plugin (shell/cmd)
  8923 1741407211.14353: Loading ShellModule 'cmd' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell/cmd.py (found_in_cache=False, class_only=True)
  8923 1741407211.14505: Loading ModuleDocFragment 'shell_windows' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/shell_windows.py (found_in_cache=True, class_only=False)
  8923 1741407211.14640: Loaded config def from plugin (shell/powershell)
  8923 1741407211.14685: Loading ShellModule 'powershell' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell/powershell.py (found_in_cache=False, class_only=True)
  8923 1741407211.14841: Loading ModuleDocFragment 'shell_common' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/shell_common.py
  8923 1741407211.15091: Loaded config def from plugin (shell/sh)
  8923 1741407211.15260: Loading ShellModule 'sh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell/sh.py (found_in_cache=False, class_only=True)
  8923 1741407211.15568: Loaded config def from plugin (become/runas)
  8923 1741407211.15626: Loading BecomeModule 'runas' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/become/runas.py (found_in_cache=False, class_only=True)
  8923 1741407211.15916: Loaded config def from plugin (become/su)
  8923 1741407211.15975: Loading BecomeModule 'su' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/become/su.py (found_in_cache=False, class_only=True)
  8923 1741407211.16455: Loaded config def from plugin (become/sudo)
  8923 1741407211.16517: Loading BecomeModule 'sudo' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/become/sudo.py (found_in_cache=False, class_only=True)
  8923 1741407211.16611: Loading data from /home/ts0818/work/ansible/test_ssh_jump_playbook.yml
  8923 1741407211.21054: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback
  8923 1741407211.21249: Loading ModuleDocFragment 'default_callback' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/default_callback.py
  8923 1741407211.21834: Loading ModuleDocFragment 'result_format_callback' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/result_format_callback.py
  8923 1741407211.22083: Loaded config def from plugin (callback/default)
  8923 1741407211.22183: Loading CallbackModule 'default' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/default.py
Loading callback plugin default of type stdout, v2.0 from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/default.py
  8923 1741407211.22481: Loading CallbackModule 'default' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/default.py (found_in_cache=True, class_only=True)
  8923 1741407211.23733: Loaded config def from plugin (callback/junit)
  8923 1741407211.23791: Loading CallbackModule 'junit' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/junit.py (found_in_cache=False, class_only=True)
  8923 1741407211.23883: Loading ModuleDocFragment 'result_format_callback' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/doc_fragments/result_format_callback.py (found_in_cache=True, class_only=False)
  8923 1741407211.23989: Loaded config def from plugin (callback/minimal)
  8923 1741407211.24068: Loading CallbackModule 'minimal' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/minimal.py (found_in_cache=False, class_only=True)
  8923 1741407211.24157: Loading CallbackModule 'oneline' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/oneline.py (found_in_cache=False, class_only=True)
  8923 1741407211.24244: Loaded config def from plugin (callback/tree)
  8923 1741407211.24271: Loading CallbackModule 'tree' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/callback/tree.py (found_in_cache=False, class_only=True)
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: test_ssh_jump_playbook.yml **************************************************************************************************************************************************************************************
Positional arguments: test_ssh_jump_playbook.yml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/ts0818/work/ansible/inventory/hosts.yml',)
forks: 5
1 plays in test_ssh_jump_playbook.yml
  8923 1741407211.24922: in VariableManager get_vars()
  8923 1741407211.25015: done with get_vars()
  8923 1741407211.25049: in VariableManager get_vars()
  8923 1741407211.25130: done with get_vars()
  8923 1741407211.25180: variable 'omit' from source: magic vars
  8923 1741407211.25240: in VariableManager get_vars()
  8923 1741407211.25460: done with get_vars()
  8923 1741407211.25553: variable 'omit' from source: magic vars

PLAY [Test SSH Jump] ******************************************************************************************************************************************************************************************************
  8923 1741407211.26685: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/strategy
  8923 1741407211.26916: Loading StrategyModule 'linear' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/strategy/linear.py
  8923 1741407211.27086: getting the remaining hosts for this loop
  8923 1741407211.27137: done getting the remaining hosts for this loop
  8923 1741407211.27363: building list of next tasks for hosts
  8923 1741407211.27379: getting the next task for host nijyo
  8923 1741407211.27547: done getting next task for host nijyo
  8923 1741407211.27566:  ^ task is: TASK: Gathering Facts
  8923 1741407211.27574:  ^ state is: HOST STATE: block=0, task=0, rescue=0, always=0, run_state=IteratingStates.SETUP, fail_state=FailedStates.NONE, pending_setup=True, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
  8923 1741407211.27587: done building task lists
  8923 1741407211.27592: counting tasks in each state of execution
  8923 1741407211.27597: done counting tasks in each state of execution:
        num_setups: 1
        num_tasks: 0
        num_rescue: 0
        num_always: 0
  8923 1741407211.27734: advancing hosts in SETUP
  8923 1741407211.27831: starting to advance hosts
  8923 1741407211.28109: done advancing hosts to next task
  8923 1741407211.28196: getting variables
  8923 1741407211.28347: in VariableManager get_vars()
  8923 1741407211.28576: Calling all_inventory to load vars for nijyo
  8923 1741407211.28598: Calling groups_inventory to load vars for nijyo
  8923 1741407211.28621: Calling all_plugins_inventory to load vars for nijyo
  8923 1741407211.28760: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.28907:        processing dir /home/ts0818/work/ansible/inventory/group_vars
  8923 1741407211.28948: Loading data from /home/ts0818/work/ansible/inventory/group_vars/all.yml
  8923 1741407211.29151: Calling all_plugins_play to load vars for nijyo
  8923 1741407211.29192: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.29359: Calling groups_plugins_inventory to load vars for nijyo
  8923 1741407211.29437: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.29506:        processing dir /home/ts0818/work/ansible/inventory/group_vars
  8923 1741407211.29533: Calling groups_plugins_play to load vars for nijyo
  8923 1741407211.29802: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.29993: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.30034:        processing dir /home/ts0818/work/ansible/inventory/host_vars
  8923 1741407211.30231: Loading data from /home/ts0818/work/ansible/inventory/host_vars/nijyo.yml
  8923 1741407211.30388: Loading VarsModule 'host_group_vars' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/vars/host_group_vars.py (found_in_cache=True, class_only=False)
  8923 1741407211.30630: done with get_vars()
  8923 1741407211.30665: done getting variables
  8923 1741407211.30944: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/action
  8923 1741407211.31087: Loading ActionModule 'gather_facts' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/action/gather_facts.py (found_in_cache=False, class_only=True)
  8923 1741407211.31123: sending task start callback, copying the task so we can template it temporarily
  8923 1741407211.31164: done copying, going to template now
  8923 1741407211.31384: done templating
  8923 1741407211.31495: here goes the callback...

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************
task path: /home/ts0818/work/ansible/test_ssh_jump_playbook.yml:2
  8923 1741407211.31824: sending task start callback
  8923 1741407211.31952: entering _queue_task() for nijyo/gather_facts
  8923 1741407211.31976: Creating lock for gather_facts
  8923 1741407211.32477: worker is 1 (out of 1 available)
  8923 1741407211.32569: exiting _queue_task() for nijyo/gather_facts
  8923 1741407211.32756: done queuing things up, now waiting for results queue to drain
  8923 1741407211.32787: waiting for pending results...
  8928 1741407211.32755: running TaskExecutor() for nijyo/TASK: Gathering Facts
  8928 1741407211.32950: in run() - task a7f3c3e4-c44c-90e8-c9bb-00000000000d
  8928 1741407211.33032: variable 'ansible_search_path' from source: unknown
  8928 1741407211.33126: calling self._execute()
  8928 1741407211.33248: variable 'ansible_host' from source: inventory host_vars for 'nijyo'
  8928 1741407211.33396: variable 'ansible_user' from source: inventory host_vars for 'nijyo'
  8928 1741407211.33522: variable 'ansible_ssh_common_args' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.33603: variable 'omit' from source: magic vars
  8928 1741407211.33771: variable 'omit' from source: magic vars
  8928 1741407211.33833: variable 'omit' from source: magic vars
  8928 1741407211.33944: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection
  8928 1741407211.34028: Loading Connection 'ssh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/connection/ssh.py (found_in_cache=True, class_only=False)
  8928 1741407211.34128: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell
  8928 1741407211.34178: Loading ShellModule 'sh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
  8928 1741407211.34228: Loading ShellModule 'sh' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
  8928 1741407211.34300: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/become
  8928 1741407211.34409: Loading BecomeModule 'sudo' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/become/sudo.py (found_in_cache=True, class_only=False)
  8928 1741407211.34495: variable 'inventory_hostname' from source: host vars for 'nijyo'
  8928 1741407211.34540: variable 'ansible_host' from source: inventory host_vars for 'nijyo'
  8928 1741407211.34575: variable 'ansible_ssh_common_args' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.35335: variable 'ebisugawa_ssh_pass' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.35387: variable 'ebisugawa_ssh_user' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.35412: variable 'ebisugawa_ssh_ip' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.35467: variable 'ansible_user' from source: inventory host_vars for 'nijyo'
  8928 1741407211.35704: Set connection var ansible_timeout to 10
  8928 1741407211.35737: Set connection var ansible_shell_executable to /bin/sh
  8928 1741407211.35784: Set connection var ansible_module_compression to ZIP_DEFLATED
  8928 1741407211.35817: Set connection var ansible_shell_type to sh
  8928 1741407211.35841: Set connection var ansible_pipelining to False
  8928 1741407211.35854: Set connection var ansible_connection to ssh
  8928 1741407211.35902: variable 'ansible_shell_executable' from source: unknown
  8928 1741407211.35931: variable 'ansible_connection' from source: unknown
  8928 1741407211.35958: variable 'ansible_module_compression' from source: unknown
  8928 1741407211.35990: variable 'ansible_shell_type' from source: unknown
  8928 1741407211.36001: variable 'ansible_shell_executable' from source: unknown
  8928 1741407211.36077: variable 'ansible_host' from source: inventory host_vars for 'nijyo'
  8928 1741407211.36100: variable 'ansible_user' from source: inventory host_vars for 'nijyo'
  8928 1741407211.36123: variable 'ansible_pipelining' from source: unknown
  8928 1741407211.36143: variable 'ansible_timeout' from source: unknown
  8928 1741407211.36164: variable 'ansible_ssh_common_args' from source: group vars, precedence entry 'all_plugins_inventory'
  8928 1741407211.36357: trying /home/ts0818/.local/lib/python3.8/site-packages/ansible/modules
  8928 1741407211.37057: Loading ActionModule 'gather_facts' from /home/ts0818/.local/lib/python3.8/site-packages/ansible/plugins/action/gather_facts.py (found_in_cache=True, class_only=False)
  8928 1741407211.37101: variable 'omit' from source: magic vars
  8928 1741407211.37129: starting attempt loop
  8928 1741407211.37151: running the handler
  8928 1741407211.37196: variable 'ansible_facts' from source: unknown
  8928 1741407211.37275: _low_level_execute_command(): starting
  8928 1741407211.37319: _low_level_execute_command(): executing: /bin/sh -c 'echo ~vagrant && sleep 0'
<192.168.111.104> ESTABLISH SSH CONNECTION FOR USER: vagrant
<192.168.111.104> SSH: EXEC ssh -vvv -o PreferredAuthentications=password -o PasswordAuthentication=yes -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="vagrant"' -o ConnectTimeout=10 -vvv -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o 'ProxyCommand=sshpass -p vagrant ssh -W %h:%p -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q vagrant@192.168.111.103' 192.168.111.104 '/bin/sh -c '"'"'echo ~vagrant && sleep 0'"'"''
  8928 1741407211.39486: stderr chunk (state=2):
>>>OpenSSH_8.2p1 Ubuntu-4ubuntu0.12, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/ts0818/.ssh/config
debug1: /home/ts0818/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
<<<
  8928 1741407211.40090: stderr chunk (state=3):
>>>debug2: resolve_canonicalize: hostname 192.168.111.104 is address
<<<
  8928 1741407211.40290: stderr chunk (state=3):
>>>debug1: Executing proxy command: exec sshpass -p vagrant ssh -W 192.168.111.104:22 -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q vagrant@192.168.111.103
debug3: timeout: 10000 ms remain after connect
<<<
  8928 1741407211.41689: stderr chunk (state=3):
>>>debug1: identity file /home/ts0818/.ssh/id_rsa type -1
debug1: identity file /home/ts0818/.ssh/id_rsa-cert type -1
debug1: identity file /home/ts0818/.ssh/id_dsa type -1
debug1: identity file /home/ts0818/.ssh/id_dsa-cert type -1
debug1: identity file /home/ts0818/.ssh/id_ecdsa type -1
debug1: identity file /home/ts0818/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ts0818/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/ts0818/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/ts0818/.ssh/id_ed25519 type -1
debug1: identity file /home/ts0818/.ssh/id_ed25519-cert type -1
debug1: identity file /home/ts0818/.ssh/id_ed25519_sk type -1
debug1: identity file /home/ts0818/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/ts0818/.ssh/id_xmss type -1
debug1: identity file /home/ts0818/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.12
<<<
  8928 1741407211.47126: stderr chunk (state=3):
>>>kex_exchange_identification: Connection closed by remote host
<<<
  8928 1741407211.47200: stdout chunk (state=3):
>>><<<
  8928 1741407211.47218: stderr chunk (state=3):
>>><<<
<192.168.111.104> (255, b'', b'OpenSSH_8.2p1 Ubuntu-4ubuntu0.12, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /home/ts0818/.ssh/config\r\ndebug1: /home/ts0818/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.111.104 is address\r\ndebug1: Executing proxy command: exec sshpass -p vagrant ssh -W 192.168.111.104:22 -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q vagrant@192.168.111.103\r\ndebug3: timeout: 10000 ms remain after connect\r\ndebug1: identity file /home/ts0818/.ssh/id_rsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_rsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_dsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_dsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa_sk type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa_sk-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519 type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519_sk type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519_sk-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_xmss type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_xmss-cert type -1\r\ndebug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.12\r\nkex_exchange_identification: Connection closed by remote host\r\n')
  8928 1741407211.47517: _execute() done
  8928 1741407211.47541: dumping result to json
  8928 1741407211.47548: done dumping result, returning
  8928 1741407211.47566: done running TaskExecutor() for nijyo/TASK: Gathering Facts [a7f3c3e4-c44c-90e8-c9bb-00000000000d]
  8928 1741407211.47690: sending task result for task a7f3c3e4-c44c-90e8-c9bb-00000000000d
  8928 1741407211.47842: done sending task result for task a7f3c3e4-c44c-90e8-c9bb-00000000000d
  8928 1741407211.48130: WORKER PROCESS EXITING
fatal: [nijyo]: UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: OpenSSH_8.2p1 Ubuntu-4ubuntu0.12, OpenSSL 1.1.1f  31 Mar 2020\r\ndebug1: Reading configuration data /home/ts0818/.ssh/config\r\ndebug1: /home/ts0818/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.111.104 is address\r\ndebug1: Executing proxy command: exec sshpass -p vagrant ssh -W 192.168.111.104:22 -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q vagrant@192.168.111.103\r\ndebug3: timeout: 10000 ms remain after connect\r\ndebug1: identity file /home/ts0818/.ssh/id_rsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_rsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_dsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_dsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa_sk type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ecdsa_sk-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519 type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519_sk type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_ed25519_sk-cert type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_xmss type -1\r\ndebug1: identity file /home/ts0818/.ssh/id_xmss-cert type -1\r\ndebug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.12\r\nkex_exchange_identification: Connection closed by remote host",
    "unreachable": true
}
  8923 1741407211.48569: no more pending results, returning what we have
  8923 1741407211.48671: results queue empty
  8923 1741407211.48708: checking for any_errors_fatal
  8923 1741407211.48739: done checking for any_errors_fatal
  8923 1741407211.48775: checking for max_fail_percentage
  8923 1741407211.48818: done checking for max_fail_percentage
  8923 1741407211.48883: checking to see if all hosts have failed and the running result is not ok
  8923 1741407211.48893: done checking to see if all hosts have failed
  8923 1741407211.48904: getting the remaining hosts for this loop
  8923 1741407211.48934: done getting the remaining hosts for this loop
  8923 1741407211.48952: building list of next tasks for hosts
  8923 1741407211.48961: done building task lists
  8923 1741407211.48984: counting tasks in each state of execution
  8923 1741407211.49017: done counting tasks in each state of execution:
        num_setups: 0
        num_tasks: 0
        num_rescue: 0
        num_always: 0
  8923 1741407211.49163: all hosts are done, so returning None's for all hosts
  8923 1741407211.49185: done queuing things up, now waiting for results queue to drain
  8923 1741407211.49271: results queue empty
  8923 1741407211.49310: checking for any_errors_fatal
  8923 1741407211.49331: done checking for any_errors_fatal
  8923 1741407211.49343: checking for max_fail_percentage
  8923 1741407211.49354: done checking for max_fail_percentage
  8923 1741407211.49364: checking to see if all hosts have failed and the running result is not ok
  8923 1741407211.49375: done checking to see if all hosts have failed
  8923 1741407211.49402: running handlers

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

  8923 1741407211.50127: RUNNING CLEANUP
ts0818@ansible-controller:~/work/ansible$    

⇧ うむ、サッパリ分からん...

何やら、

serverfault.com

⇧ 上記サイト様によりますと、「Ansible」側でハードコーディングされてしまっているという話があり、

github.com

⇧ 確認してみたところ、確かに、ハードコーディングされてはいるのだが、そんなことより、「Ansible」側で変数名が指定されているという方にしてやられましたと...

最終的なコードは以下のようになりました。

■/home/ts0818/.ssh/config

Host *
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null
#  PreferredAuthentications password
#  PasswordAuthentication yes
#  PubKeyAuthentication no

⇧ ~/.ssh/configの設定は、「ansible_ssh_common_args:」の方で設定しているので不要かも。

■/home/ts0818/ansible/inventory/group_vars/all.yml

ebisugawa_ssh_ip: 192.168.111.103
ebisugawa_ssh_user: vagrant
ebisugawa_ssh_pass: vagrant

ansible_ssh_common_args: '-o ProxyCommand="sshpass -p {{ ebisugawa_ssh_pass }} ssh -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q {{ ebisugawa_ssh_user }}@{{ ebisugawa_ssh_ip }}"'
#ansible_ssh_common_args: ' -o PasswordAuthentication=yes -o PreferredAuthentications=password -o ProxyCommand="sshpass -p {{ ebisugawa_ssh_pass }} ssh -W %h:%p -o PasswordAuthentication=yes -o PreferredAuthentications=password -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q {{ ebisugawa_ssh_user }}@{{ ebisugawa_ssh_ip }}"'
#ansible_ssh_common_args: '-o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ProxyCommand="sshpass -p {{ ebisugawa_ssh_pass }} ssh -W %h:%p -o PreferredAuthentications=password -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q {{ ebisugawa_ssh_user }}@{{ ebisugawa_ssh_ip }}"'

■/home/ts0818/ansible/inventory/host_vars/nijyo.yml

# ansible_ssh_ip: 192.168.111.104
# ansible_ssh_user: vagrant
# ansible_ssh_pass: vagrant
# Ansible側で用意している変数名である必要がある
# https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/connection/ssh.py
ansible_ssh_host: 192.168.111.104
ansible_ssh_user: vagrant
ansible_ssh_pass: vagrant

#ansible_ssh_common_args: '-o ProxyCommand="sshpass -p {{ ebisugawa_ssh_pass }} ssh -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q {{ ebisugawa_ssh_user }}@{{ ebisugawa_ssh_ip }}"'
    

■/home/ts0818/ansible/inventory/hosts.yml

all:
  hosts:
    nijyo:    

■/home/ts0818/ansible/test_ssh_jump_playbook.yml

---
- name: Test SSH Jump
  hosts: nijyo
#  become: false

  tasks:
    - name: Get OS infomation
      ansible.builtin.setup:

    - name: Show OS information
      ansible.builtin.debug:
        msg:
          - "OSタイプ: {{ ansible_distribution }} {{ ansible_distribution_version }}"
          - "CPU情報: {{ ansible_processor }} (コア数: {{ ansible_processor_cores }})"
          - "メモリ: 合計{{ ansible_memtotal_mb }} MB, 利用可能{{ ansible_memfree_mb }} MB"
          - "ディスク使用状況: {{ ansible_mounts }}"
          - "アップタイム: {{ ansible_uptime_seconds }}秒    

⇧ で保存して、Playbookを実行する。

■キャッシュなしでPlaybook実行

ansible-playbook -i inventory/hosts.yml test_ssh_jump_playbook.yml --flush-cache

勿論、「Ansible」で「SSH」接続しにいく「仮想マシン(VM:Virtual Machine)」側の「/etc/ssh/sshd_config」などで「パスワード認証」を許可しておく必要はある。

ちなみに、自分の環境では、「Ubuntu 20.04 LTS」の方の「SSHサーバー」の設定で「/etc/ssh/sshd_config.d/60-cloudimg-settings.conf」なるファイルで、「PasswordAuthentication no」になっているのに気付くまでに相当時間を無駄にしてしまった...

もし、「パスワード認証」を実現したい場合は「PasswordAuthentication yes」にしておくのを忘れずに。

 

それにしても、「Ansible」も独自のルールが多過ぎて辛い...

とりあえず、「Ansible」の用意している「変数名」を利用せねばならないのであれば、公式のドキュメントで注意書きしておいて欲しい...

休日が潰れてしまったではないか...

毎度モヤモヤ感が半端ない…

今回はこのへんで。