Skip to content

It's work on Windows hosts? #708

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

Open
svjatoslav-torn opened this issue Apr 9, 2025 · 3 comments
Open

It's work on Windows hosts? #708

svjatoslav-torn opened this issue Apr 9, 2025 · 3 comments

Comments

@svjatoslav-torn
Copy link

Guys, hello) I am understand, this module be work on windows hosts?

I already try
But get error:

A MySQL module is required: for Python 2.7 either PyMySQL, or MySQL-python, or for Python 3.X mysqlclient or >PyMySQL. Consider setting ansible_python_interpreter to use the intended Python version.

I installed Python 3.13 and PyMySQL on Windows host, but it not work)

@joey-grant
Copy link

Hey @svjatoslav-torn, can you confirm whether ansible_python_interpreter aligns with the path to your recently installed Python 3.13 and PyMySQL? It might be helpful to checkout this section of the documentation, specifically in regards to how the mysql modules utilize the discovered interpreter.

@svjatoslav-torn
Copy link
Author

Hey @svjatoslav-torn, can you confirm whether ansible_python_interpreter aligns with the path to your recently installed Python 3.13 and PyMySQL? It might be helpful to checkout this section of the documentation, specifically in regards to how the mysql modules utilize the discovered interpreter.

This python and PyMySQL

Image

I try add ansible_python_interpreter to inventory, and even to playbook vars
I try different, example:

ansible_python_interpreter: C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python313\\python.exe
ansible_python_interpreter: "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python313\\python.exe"
ansible_python_interpreter: C:\Users\Administrator\AppData\Local\Programs\Python\Python313\python.exe
ansible_python_interpreter: "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\python.exe"
ansible_python_interpreter: C:/Users/Administrator/AppData/Local/Programs/Python/Python313/python.exe
ansible_python_interpreter: "C:/Users/Administrator/AppData/Local/Programs/Python/Python313/python.exe"
ansible_python_interpreter: %LOCALAPPDATA%\\Programs\\Python\\Python313\\python.exe
ansible_python_interpreter: "%LOCALAPPDATA%\\Programs\\Python\\Python313\\python.exe"

Now my playbook sees so

---
- name: Test MySQL connection using community.mysql.mysql_info
  hosts: all
  gather_facts: false
  vars:
    ansible_python_interpreter: "C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python313\\python.exe"
  tasks:
    - name: Gather MySQL information
      community.mysql.mysql_info:
        login_user: "{{ mysql_user }}"
        login_password: "{{ mysql_password }}"
        login_host: "localhost"
      register: mysql_info

    - name: Debug MySQL info
      debug:
        var: mysql_info

My inventory look so

  GNU nano 7.2                                                                /var/ansible/inventory_test.yml                                                                          
---
all:
  vars:
    ansible_host_key_checking: false
   group1:
      hosts:
        65.44.44.44:
          ansible_shell_type: cmd
          ansible_connection: ssh
          ansible_ssh_user: Administrator
          ansible_ssh_password: password
          ansible_ssh_port: 33
          mysql_user: root
          mysql_password: mysql_password

I run command

ansible-playbook /var/ansible/mysql_test.yml -i /var/ansible/inventory_test.yml

I see always same result:

PLAY [Test MySQL connection using community.mysql.mysql_info] *************************************************************************************************************************

