Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected failure during module execution #30

Open
KizzyCode opened this issue Mar 3, 2021 · 6 comments
Open

Unexpected failure during module execution #30

KizzyCode opened this issue Mar 3, 2021 · 6 comments
Assignees
Labels

Comments

@KizzyCode
Copy link

KizzyCode commented Mar 3, 2021

The plugin crashes when I try to execute the following task:

- name: Test
  command: "touch /Testolope.dat"
  connection: sshjail
  delegate_to: "{{ jail_name }}@{{ inventory_hostname }}"

(jail_name is defined and the jail is running; jexec works)

Playbook:

- hosts: all
  any_errors_fatal: true
  remote_user: root
  
  vars:
    - jail_name: playground

  tasks:
    - name: Test
      command: "touch /Testolope.dat"
      connection: sshjail
      delegate_to: "{{ jail_name }}@{{ inventory_hostname }}"

Traceback:

The full traceback is:
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 663, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/command.py", line 26, in run
    results = merge_hash(results, self._execute_module(module_name='ansible.legacy.command', task_vars=task_vars, wrap_async=wrap_async))
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 888, in _execute_module
    self._transfer_data(remote_module_path, module_data)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 498, in _transfer_data
    self._transfer_file(afile, remote_path)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 475, in _transfer_file
    self._connection.put_file(local_path, remote_path)
  File "/Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible/connection_plugins/sshjail.py", line 437, in put_file
    self._copy_file(tmp, out_path)
  File "/Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible/connection_plugins/sshjail.py", line 407, in _copy_file
    copycmd = plugin.build_become_command(' '.join(['cp', from_file, to_file]), shell)
AttributeError: 'NoneType' object has no attribute 'build_become_command'

Full ansible output:

ansible-playbook 2.10.6
  config file = /Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible.cfg
  configured module search path = ['/Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible/modules']
  ansible python module location = /usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.2 (default, Feb 24 2021, 13:26:09) [Clang 12.0.0 (clang-1200.0.32.29)]
Using /Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible.cfg as config file
Parsed 192.168.178.83, inventory source with host_list plugin
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: Playground.yml *****************************************************************************************************************************
1 plays in Jails.Playground/Playground.yml

