On Thursday, November 16, 2017 at 4:42:19 PM UTC-5, leam hall wrote:
>
> Trying to edit grub.conf and add a phrase to the kernel lines.
>
> *Sample stanza:*
>
> title CentOS (2.6.32-696.13.2.el6.x86_64)
> root (hd0,0)
> kernel /vmlinuz-2.6.32-696.13.2.el6.x86_64 ro
> root=/dev/mapper/vg_root-lv_root rd_NO_LUKS rd_LVM_LV=vg_root/lv_root
> LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 console=ttyS0,115200n8
> rd_LVM_LV=vg_root/lv_swap KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb
> quiet rd_NO_DM
> initrd /initramfs-2.6.32-696.13.2.el6.x86_64.img
>
>
> Ansible playbook stanza that's not working:
>
> - name: edit_grub_conf
> lineinfile:
> path: "/tmp/grub.conf"
> regexp: "^kernel(.*)?"
> line: 'kernel\1 transparent_hugepage=never'
> state: present
> backrefs: true
> mode: 0666
>
> Error reported:
>
> TASK [edit_grub_conf]
> **********************************************************
> fatal: [leviticus]: FAILED! => {"changed": false, "failed": true,
> "module_stderr": "Shared connection to leviticus closed.\r\n",
> "module_stdout": "Traceback (most recent call last):\r\n File
> \"/tmp/ansible_PUtMtv/ansible_module_lineinfile.py\", line 470, in
> <module>\r\n main()\r\n File
> \"/tmp/ansible_PUtMtv/ansible_module_lineinfile.py\", line 462, in main\r\n
> ins_aft, ins_bef, create, backup, backrefs)\r\n File
> \"/tmp/ansible_PUtMtv/ansible_module_lineinfile.py\", line 261, in
> present\r\n bre_m = re.compile(to_bytes(regexp,
> errors='surrogate_or_strict'))\r\n File \"/usr/lib64/python2.6/re.py\",
> line 190, in compile\r\n return _compile(pattern, flags)\r\n File
> \"/usr/lib64/python2.6/re.py\", line 245, in _compile\r\n raise error, v #
> invalid expression\r\nsre_constants.error: nothing to repeat\r\n", "msg":
> "MODULE FAILURE", "rc": 0}
>
>
> What am I missing?
>
> Thanks!
>
> Leam
>
Interesting. I read
http://www.mydailytutorials.com/ansible-lineinfile-module-examples/ and
used the example as a starting point. Found out lineinfile only works on
one line in the file, not all of them. And just the last one.
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/992d2124-adb8-4e1b-9ed5-48dd9abd29ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.