您的位置:首页 > 其它

playbook核心元素之 模板template 介绍(7)

2016-11-30 11:40 411 查看
playbook核心元素之 --> 模板template 介绍

templates:文件文件,内部嵌套有模板语言脚本(使用模板语言编写)

[root@ansible ~]# ansible-doc -l | grep "^\<template\>" --> template是一个模块
template   Templates a file out to a remote server.
[root@node1 ~]# ansible-doc -s template  --> 查看 template模块的参数
src=
dest=
mode=
onwer=
group=
...


注意:此模拟不能再命令行使用,而只能用于playbook

实际使用范例

[root@ansible ~]# vim test4.yaml
- hosts: centos7
remote_user: root
tasks:
- name: install httpd
yum: name=httpd state=latest
- name: copy config file
template: src=/root/httpd.conf.j2 dest=/etc/httpd/conf/httpd.conf
notify: restart httpd service
- name: start httpd service
service: name=httpd state=started
handlers:
- name: restart httpd service
service: name=httpd state=restarted
















内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  yaml playbook ansible