# expect module does not like an int I am passing in

**URL:** <https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028>\
**Category:** Ansible Project\
**Created:** [November 15, 2016, 2:48pm UTC](https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028 "2016-11-15T14:48:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt\_shepherd](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@matt\_shepherd](https://forum.ansible.com/u/matt_shepherd)\
**Post date:** [November 15, 2016, 2:48pm UTC](https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028/1 "2016-11-15T14:48:13Z")

</div>

All, I did some searching here and did not find this specific issue. I am trying to use the expect module to work with fdisk to automatically provision new space on VMs.

tasks:

- name: “DISK | Create a partition for the added disk space”  
expect:  
command: fdisk /dev/sda  
responses:  
‘Command (m for help\*’:
- n
- t
- w  
‘Select (default._$': p  
'Partition number._$’: “{{ next\_part }}”  
‘First sector._$': \r  
'Last sector._$’: \r  
‘Hex code.\*$’: 08e

What i get is:

TASK [DISK | Create a partition for the added disk space] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [p-db-rhel7-01]: FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “Shared connection to XX.4.XXX.144 closed.\r\n”, “module\_stdout”: “Traceback (most recent call last):\r\n File "/tmp/ansible\_z0\_ZP0/ansible\_module\_expect.py", line 237, in \r\n main()\r\n File "/tmp/ansible\_z0\_ZP0/ansible\_module\_expect.py", line 149, in main\r\n response = u’%s\n’ % value.rstrip(‘\n’).decode()\r\nAttributeError: ‘int’ object has no attribute ‘rstrip’\r\n”, “msg”: “MODULE FAILURE”}

I finally figured out that the next\_part variable I am passing in is the number of the partition I want to create (3 in this case), and I think this is complaining because there is no “rstrip” function for integers. However, I am sure peopole have used this module to great effect with responses that are integers. So, any help?

Thanks

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 16, 2016, 6:09pm UTC](https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028/2 "2016-11-16T18:09:41Z")

</div>

You could try to filter it to a string  
"{{ next\_part | string }}"

---

<div class="post-metadata">

**Author:** ![matt\_shepherd](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@matt\_shepherd](https://forum.ansible.com/u/matt_shepherd)\
**Post date:** [November 17, 2016, 11:33am UTC](https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028/3 "2016-11-17T11:33:36Z")

</div>

Thanks, I’ll have to try that. I actually solved it where I create the variable. What I had in host\_vars/node was:

next\_part = 3

If I change it to the following it seemed to fix it.

next\_part = ‘3’

Your solution is making use of a feature of jinja, right?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 17, 2016, 3:13pm UTC](https://forum.ansible.com/t/expect-module-does-not-like-an-int-i-am-passing-in/23028/4 "2016-11-17T15:13:02Z")

</div>

Yes, Jinja2 filters.
