ansible-role-nginx/tasks/main.yml

33 lines
883 B
YAML

- name: Install packages.
tags: nginx
ansible.builtin.package:
state: present
name:
- nginx
register: nginx_installed
- name: Backup default nginx config
command: mv /etc/nginx /etc/nginx.orig
when: nginx_installed.changed == true
register: nginx_original_config_backup
- name: Clone h5bp nginx config.
tags: nginx
ansible.builtin.git:
repo: https://github.com/h5bp/server-configs-nginx
dest: /etc/nginx
depth: 1
notify: restart nginx
when: nginx_original_config_backup.changed == true
- name: Copy default fastcgi_params back to h5bp nginx config.
command: cp /etc/nginx.orig/fastcgi_params /etc/nginx
when: nginx_original_config_backup.changed == true
- name: Remove default nginx directory.
tags: nginx
ansible.builtin.file:
path: /etc/nginx.orig
state: absent
when: nginx_original_config_backup.changed == true