TASK [Gather MySQL information] *******************************************************************************************************************************************************
fatal: [44.44.44.44]: FAILED! => {"changed": false, "module_stderr": "ê߬½ετÑ¡¿Ñ »α¿ ó맮óÑ \"Create\" ß \"1\" áαúπ¼Ñ¡ΓἿ: \"ßΓ᫬á:4 º¡á¬:21\r\n+ def _ansiballz_main():\r\n+                     ~\r\nÅ«ß½Ñ ''('' «ª¿ñὫß∞ óδαáªÑ¡¿Ñ.\r\nßΓ᫬á:8 º¡á¬:19\r\n+         os.getcwd()\r\n+                   ~\r\nÅ«ß½Ñ ''('' «ª¿ñὫß∞ óδαáªÑ¡¿Ñ.\r\nßΓ᫬á:20 º¡á¬:27\r\n+     except (AttributeError, OSError):\r\n+                           ~\r\nÄΓßπΓßΓóπÑΓ áαúπ¼Ñ¡Γ ó ß»¿ß¬Ñ »áαá¼ÑΓα«ó.\r\nßΓ᫬á:22 º¡á¬:29\r\n+     excludes = set(('', '.', scriptdir))\r\n+                             ~\r\nÄΓßπΓßΓóπÑΓ óδαáªÑ¡¿Ñ »«ß½Ñ \",\".\r\nßΓ᫬á:22 º¡á¬:30\r\n+     excludes = set(('', '.', scriptdir))\r\n+                              ~~~~~~~~~\r\nìÑ»αÑñó¿ñÑ¡¡á∩ ½Ñ¬ßѼá \"scriptdir\" ó óδαáªÑ¡¿¿ ¿½¿ «»ÑαáΓ«αÑ.\r\nßΓ᫬á:22 º¡á¬:29\r\n+     excludes = set(('', '.', scriptdir))\r\n+                             ~\r\nÄΓßπΓßΓóπÑΓ ºá¬αδóáεΘ¿⌐ º¡á¬ \")\" ó óδαáªÑ¡¿¿.\r\nßΓ᫬á:22 º¡á¬:39\r\n+     excludes = set(('', '.', scriptdir))\r\n+                                       ~\r\nìÑ»αÑñó¿ñÑ¡¡á∩ ½Ñ¬ßѼá \")\" ó óδαáªÑ¡¿¿ ¿½¿ «»ÑαáΓ«αÑ.\r\nßΓ᫬á:22 º¡á¬:40\r\n+     excludes = set(('', '.', scriptdir))\r\n+                                        ~\r\nìÑ»αÑñó¿ñÑ¡¡á∩ ½Ñ¬ßѼá \")\" ó óδαáªÑ¡¿¿ ¿½¿ «»ÑαáΓ«αÑ.\r\nßΓ᫬á:29 º¡á¬:7\r\n+     if sys.version_info < (3,):\r\n+       ~\r\nÄΓßπΓßΓóπÑΓ \"(\" ó «»ÑαáΓ«αÑ if »«ß½Ñ \"if\".\r\nßΓ᫬á:29 º¡á¬:30\r\n+     if sys.version_info < (3,):\r\n+                              ~\r\nÄΓßπΓßΓóπÑΓ óδαáªÑ¡¿Ñ »«ß½Ñ \",\".\r\néδñá¡δ ß««íΘÑ¡¿∩ ¡Ñ «í« óßÑσ «Φ¿í¬áσ ß¿¡Γá¬ß¿τÑ߬«ú« á¡á½¿ºá.  êß»αáó∞ΓÑ »ÑαÑτ¿ß½Ñ¡¡δÑ ó ß««íΘÑ¡¿∩σ «Φ¿í¬¿ ¿ »«óΓ«α¿ΓÑ \r\n»«»δΓ¬π.\"\r\nßΓ᫬á:10 º¡á¬:1\r\n+ & ([ScriptBlock]::Create($split_parts[0]))\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException\r\n    + FullyQualifiedErrorId : ParseException\r\n \r\n", "module_stdout": "", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 1}

@Andersson007
Copy link
Collaborator

@svjatoslav-torn hello, thanks for opening the issue. Not being a windows user, it's hard for me to say what could the issue be about. As a workaround, you could:

  1. Open a port and make MySQL listen outside connections on your Windows maching
  2. install PyMySQL on your Ansible controller
  3. run the task with delegate_to: localhost so that it runs on the controller and the login_host:

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

No branches or pull requests

3 participants