ansible 模板

play.yml

---

- name: ansible playbook
  hosts: all
  remote_user: root
  become: yes
  vars:
	docker_registry_mirror: 'https://xxx.mirror.aliyun.com'
  var_files:
  
  tasks:
	- name: 拷贝文件
	  template:
		src: ./files/docker.service.j2
		dest: /etc/systemd/system/

模板文件:

./files/docker.service.j2

...
--registry-mirror = {{ docker_registry_mirror }}
...