# Problems with module blockinfile

**URL:** <https://forum.ansible.com/t/problems-with-module-blockinfile/22104>\
**Category:** Ansible Project\
**Created:** [July 25, 2016, 12:57am UTC](https://forum.ansible.com/t/problems-with-module-blockinfile/22104 "2016-07-25T00:57:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rick\_Paxton](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rick\_Paxton](https://forum.ansible.com/u/Rick_Paxton)\
**Post date:** [July 25, 2016, 12:57am UTC](https://forum.ansible.com/t/problems-with-module-blockinfile/22104/1 "2016-07-25T00:57:59Z")

</div>

So I just want to state that I’m new to Ansible and not sure how to debug issues yet, any guidance would be appreciated.

I’m attempting to use module blockinfile to update /etc/sysctl.conf file, but it doesn’t seem to want to cooperate.

**playbook:**  
settings.yml  
1 —  
2 - hosts: dbservers  
3 become: yes  
4  
5 tasks:  
6 - name: insert/update sysctl.conf settings per specifications  
7 blockinfile:  
8 backup: yes  
9 dest: /etc/sysctl.conf  
10 marker: # {mark} ANSIBLE MANAGED BLOCK  
11 content: |  
12 kernel.shmmni = 4096  
13 kernel.sem = 250 32000 100 128  
14 fs.file-max = 512 \* PROCESSES  
15 net.ipv4.ip\_local\_port\_range = 1024 6500  
16 net.core.rmem\_default = 4194304  
17 net.core.rmem\_max = 4194304  
18 net.core.wmem\_default = 262144  
19 net.ipv4.tcp\_wmem = 262144 262144 262144  
20 net.ipv4.tcp\_rmem = 4194304 4194304 4194304

**execution:**  
$ ansible-playbook ./playbooks/settings.yml

**results:**  
PLAY [dbservers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [setup] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [ag-rhel6-temp.test.local]

TASK [insert/update sysctl.conf settings per specifications] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [ag-rhel6-temp.test.local]: FAILED! =\> {“changed”: false, “failed”: true, “module\_stderr”: “”, “module\_stdout”: “Traceback (most recent call last):\r\n File "/tmp/ansible\_3oLmj8/ansible\_module\_blockinfile.py", line 313, in \r\n main()\r\n File "/tmp/ansible\_3oLmj8/ansible\_module\_blockinfile.py", line 243, in main\r\n marker0 = re.sub(r’{mark}', ‘BEGIN’, marker)\r\n File "/usr/lib64/python2.6/re.py", line 151, in sub\r\n return \_compile(pattern, 0).sub(repl, string, count)\r\nTypeError: expected string or buffer\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

NO MORE HOSTS LEFT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @./playbooks/settings.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ag-rhel6-temp.test.local : ok=1 changed=0 unreachable=0 failed=1

Again, any help or pointers would be appreciated!  
Thanks,  
Rick

---

<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:** [July 25, 2016, 8:54pm UTC](https://forum.ansible.com/t/problems-with-module-blockinfile/22104/2 "2016-07-25T20:54:29Z")

</div>

It's complaining about marker: not being a string, you need to put quotes around it.  
Since the marker text you are using is the same as the default you can just delete the marker line.

---

<div class="post-metadata">

**Author:** ![Rick\_Paxton](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rick\_Paxton](https://forum.ansible.com/u/Rick_Paxton)\
**Post date:** [July 26, 2016, 12:39am UTC](https://forum.ansible.com/t/problems-with-module-blockinfile/22104/3 "2016-07-26T00:39:17Z")

</div>

Thank Kai, adding double quotes to the marker line resolved the issue!

-Rick
