nginx/tasks/main.yaml
changeset 47 3f1771bb0d79
parent 40 b42b417751e5
child 118 56bffa9ef826
equal deleted inserted replaced
46:f43ad090546d 47:3f1771bb0d79
     1 ---
     1 ---
     2 
     2 
     3 - name: install nginx packages
     3 - name: apt install nginx
     4   become: yes
     4   become: yes
     5   apt: name="nginx"
     5   apt: name="nginx"
     6 
       
     7 - name: install site
       
     8   become: yes
       
     9   template: src="{{nginx_conf_src}}" dest="/etc/nginx/sites-available/{{nginx_conf_dst}}"
       
    10   notify: restart nginx
       
    11 
       
    12 - name: install nginx packages
       
    13   become: yes
       
    14   apt: name="python-certbot-nginx"
       
    15   notify: restart nginx
       
    16   when: nginx_enable_certbot
       
    17 
       
    18 - name: install certbot in nginx
       
    19   become: yes
       
    20   command: "certbot certonly --nginx -n --agree-tos -d {{nginx_server_name}} -m {{nginx_admin_email}}"
       
    21   changed_when: false
       
    22   when: nginx_enable_certbot
       
    23 
     6 
    24 - name: disable default site
     7 - name: disable default site
    25   become: yes
     8   become: yes
    26   file: path="/etc/nginx/sites-enabled/default" state="absent"
     9   file: path="/etc/nginx/sites-enabled/default" state="absent"
       
    10 
       
    11 - name: install base config
       
    12   become: yes
       
    13   copy: src="nginx.conf" dest="/etc/nginx/nginx.conf"
    27   notify: restart nginx
    14   notify: restart nginx
    28 
    15 
    29 - name: enable site
    16 - name: make stream dirs
       
    17   become: yes
       
    18   file: path="/etc/nginx/streams-{{item}}" state="directory"
       
    19   loop: ["available", "enabled"]
       
    20 
       
    21 - name: make config available
       
    22   become: yes
       
    23   template:
       
    24     src:  "{{nginx_conf_src}}"
       
    25     dest: "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
       
    26   notify: restart nginx
       
    27 
       
    28 - name: enable config
    30   become: yes
    29   become: yes
    31   file:
    30   file:
    32     src:  "/etc/nginx/sites-available/{{nginx_conf_dst}}"
    31     src:  "/etc/nginx/{{nginx_server_type}}s-available/{{nginx_server_name}}.conf"
    33     dest: "/etc/nginx/sites-enabled/{{nginx_conf_dst}}"
    32     dest: "/etc/nginx/{{nginx_server_type}}s-enabled/{{nginx_server_name}}.conf"
    34     state: "link"
    33     state: "link"
       
    34   notify: restart nginx
       
    35 
       
    36 - name: copy root files
       
    37   become: yes
       
    38   copy: src="{{nginx_root_src}}" dest="{{nginx_root_dest}}/"
       
    39   when: nginx_root
    35   notify: restart nginx
    40   notify: restart nginx
    36 
    41 
    37 - name: enable nginx service
    42 - name: enable nginx service
    38   become: yes
    43   become: yes
    39   systemd: name="nginx" enabled="yes" state="started"
    44   systemd: name="nginx" enabled="yes" state="started"