#cat jia.yml
- hosts: test-gfs
user: dev
gather_facts: true
vars:
PORT: "3306"
MESAGE: "wangrenqing"
IP_local: "{{ansible_default_ipv4.address}}"
IP_local_lan: "{{ ansible_all_ipv4_addresses[1] }}"
#HOST_NAME: "{{inventory_hostname}}
tasks:
- name: copy file to client
template: src=./test.j dest=/tmp/test.tmp
- debug: "msg={{ ansible_default_ipv4.address }}"
- name: "add file"
lineinfile: dest=/tmp/test.tmp line="{{PORT}}"
#cat ./test.j
this is {{PORT}} fsdfsdf {{MESAGE}}
ip_wan: {{IP_local}} ip_lan: {{IP_local_lan}}