# open(module, 'wb') SyntaxError for raw module in ansible-playbook

**URL:** <https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062>\
**Category:** Ansible Project\
**Created:** [April 4, 2019, 3:59pm UTC](https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062 "2019-04-04T15:59:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Iracheta](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@Henry\_Iracheta](https://forum.ansible.com/u/Henry_Iracheta)\
**Post date:** [April 4, 2019, 3:59pm UTC](https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062/1 "2019-04-04T15:59:16Z")

</div>

I am trying to use Ansible on a remote host that has a version of Python 2.4.3 installed. My understanding is that a more recent version of  
Python is required to properly use Ansible; however, I should be able to use the “raw” module for such older Python environments. I am able to successfully  
use the “raw” module via the ansible CLI; however, when I try to use the raw module via the ansible-playbook CLI I get the following error:

“line 39\r\n with open(module, ‘wb’) as f:\r\n ^\r\nSyntaxError: invalid syntax\r\n”, “msg”: "MODULE FAILURE

Mapped “line 39” to file AnsiballZ\_setup.py on the remote host. But surprised the file was invoked given the raw module was being used.

Here is an example of the playbook being tested:

- hosts: servers  
remote\_user: xxxxx  
tasks:
- name: simply test to confirm playbook works  
raw: /bin/hostname

Any suggestions on how to work around this issue ?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 4, 2019, 4:00pm UTC](https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062/2 "2019-04-04T16:00:15Z")

</div>

Ansible no longer supports Python 2.4 on target hosts. The last version to support Python 2.4 was Ansible 2.3.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Meyer](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Sebastian\_Meyer](https://forum.ansible.com/u/Sebastian_Meyer)\
**Post date:** [April 4, 2019, 5:59pm UTC](https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062/3 "2019-04-04T17:59:19Z")

</div>

> Here is an example of the playbook being tested:
> 
> - hosts: servers  
> &nbsp;&nbsp;remote\_user: xxxxx  
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: simply test to confirm playbook works  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw: /bin/hostname
> 
> \> Any suggestions on how to work around this issue ?

You need to set gather\_facts to no. gather\_facts uses the setup module,  
which is Python.

- hosts: servers  
&nbsp;&nbsp;gather\_facts: no  
&nbsp;&nbsp;tasks:  
[...]

Sebastian

---

<div class="post-metadata">

**Author:** ![Henry\_Iracheta](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@Henry\_Iracheta](https://forum.ansible.com/u/Henry_Iracheta)\
**Post date:** [April 4, 2019, 10:04pm UTC](https://forum.ansible.com/t/open-module-wb-syntaxerror-for-raw-module-in-ansible-playbook/30062/4 "2019-04-04T22:04:33Z")

</div>

That worked, thank you very much !
