--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/cb9896bd-1639-4690-b8d7-457c5ab75617%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/mYI1oZ8hAyA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAPz4CsxFGgeTEkh%2BHr1cXDxOF1trst3pJnvFY%2BU%2BraCVHnFu7Q%40mail.gmail.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/F0747137-FE47-43DF-9CA4-DA19943DEBDA%40google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/41AA737F-28EB-4F29-8FDF-71B2E87937C5%40gmail.com.
I don't know if I got your specification correctly
anyway this is an example
$ cat lineinfile.yml
- hosts: localhost
tasks:
- name: lineinfile
lineinfile:
path: ./hosts
regexp: '^(.*) server\.corp\b(.*)$'
line: '\1 server.corp server.corp.company.com \2'
backrefs: yes
$ cat hosts
127.0.0.1 localhost
192.168.192.168 server.corp
fusillator@catorcio:~/Code/ansible/test$ ansible-playbook
lineinfile.yml
PLAY [localhost]
**************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts]
********************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [lineinfile]
*************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP
********************************************************************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0
failed=0
$ cat hosts
127.0.0.1 localhost
192.168.192.168 server.corp server.corp.company.com
regards
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e40f8d40-fa16-4a53-9c10-02e669c89019%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I don't know if I got your specification correctly
anyway this is an example
fusillator@catorcio:~/Code/ansible/test$ cat lineinfile.yml
- hosts: localhost
tasks:
- name: lineinfile
lineinfile:
path: ./hosts
regexp: '^(.*) server\.corp\b(.*)$'
line: '\1 server.corp server.corp.company.com \2'
backrefs: yes
fusillator@catorcio:~/Code/ansible/test$ cat hosts
127.0.0.1 localhost
192.168.192.168 server.corp
fusillator@catorcio:~/Code/ansible/test$ ansible-playbook
lineinfile.yml
PLAY [localhost]
**************************************************************************************************************************************************************************************************************************************************************
TASK [Gathering Facts]
********************************************************************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [lineinfile]
*************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP
********************************************************************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0
failed=0
fusillator@catorcio:~/Code/ansible/test$ cat hosts
127.0.0.1 localhost
192.168.192.168 server.corp server.corp.company.com
regards
Luca
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/05A2A994-7FE9-4881-9EC7-95F56D103C7A%40google.com.