On Mon, 7 Jun 2021 23:20:30 -0700 (PDT) Vinod P <vinodp2...@gmail.com> wrote:
> in /etc directory and replace them with new IP address as follows > sudo find /etc -type f -exec sed -i -e 's/10.1.3.51/10.2.3.54/g' {} + For example, given the file shell> cat etc/file1 10.1.3.50 10.1.3.51 10.1.3.52 the playbook shell> cat test-007.yml - hosts: localhost gather_facts: false become: true tasks: - find: path: etc file_type: file recurse: true register: result - replace: path: "{{ item }}" regexp: "10.1.3.51" replace: "10.2.3.54" loop: "{{ result.files| map(attribute='path')| list }}" gives shell> ansible-playbook test-007.yml -CD PLAY [localhost] ****************************************** TASK [find] ****************************************** ok: [localhost] TASK [replace] ****************************************** --- before: etc/file1 +++ after: etc/file1 @@ -1,3 +1,3 @@ 10.1.3.50 -10.1.3.51 +10.2.3.54 10.1.3.52 changed: [localhost] => (item=etc/file1) -- Vladimir Botka -- 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-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/20210608084532.4d6a8956%40gmail.com.
pgpclcpwEiggm.pgp
Description: OpenPGP digital signature