Ansible使用介绍

72课时
1.9K学过
8分

课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
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进程数量与系统自带变量结合起来引用。