1、模拟6和7系统(6对应11、7对应12)

playbook变量(七)template 基本使用 when

[root@linux-node1 ansible]# cat test_template2.yaml 
---
- hosts: date
  remote_user: root
  vars:
    - http_port: 99

  tasks:
    - name: install package
      yum: name=nginx
    - name: copy 7 template
      template: src=nginx.conf11.j2 dest=/etc/nginx/nginx.conf
      when: ansible_distribution_major_version == "7"
      notify: restart service
    - name: copy 6 template
      template: src=nginx.conf12.j2 dest=/etc/nginx/nginx.conf
      when: ansible_distribution_major_version == "6"
      notify: restart service
    - name: start service
      service: name=nginx state=started enabled=yes

  handlers:
    - name: restart service
      service: name=nginx state=restarted 

playbook变量(七)template 基本使用 when

 

 

 

 

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2022-02-24
  • 2021-09-06
  • 2022-01-22
  • 2021-06-30
  • 2021-11-30
  • 2022-02-12
猜你喜欢
  • 2021-06-06
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2021-05-23
相关资源
相似解决方案