2分钟
04 示例1:使用template传输配置文件
cp /etc/nginx/nginx.conf templates/nginx.conf.j2
vim testtemplate.yml
—
– hosts: os6
remote_user: root
tasks:
– name: install package
yum: name=nginx
– name: copy template
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
– name: start service
service: name=nginx state=started enabled=yes
执行结果:运行playbook后,我们发现work process进程数量与虚拟机cpu内核数量是一致的,接下来我
们将把配置模板中的work process进程数量与系统自带变量结合起来引用。
学员评价