PLAY [all] *******************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************
task path: /Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/Jails.Playground/Playground.yml:5
<192.168.178.83> Attempting python interpreter discovery
<192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 192.168.178.83 '/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'"'"''
<192.168.178.83> (0, b'PLATFORM\nFreeBSD\nFOUND\n/usr/local/bin/python3.7\n/usr/local/bin/python\nENDFOUND\n', b'')
<192.168.178.83> Python interpreter discovery fallback (unsupported platform for extended discovery: freebsd)
Using module file /usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/modules/setup.py
Pipelining is enabled.
<192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 192.168.178.83 '/bin/sh -c '"'"'/usr/local/bin/python3.7 && sleep 0'"'"''
<192.168.178.83> (0, b'\n{"ansible_facts": {"ansible_processor": ["Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz (3300.00-MHz K8-class CPU)", "Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz (3300.00-MHz K8-class CPU)", "Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz (3300.00-MHz K8-class CPU)"], "ansible_processor_count": "4", "ansible_memtotal_mb": 5969, "ansible_memfree_mb": 5063, "ansible_swaptotal_mb": 16384, "ansible_swapfree_mb": 16384, "ansible_bios_date": "NA", "ansible_bios_vendor": "NA", "ansible_bios_version": "NA", "ansible_board_asset_tag": "NA", "ansible_board_name": "NA", "ansible_board_serial": "NA", "ansible_board_vendor": "NA", "ansible_board_version": "NA", "ansible_chassis_asset_tag": "NA", "ansible_chassis_serial": "NA", "ansible_chassis_vendor": "NA", "ansible_chassis_version": "NA", "ansible_form_factor": "NA", "ansible_product_name": "NA", "ansible_product_serial": "NA", "ansible_product_uuid": "NA", "ansible_product_version": "NA", "ansible_system_vendor": "NA", "ansible_devices": {"cd0": [], "da0": []}, "ansible_mounts": [{"mount": "none", "device": "/dev/da0p2.eli", "fstype": "swap", "options": "sw,ealgo=AES-XTS,keylen=256"}], "ansible_hostnqn": "", "ansible_user_id": "root", "ansible_user_uid": 0, "ansible_user_gid": 0, "ansible_user_gecos": "Charlie &", "ansible_user_dir": "/root", "ansible_user_shell": "/usr/local/bin/zsh", "ansible_real_user_id": 0, "ansible_effective_user_id": 0, "ansible_real_group_id": 0, "ansible_effective_group_id": 0, "ansible_is_chroot": true, "ansible_system": "FreeBSD", "ansible_kernel": "12.2-RELEASE-p4", "ansible_kernel_version": "FreeBSD 12.2-RELEASE-p4 GENERIC", "ansible_machine": "amd64", "ansible_python_version": "3.7.9", "ansible_fqdn": "keziah-de.fritz.box", "ansible_hostname": "keziah-de", "ansible_nodename": "keziah-de", "ansible_domain": "fritz.box", "ansible_userspace_bits": "64", "ansible_architecture": "amd64", "ansible_date_time": {"year": "2021", "month": "03", "weekday": "Wednesday", "weekday_number": "3", "weeknumber": "09", "day": "03", "hour": "22", "minute": "25", "second": "41", "epoch": "1614806741", "date": "2021-03-03", "time": "22:25:41", "iso8601_micro": "2021-03-03T21:25:41.797010Z", "iso8601": "2021-03-03T21:25:41Z", "iso8601_basic": "20210303T222541797010", "iso8601_basic_short": "20210303T222541", "tz": "CET", "tz_offset": "+0100"}, "ansible_distribution": "FreeBSD", "ansible_distribution_release": "12.2-RELEASE-p4", "ansible_distribution_version": "12.2", "ansible_distribution_major_version": "12", "ansible_os_family": "FreeBSD", "ansible_selinux": {"status": "Missing selinux Python library"}, "ansible_selinux_python_present": false, "ansible_interfaces": ["bridge0", "em0", "lo0", "playground_host", "skeleton_host"], "ansible_em0": {"device": "em0", "ipv4": [{"address": "192.168.178.83", "netmask": "255.255.255.0", "network": "192.168.178.0", "broadcast": "192.168.178.255"}], "ipv6": [{"address": "fe80::20c:29ff:fe0d:6692%em0", "prefix": "64", "scope": "0x1"}, {"address": "2a02:8109:b5c0:28ac:20c:29ff:fe0d:6692", "prefix": "64"}], "type": "ether", "flags": ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], "macaddress": "00:0c:29:0d:66:92", "metric": "0", "mtu": "1500", "options": ["PERFORMNUD", "ACCEPT_RTADV", "AUTO_LINKLOCAL"], "media": "Ethernet", "media_select": "autoselect", "media_type": "1000baseT", "media_options": ["full-duplex"], "status": "active"}, "ansible_lo0": {"device": "lo0", "ipv4": [{"address": "127.0.0.1", "netmask": "255.0.0.0", "network": "127.0.0.0", "broadcast": "127.255.255.255"}], "ipv6": [{"address": "::1", "prefix": "128"}, {"address": "fe80::1%lo0", "prefix": "64", "scope": "0x2"}], "type": "loopback", "flags": ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "macaddress": "unknown", "metric": "0", "mtu": "16384", "options": ["PERFORMNUD", "AUTO_LINKLOCAL"]}, "ansible_bridge0": {"device": "bridge0", "ipv4": [{"address": "10.0.1.1", "netmask": "255.0.0.0", "network": "10.0.0.0", "broadcast": "10.255.255.255"}], "ipv6": [], "type": "ether", "flags": ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "macaddress": "02:32:d5:59:09:00", "metric": "0", "mtu": "1500", "options": ["PERFORMNUD", "IFDISABLED"]}, "ansible_playground_host": {"device": "playground_host", "ipv4": [], "ipv6": [{"address": "fe80::5a:d1ff:feca:4a0a%playground_host", "prefix": "64", "scope": "0x4"}], "type": "ether", "flags": ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], "macaddress": "02:5a:d1:ca:4a:0a", "metric": "0", "mtu": "1500", "options": ["PERFORMNUD", "AUTO_LINKLOCAL"], "media": "Ethernet", "media_select": "10Gbase-T", "media_type": "10Gbase-T", "media_options": ["full-duplex"], "status": "active"}, "ansible_skeleton_host": {"device": "skeleton_host", "ipv4": [], "ipv6": [{"address": "fe80::52:a4ff:fe2a:750a%skeleton_host", "prefix": "64", "scope": "0x5"}], "type": "ether", "flags": ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], "macaddress": "02:52:a4:2a:75:0a", "metric": "0", "mtu": "1500", "options": ["PERFORMNUD", "AUTO_LINKLOCAL"], "media": "Ethernet", "media_select": "10Gbase-T", "media_type": "10Gbase-T", "media_options": ["full-duplex"], "status": "active"}, "ansible_default_ipv4": {"gateway": "192.168.178.1", "interface": "em0", "device": "em0", "type": "ether", "flags": ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], "macaddress": "00:0c:29:0d:66:92", "metric": "0", "mtu": "1500", "options": ["PERFORMNUD", "ACCEPT_RTADV", "AUTO_LINKLOCAL"], "media": "Ethernet", "media_select": "autoselect", "media_type": "1000baseT", "media_options": ["full-duplex"], "status": "active", "address": "192.168.178.83", "netmask": "255.255.255.0", "network": "192.168.178.0", "broadcast": "192.168.178.255"}, "ansible_default_ipv6": {}, "ansible_all_ipv4_addresses": ["192.168.178.83", "10.0.1.1"], "ansible_all_ipv6_addresses": ["fe80::20c:29ff:fe0d:6692%em0", "2a02:8109:b5c0:28ac:20c:29ff:fe0d:6692", "fe80::5a:d1ff:feca:4a0a%playground_host", "fe80::52:a4ff:fe2a:750a%skeleton_host"], "ansible_pkg_mgr": "pkgng", "ansible_local": {}, "ansible_lsb": {}, "ansible_virtualization_type": "VMware", "ansible_virtualization_role": "guest", "ansible_service_mgr": "bsdinit", "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDWu0oNrQ2NUDf9Itnw1nFtKanraFi0KrQHDALjJje5SGX7ITN+kzw0igBaKCmhyGtg3nueyx1OxXoUtwsrpMQ+tnqjgOKK9dLk9/k7hYK2LKiQ2DqN1T6LQhiOqRaryuUtUvV7n2U7lnQHcgBIXeMZgd1YKViHQPYCbx8SQa0lkV/+rQNmz91dg9UMYoH01Mg69gFhwl8k9gp6OP1LVf51zUPPyzQbaWENW7BKtR2OAlpUxbAHZqoVBqXZzCIWdF8dus0b98aDjN1XXOmjLSqonJ6qU4D6U5PXY55tIHykkK0lqYFVrmH8fCpmtHW86E9cgBy/MuiT4XzYNU17CdaN", "ansible_ssh_host_key_rsa_public_keytype": "ssh-rsa", "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFca6GprbeZRdmkywJ7YVLaz9TEEEw/R/jlIwAhaZqZMJQtvjIi+NmeZkmyopPyduZtWDScupAp7R4t45DY5a58=", "ansible_ssh_host_key_ecdsa_public_keytype": "ecdsa-sha2-nistp256", "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAICgghWaTHxwjyhctPD+Vdu/cJ/cZ3osESXUICBoPRE7P", "ansible_ssh_host_key_ed25519_public_keytype": "ssh-ed25519", "ansible_fips": false, "ansible_env": {"LC_CTYPE": "C.UTF-8", "SSH_CLIENT": "192.168.178.87 52843 22", "LOGNAME": "root", "MAIL": "/var/mail/root", "PATH": "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "OLDPWD": "/root", "PWD": "/root", "_": "/bin/sh", "TERM": "su", "HOME": "/root", "USER": "root", "SSH_CONNECTION": "192.168.178.87 52843 192.168.178.83 22", "SHELL": "/usr/local/bin/zsh", "BLOCKSIZE": "K", "SHLVL": "0"}, "ansible_apparmor": {"status": "disabled"}, "ansible_python": {"version": {"major": 3, "minor": 7, "micro": 9, "releaselevel": "final", "serial": 0}, "version_info": [3, 7, 9, "final", 0], "executable": "/usr/local/bin/python3.7", "has_sslcontext": true, "type": "cpython"}, "ansible_dns": {"search": ["fritz.box"], "nameservers": ["192.168.178.1"]}, "ansible_iscsi_iqn": "", "ansible_fibre_channel_wwn": [], "gather_subset": ["all"], "module_setup": true}, "invocation": {"module_args": {"gather_subset": ["all"], "gather_timeout": 10, "filter": "*", "fact_path": "/etc/ansible/facts.d"}}}\n', b'')
[WARNING]: Platform freebsd on host 192.168.178.83 is using the discovered Python interpreter at /usr/local/bin/python3.7, but future installation of
another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
ok: [192.168.178.83]
META: ran handlers

