nginx_vm1.yml

 avatar
unknown
yaml
a year ago
688 B
26
Indexable
---

- hosts:
  - vm1
  vars:
  - siteslist:
    - "www.test1.com"
    - "www.test2.com"
    - "www.test3.com"
  tasks:
  - name: Install nginx
    apt:
       pkg: nginx
    become: yes
  - name: Create dir for websites
    file:
       path: /var/www/{{ item }}
       state: directory
    become: yes
    with_items: "{{ siteslist }}"
  - name: Create nginx config files
    template:
       src: "website.j2"
       dest: "/etc/nginx/sites-enabled/{{ item }}.conf"
    with_items: "{{ siteslist }}"
    become: yes
    notify: nginxrestart
  handlers:
  - name: nginxrestart
    service:
       name: "nginx"
       state: "restarted"
    become: yes
Editor is loading...
Leave a Comment