[root@node1 ansibletest]# cat testtemplate.yaml
- hosts: all
remote_user: root
tasks:
- name: install nginx
yum: name=nginx
- name: copy temp
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
- name: start service
service: name=nginx state=started
修改模板
cat templates/nginx.conf.j2 | grep process
worker_processes {
{
ansible_processor_vcpus**2 }};
cat templates/nginx.conf.j2 | grep port
listen {
{
http_port }} default_server;
模板
[root@node1