Skip to content

The oracle_db module forces the use of /usr/bin/python3 even when the ansible_python_interpreter variable is defined #539

@raul-selas

Description

@raul-selas

This playbook fails at task

- name: Crear base de datos Oracle
  hosts: dbservers
  gather_facts: false
  collections:
    - opitzconsulting.ansible_oracle
  vars:
    ansible_python_interpreter: "/opt/venv/create_oracle_db/bin/python"
    oracle_home: /database/product/oh_dbd134a
    sid: dbd134a
    db_name: dbd134a
    host: myhost.mydomain
    sys_password: "TuPasswordSys"
    system_password: "TuPasswordSystem"
    listener_port: 2008
    characterset: AL32UTF8
    db_type: OLTP
    installation_user: oracle19
    datafile_dest: /database/oradata/dbd134a
    virtualenv_bin: /usr/bin/virtualenv
  tasks:
    - name: Mostrar username
      opitzconsulting.ansible_oracle.oracle_sql:
        username: "algo"
        password: "algo"
        service_name: one.world
        sql: 'select username from dba_users'
      ignore_errors: true

    - name: debug ansible_python_interpreter
      debug:
        msg: "ansible_python_interpreter: {{ ansible_python_interpreter }}"

    - name: Crear base de datos Oracle
      opitzconsulting.ansible_oracle.oracle_db:
        datafile_dest: "{{ datafile_dest }}"
        oracle_home: "{{ oracle_home }}"
        sid: "{{ sid }}"
        db_name: "{{ db_name }}"
        host: "{{ host }}"
        sys_password: "{{ sys_password }}"
        system_password: "{{ system_password }}"
        port: "{{ listener_port }}"
        characterset: "{{ characterset }}"
        db_type: "{{ db_type }}"

        state: present

relevant log:

SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/home/rselas/.ssh/ansible_admin_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="oracle19"' -o ConnectTimeout=10 -o 'ControlPath="/home/rselas/.ansible/cp/6c8efd9f18"' -o NumberOfPasswordPrompts=1 -tt bddes-sns16n1.mydomain '/bin/sh -c '"'"'/usr/bin/python3 /export/home/oracle19/.ansible/tmp/ansible-tmp-1764840562.7414513-110525-140620100804002/AnsiballZ_oracle_db.py && sleep 0'"'"''

However, if I manually replace the shebang of the module:

1c1
< #!/usr/bin/python3
---
> #!/usr/bin/python

then ansible allows to use the selected python interpreter in ansible_python_interpreter

SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/home/rselas/.ssh/ansible_admin_key"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="oracle19"' -o ConnectTimeout=10 -o 'ControlPath="/home/rselas/.ansible/cp/6c8efd9f18"' -o NumberOfPasswordPrompts=1 -tt bddes-sns16n1.mydomain '/bin/sh -c '"'"'/opt/venv/create_oracle_db/bin/python3 /export/home/oracle19/.ansible/tmp/ansible-tmp-1764840916.2794776-113889-38693971423708/AnsiballZ_oracle_sql.py && sleep 0'"'"''

This is problematic because it requires the existence of the /usr/bin/python3 interpreter at a system level besides installing the oracle_CX python module into the system python environment.

I've tested other modules (without modifying them), like oracle_sql, and it can work as expected, using the python interpreter referenced in ansible_python_interpreter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions