Skip to content

become_method: machinectl results in IndentationError: unexpected indent #81254

Closed
ansible-collections/community.general
#9908
@Yannik

Description

@Yannik

Summary

Using become_method: machinectl results in failure when

[ssh_connection]
pipelining = True

is configured.

Issue Type

Bug Report

Component Name

become

Ansible Version

$ ansible --version
ansible [core 2.15.1]
  config file = /home/yannik/projects/mcc-berlin/ansible.cfg
  configured module search path = ['/home/yannik/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/yannik/.local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/yannik/projects/mcc-berlin/vendor_collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/yannik/projects/ansible/ansible.cfg
EDITOR(env: EDITOR) = vim
PAGER(env: PAGER) = less

CONNECTION:
==========

ssh:
___
pipelining(/home/yannik/projects/ansible/ansible.cfg) = True

OS / Environment

Target OS: Debian bookworm

Steps to Reproduce

Task:

- shell: echo $XDG_RUNTIME_DIR
  become: yes
  become_user: web-cpim
  become_method: machinectl

ansible.cfg:

[ssh_connection]
pipelining = True

Expected Results

The task should not fail

Actual Results

fatal: [host]: FAILED! => changed=false 
  module_stderr: ''
  module_stdout: |-
    Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> #!/usr/bin/python3
    >>> # -*- coding: utf-8 -*-
    >>> _ANSIBALLZ_WRAPPER = True # For test-module.py script to tell this is a ANSIBALLZ_WRAPPER
    >>> def _ansiballz_main():
    ...     import os
    ...     import os.path
    ...     try:
    ...         os.getcwd()
    ...     except OSError:
    ...         try:
    ...             os.chdir(os.path.expanduser('~'))
    ...         except OSError:
    ...             os.chdir('/')
    ...
    >>>     import sys
    l  File "<stdin>", line 1
        import sys
    IndentationError: unexpected indent
    >>>     import __main__
      File "<stdin>", line 1
        import __main__
    IndentationError: unexpected indent
    >>>     scriptdir = None
      File "<stdin>", line 1
        scriptdir = None
    IndentationError: unexpected indent
    >>>     try:
      File "<stdin>", line 1
        try:
    IndentationError: unexpected indent
    >>>         scriptdir = os.path.dirname(os.path.realpath(__main__.__file__))
      File "<stdin>", line 1
        scriptdir = os.path.dirname(os.path.realpath(__main__.__file__))
    IndentationError: unexpected indent
    >>>     except (AttributeError, OSError):
      File "<stdin>", line 1
        except (AttributeError, OSError):
    IndentationError: unexpected indent
    >>>         pass
      File "<stdin>", line 1
        pass
    IndentationError: unexpected indent
    >>>     excludes = set(('', '.', scriptdir))
      File "<stdin>", line 1
        excludes = set(('', '.', scriptdir))
    IndentationError: unexpected indent
    >>>     sys.path = [p for p in sys.path if p not in excludes]
      File "<stdin>", line 1
        sys.path = [p for p in sys.path if p not in excludes]
    IndentationError: unexpected indent
    >>>     import base64
      File "<stdin>", line 1
        import base64
    IndentationError: unexpected indent
    >>>     import runpy
      File "<stdin>", line 1
        import runpy
    IndentationError: unexpected indent
    >>>     import shutil
      File "<stdin>", line 1
        import shutil
    IndentationError: unexpected indent
    >>>     import tempfile
      File "<stdin>", line 1
        import tempfile
    IndentationError: unexpected indent
    >>>     import zipfile
      File "<stdin>", line 1
        import zipfile
    IndentationError: unexpected indent
    >>>     if sys.version_info < (3,):
      File "<stdin>", line 1
        if sys.version_info < (3,):
    IndentationError: unexpected indent
    >>>         PY3 = False
      File "<stdin>", line 1
        PY3 = False
    IndentationError: unexpected indent
    >>>     else:
      File "<stdin>", line 1
        else:
    IndentationError: unexpected indent
    >>>         PY3 = True
      File "<stdin>", line 1
        PY3 = True
    IndentationError: unexpected indent
    >>>     ZIPDATA = """<LONG-BASE64-TEXT>
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 0

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions