ansible Templates:模版
Posted c040
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible Templates:模版相关的知识,希望对你有一定的参考价值。
---恢复内容开始---
Templates:模版
cat /etc/ansible/hosts
cat templates/nginx.conf.j2
- hosts: test
remote_user: root
vars:
- package: httpd
- service: httpd
tasks:
- name: install nginx package
yum: name={{ package }} state=latest
- name: install configuration file for httpd
template: src=/root/templates/httpd.conf.j2 dest=/etc/httpd/conf/httpd.conf
notify:
- restart httpd
- name: start httpd service
service: enabled=true name={{ service }} state=started
handlers:
- name: restart httpd
service: name={{ package }} state=restarted
tags 标签
<u></u>
- hosts: test
remote_user: root
vars:
- package: nginx
- service: nginx
tasks:
- name: install nginx package
yum: name={{ package }} state=latest
tags:
- install
- name: configuration file for httpd
tags:
- conf
template: src=/root/templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify:
- restart nginx
- name: start nginx service
shell: nginx
tags:
- start_nginx
handlers:
- name: restart nginx
shell: nginx -s reload
---恢复内容结束---
以上是关于ansible Templates:模版的主要内容,如果未能解决你的问题,请参考以下文章
ansible之配置tomcat
Ansible批量安装mysql数据
Ansible角色
ansible-playbook
django静态模版使用
使用Visual Studio Code自定义代码模版