how to run the python script from ansible to Windows 2019?

115 views
Skip to first unread message

Dhilipsingh G

unread,
May 8, 2020, 2:55:03 AM5/8/20
to Ansible Project
hi Team , 

i am getting error while run the python script from ansible to windows 2019. kindly help  me to fix the issue 

error :
 "Traceback (most recent call last):",
        "  File \"deploy.py\", line 866, in <module>",
        "    DatabaseCreator().main()",
        "  File \"deploy.py\", line 788, in main",
        "    os.makedirs(self.ECRF_FGDB_PATH)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedirs",
        "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedirs",
        "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedirs",
        "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 157, in makedirs",
        "    mkdir(name, mode)",
        "WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: '\\\\\\\\'"

Dick Visser

unread,
May 8, 2020, 6:15:08 AM5/8/20
to ansible...@googlegroups.com
To answer your question more information is needed. Could you please
describe clearly all of the below:

- What goal you are trying to achieve.
- How you are doing this.
- What problems you encounter.
- Which commands did you run, and what actual output did you get
(copied as plain text - not as screenshots, images, or other binary
attachments).
- What do the relevant inventory/tasks/playbooks/code/variables look like.
- The output of ‘ansible --version’
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ac654703-540d-4b8a-95c7-830f1a59fbbd%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Dhilipsingh G

unread,
May 8, 2020, 7:39:46 AM5/8/20
to Ansible Project

hi

- What goal you are trying to achieve
I need to run the python script on windows machine by ansible 
- How you are doing this.
i have python script on windows machine then i write the bat file for run the python script , python installed on "F:\\Python27\\ArcGISx6410.7\python.exe .
my bat file is cd "F:\scc_install_dir\EGDMSDatabaseDeploy"
"F:\Python27\ArcGISx6410.7\python.exe" "EGDMSDatabaseDeploy.py"
exit
EGDMSDatabaseDeploy.py is the python script name

Cmd and error 

fatal: [10.105.83.32]: FAILED! => {
    "changed": true,
    "cmd": "db.bat",
    "delta": "0:00:13.881565",
    "end": "2020-05-08 11:32:14.295884",
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2020-05-08 11:32:00.414319",
    "stderr": "The filename, directory name, or volume label syntax is incorrect                                                                                        .\r\nTraceback (most recent call last):\r\n  File \"F:\\FileShare\\FTPRoot\\Chid                                                                                        ambaram_Files\\DBDeploy\\EGDMSDatabaseDeploy_v3_4_14.py\", line 874, in <module>                                                                                        \r\n    DatabaseCreator().main()\r\n  File \"F:\\FileShare\\FTPRoot\\Chidambaram                                                                                        _Files\\DBDeploy\\EGDMSDatabaseDeploy_v3_4_14.py\", line 788, in main\r\n    os.                                                                                        makedirs(self.ECRF_FGDB_PATH)\r\n  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.p                                                                                        y\", line 150, in makedirs\r\n    makedirs(head, mode)\r\n  File \"F:\\Python27\                                                                                        \ArcGISx6410.7\\lib\\os.py\", line 150, in makedirs\r\n    makedirs(head, mode)\                                                                                        r\n  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedirs\r\n                                                                                            makedirs(head, mode)\r\n  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\",                                                                                         line 157, in makedirs\r\n    mkdir(name, mode)\r\nWindowsError: [Error 123] The                                                                                         filename, directory name, or volume label syntax is incorrect: '\\\\\\\\'\r\n",
    "stderr_lines": [
        "The filename, directory name, or volume label syntax is incorrect.",
        "Traceback (most recent call last):",
        "  File \"F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy\\EGDMSData                                                                                        baseDeploy_v3_4_14.py\", line 874, in <module>",
 "    DatabaseCreator().main()",
        "  File \"F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy\\EGDMSData                                                                                        baseDeploy_v3_4_14.py\", line 788, in main",
        "    os.makedirs(self.ECRF_FGDB_PATH)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedi                                                                                        rs",
        "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedi                                                                                        rs",
        "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 150, in makedi                                                                                        rs",
 "    makedirs(head, mode)",
        "  File \"F:\\Python27\\ArcGISx6410.7\\lib\\os.py\", line 157, in makedi                                                                                        rs",
        "    mkdir(name, mode)",
        "WindowsError: [Error 123] The filename, directory name, or volume label                                                                                         syntax is incorrect: '\\\\\\\\'"
    ],
    "stdout": "\r\nF:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy>##\"F:\\F                                                                                        ileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy\"\r\n\r\nF:\\FileShare\\FTPRoot\\                                                                                        Chidambaram_Files\\DBDeploy>\"F:\\Python27\\ArcGISx6410.7\\python.exe\" \"F:\\Fi                                                                                        leShare\\FTPRoot\\Chidambaram_Files\\DBDeploy\\EGDMSDatabaseDeploy_v3_4_14.py\"                                                                                         \r\n****************************************************\r\n*** EGDMS v2.0 DATAB                                                                                        ASE DEPLOYMENT PROCESS       ***\r\n********************************************                                                                                        ********\r\n\r\nReading configuration settings...\r\n\r\nF:\\FileShare\\FTPRoot\                                                                                        \Chidambaram_Files\\DBDeploy>exit\r\n",
    "stdout_lines": [
        "",
        "F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy>##\"F:\\FileShare\\                                                                                        FTPRoot\\Chidambaram_Files\\DBDeploy\"",
        "",
        "F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy>\"F:\\Python27\\Arc                                                                                        GISx6410.7\\python.exe\" \"F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy\\                                                                                        EGDMSDatabaseDeploy_v3_4_14.py\" ",
        "****************************************************",
        "*** EGDMS v2.0 DATABASE DEPLOYMENT PROCESS       ***",
        "****************************************************",
        "",
        "Reading configuration settings...",
        "",
        "F:\\FileShare\\FTPRoot\\Chidambaram_Files\\DBDeploy>exit"
    ]
}