TASK [Test] ******************************************************************************************************************************************
task path: /Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/Jails.Playground/Playground.yml:18
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'which -s jailme'
<192.168.178.83> (1, b'jailme not found\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<192.168.178.83> Failed to connect to the host via ssh: Shared connection to 192.168.178.83 closed.
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'jls -q jid name host.hostname path'
<192.168.178.83> (0, b'27 playground playground /jails/playground\r\n28 skeleton skeleton /jails/skeleton\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'jexec 27 /bin/sh -c '"'"'/bin/sh -c '"'"'"'"'"'"'"'"'echo ~root'"'"'"'"'"'"'"'"''"'"' && sleep 0'
<192.168.178.83> (0, b'/root\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'jexec 27 /bin/sh -c '"'"'/bin/sh -c '"'"'"'"'"'"'"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1614806741.668855-10047-15427075687577 `" && echo ansible-tmp-1614806741.668855-10047-15427075687577="` echo /root/.ansible/tmp/ansible-tmp-1614806741.668855-10047-15427075687577 `" )'"'"'"'"'"'"'"'"''"'"' && sleep 0'
<192.168.178.83> (0, b'ansible-tmp-1614806741.668855-10047-15427075687577=/root/.ansible/tmp/ansible-tmp-1614806741.668855-10047-15427075687577\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<192.168.178.83> Attempting python interpreter discovery
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'jexec 27 /bin/sh -c '"'"'/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'
<192.168.178.83> (0, b'PLATFORM\r\nFreeBSD\r\nFOUND\r\n/usr/local/bin/python3.7\r\n/usr/local/bin/python\r\nENDFOUND\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<192.168.178.83> Python interpreter discovery fallback (unsupported platform for extended discovery: freebsd)
Using module file /usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/modules/command.py
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 mktemp
<192.168.178.83> (0, b'/tmp/tmp.mfaUtK4V\r\n', b'Shared connection to 192.168.178.83 closed.\r\n')
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'chmod 0644 /tmp/tmp.mfaUtK4V'
<192.168.178.83> (0, b'', b'Shared connection to 192.168.178.83 closed.\r\n')
<192.168.178.83> PUT /Users/keziah/.ansible/tmp/ansible-local-10038ml6mzmn9/tmp53qtojuw TO /tmp/tmp.mfaUtK4V
<192.168.178.83> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 '[192.168.178.83]'
<192.168.178.83> (0, b'sftp> put /Users/keziah/.ansible/tmp/ansible-local-10038ml6mzmn9/tmp53qtojuw /tmp/tmp.mfaUtK4V\n', b'')
<playground@192.168.178.83> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.178.83> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/Users/keziah/.ansible/cp/912f20e3a5 -tt 192.168.178.83 'jexec 27 /bin/sh -c '"'"'/bin/sh -c '"'"'"'"'"'"'"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1614806741.668855-10047-15427075687577/ > /dev/null 2>&1'"'"'"'"'"'"'"'"''"'"' && sleep 0'
<192.168.178.83> (0, b'', b'Shared connection to 192.168.178.83 closed.\r\n')
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 663, in _execute
    result = self._handler.run(task_vars=variables)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/command.py", line 26, in run
    results = merge_hash(results, self._execute_module(module_name='ansible.legacy.command', task_vars=task_vars, wrap_async=wrap_async))
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 888, in _execute_module
    self._transfer_data(remote_module_path, module_data)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 498, in _transfer_data
    self._transfer_file(afile, remote_path)
  File "/usr/local/Cellar/ansible/3.0.0/libexec/lib/python3.9/site-packages/ansible/plugins/action/__init__.py", line 475, in _transfer_file
    self._connection.put_file(local_path, remote_path)
  File "/Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible/connection_plugins/sshjail.py", line 437, in put_file
    self._copy_file(tmp, out_path)
  File "/Users/keziah/Development/Diaries/keziah.de (FreeBSD, Staging)/ansible/connection_plugins/sshjail.py", line 407, in _copy_file
    copycmd = plugin.build_become_command(' '.join(['cp', from_file, to_file]), shell)
AttributeError: 'NoneType' object has no attribute 'build_become_command'
fatal: [192.168.178.83]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

NO MORE HOSTS LEFT ***********************************************************************************************************************************

PLAY RECAP *******************************************************************************************************************************************
192.168.178.83             : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
@KizzyCode
Copy link
Author

Ah, I stumbled upon #29 (comment) and indeed, become was missing.
So the issue is solved for me; however it might be a good idea to fix this/document this somewhere?

And thank you for this plugin; it is exactly what I've been looking for!

@austinhyde
Copy link
Owner

Hmm, yeah, that seems to be a stumbling block for folks. The readme does call it out, but it's a bit long winded, towards the bottom, and easy to skim past.

I'll update the readme to be clearer about it, and see if I can't add some validation in the plugin itself to make the error message much clearer about what the user needs to do.

I'm glad this is working well for you otherwise!

@austinhyde austinhyde self-assigned this Mar 3, 2021
@austinhyde austinhyde added the bug label Mar 3, 2021
@KizzyCode
Copy link
Author

KizzyCode commented Mar 3, 2021

I don't really know how the internals work, but maybe it's also a possibility to skip become if the current user is root already?
(Thats the reason I didn't use become in the first place; I thought it wouldn't be necessary if I'm root already).

@austinhyde
Copy link
Owner

Oh, I see, I missed that detail! I'll see if we can't check for that specific case too.

Thanks for catching this!

@austinhyde
Copy link
Owner

austinhyde commented Mar 5, 2021

Hmm... so it appears there's more going on here than meets the eye, due to the interaction between delegate_to, connection plugins, and where the playbook is being run from.

@KizzyCode could you share some more details to help me figure this out? Specifically:

  • are you running this playbook directly on the jailhost? or remotely?
  • what does your inventory look like for the jailhost and jails? what ansible_* vars are defined for them?
  • what was the command you used to run this playbook?
  • did you get your playbooks working? if so, what specifically did you change from the example you shared here?

Of course, feel free to redact any sensitive information. I just need to understand what your setup is, because this seems to be much more complicated than we originally thought. If you don't have time, I understand, no worries.

@KizzyCode
Copy link
Author

KizzyCode commented Mar 9, 2021

Sorry for the late reply 😕

  1. I'm running this playbook remotely via SSH

  2. I'm not using any inventory file; I call ansible directly like this: ansible-playbook -i $SERVER, Playground.yml.
    My project specific ansible configuration looks like this:

    [defaults]
    library = ansible/modules
    connection_plugins = ansible/connection_plugins
    
    [ssh_connection]
    pipelining = true
    
  3. ansible-playbook -i 192.168.178.83, Playground.yml

  4. I simply added the become parameters to the task:

    become_method: su
    become: true
    

    A fully working example looks like this:

    - hosts: all
      any_errors_fatal: true
      remote_user: root
      
      vars:
        - jail_name: playground
    
      tasks:
        - name: Test
          command: "touch /Testolope.dat"
          connection: sshjail
          become_method: su
          become: true
          delegate_to: "{{ jail_name }}@{{ inventory_hostname }}"

    (inventory_hostname resolves to 192.168.178.83)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants