пример использования генератора шаблонов
playbook
- name : install apache and upload web page
hosts: server1 become: yes
vars: source_file: ./mysite2/index.j2 dest_file : /var/www/html/index.html
tasks:
- name: Install Apache
yum: name=httpd state=latest
- name: Generate index.html for servers
template: src={{ source_file }} dest={{dest_file}}
notify: restart apache
service: name=httpd state=started enabled=yes
handlers:
- name : restart apache
service: name=httpd state=restarted
<!DOCTYPE html>
<head>
<title>be1.ru</title>
</head>
<body>
<p>Ansible deploy</p>
<p>Данная страница работает на сервере с ip адресом {{ansible_default_ipv4.address}}</p>
<p>На операционной системе linux {{ansible_os_family}}</p>
<p> </p>
</body>