-Ansible version
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/dgunasin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Dhilipsingh G

unread,
May 8, 2020, 7:50:53 AM5/8/20
to Ansible Project
i am getting result when i run the bat file manually on windows machine ,  

Dick Visser

unread,
May 8, 2020, 8:25:14 AM5/8/20
to ansible...@googlegroups.com
On Fri, 8 May 2020 at 13:39, Dhilipsingh G <dhilip...@gmail.com> wrote:

>> - What do the relevant inventory/tasks/playbooks/code/variables look like.

You forgot the most important information ^^^

Dhilipsingh G

unread,
May 8, 2020, 8:38:16 AM5/8/20
to Ansible Project


On Friday, May 8, 2020 at 5:55:14 PM UTC+5:30, Dick Visser wrote:
On Fri, 8 May 2020 at 13:39, Dhilipsingh G <dhilip...@gmail.com> wrote:

>> - What do the relevant inventory/tasks/playbooks/code/variables look like.

You forgot the most important information ^^^
 playbook :
---

- name: Install Databasedeploy
  hosts: 10.105.83.32
  become_method: runas

  tasks:
  #  - name: copy the bat file
  #    win_copy:
  #      src: /etc/ansible/db.bat
  #      dest:  F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy\
  #  - name: Copy folder contents
  #    win_copy:
  #      src: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy\config_3.txt
  #      dest: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy\config.txt
  #      remote_src: yes

#run the py script1
    - name: Run a script with arguments
      win_command: db.bat
      args:
        chdir: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy
      become_user: lab\dgunasin
# run the script with config 2
    - name: Copy config 2
      win_copy:
        src: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy\config_4.txt
        dest: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy\config.txt
        remote_src: yes

#run the py script1
    - name: Run a script with arguments
      win_command: db.bat
      args:
        chdir: F:\FileShare\FTPRoot\Chidambaram_Files\DBDeploy
        remote_src: yes

host file: 
[Computeserver]
10.105.83.33
[Computeserver:vars]
ansible_user=xxxx
ansible_password=xxxx
ansible_port=5986
ansible_connection=winrm
ansible_winrm_scheme=https
ansible_winrm_server_cert_validation=ignore
ansible_winrm_transport=ntlm
 
No variable and python code is in my client file , unable to copy here .

Dhilipsingh G

unread,
May 10, 2020, 11:16:04 AM5/10/20
to Ansible Project
hi ,anyone have idea ?

Dhilipsingh G

unread,
May 11, 2020, 6:42:40 AM5/11/20
to ansible...@googlegroups.com

Hi any suggestions plz

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/252257c0-d589-4522-ac29-a1887161efa2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages