Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Created February 9, 2024 09:40
Show Gist options
  • Save zeitounator/06fd1f76c8f2b06dd7bef6b5f30741f4 to your computer and use it in GitHub Desktop.
Save zeitounator/06fd1f76c8f2b06dd7bef6b5f30741f4 to your computer and use it in GitHub Desktop.
$ cat test.yml
---
- hosts: localhost
tasks:
- name: Write ip4 adrees in a file
ansible.builtin.lineinfile:
line: "My ip4 is: {{ ansible_enp5s0.ipv4.address }}"
dest: /tmp/test/toto.txt
create: true
$ ansible-playbook test.yml
PLAY [localhost] ***********************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Write ip4 adrees in a file] ******************************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP *****************************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$ cat /tmp/test/toto.txt
My ip4 is: 192.168.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment