其他分享
首页 > 其他分享> > 3_3-jinja2_template.yml

3_3-jinja2_template.yml

作者:互联网

---
- hosts: all
  remote_user: root
  vars:
    http_packages:
      - httpd
  tasks:
    - name: install https form yum
      yum:
        name: 
          "{{ http_packages }}" 
      register:
        yum_httpd
    - name: enable & start httpd service
      service:
        name: httpd
        state: started
      when: yum_httpd['rc'] == 0
    - name: open firewall for http
      firewalld: 
        service: http
        permanent: yes
        state: enabled
        immediate: yes
    - name: open firewall for port-80
      firewalld: 
        port: 80/tcp
        permanent: yes
        state: enabled
        immediate: yes

    - name: copy template file-http_index.j2 to host
      template:
        src: /home/student/ansible_student/fiels/jinja2-http_index.j2
        dest: /var/www/html/index.html
        owner: root
        group: root
        mode: 0644

标签:httpd,http,name,service,jinja2,template,yum,yes,yml
来源: https://www.cnblogs.com/Anzi-0524/p/16548984.html