Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Fix for #242 Stick to ansible-lint rules. #243

Merged
merged 7 commits into from
Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
galaxy_info:
author: "DAUPHANT Julien"
description: Ansible role to install Nginx.
license: BSD
min_ansible_version: 2.4
platforms:
Expand Down
10 changes: 7 additions & 3 deletions tasks/amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@
path: "{{ nginx_amplify_script_path }}"
state: absent

when: amplify_agent_installed.failed == true
when: amplify_agent_installed.failed|bool
tags: [configuration, packages]

- name: Update Amplify Agent if already installed and update flag is enabled
package:
name: nginx-amplify-agent
state: latest
when: amplify_agent_installed.failed == false and nginx_amplify_update_agent == true
tags: [packages]
when:
- not amplify_agent_installed.failed|bool
- nginx_amplify_update_agent|bool
tags:
- packages
- skip_ansible_lint # latest package version

- name: Verify Amplify agent is up and running
service:
Expand Down
11 changes: 7 additions & 4 deletions tasks/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
get_url:
url: https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types
dest: "{{ nginx_conf_dir }}/mime.types"
when: nginx_mime_types_file.stat.exists == False
when: not nginx_mime_types_file.stat.exists|bool
notify:
- reload nginx

- name: Copy the nginx configuration file
template:
src: nginx.conf.j2
Expand Down Expand Up @@ -75,7 +75,10 @@
- reload nginx
when: nginx_stream_params or nginx_stream_configs

- name: Create configuration files in modules-available (only for nginx official repo or custom modules, Centos/RHEL/Debian/Ubuntu EPEL/APT repo packages have these config files already)
- name: |
Create configuration files in modules-available (only for nginx official
repo or custom modules, Centos/RHEL/Debian/Ubuntu EPEL/APT repo packages
have these config files already)
template:
src: module.conf.j2
dest: "{{ nginx_conf_dir }}/modules-available/{{ item }}.conf"
Expand Down Expand Up @@ -137,4 +140,4 @@
when: (item not in nginx_remove_modules) and (item not in nginx_disabled_modules)
ignore_errors: "{{ ansible_check_mode }}"
notify:
- reload nginx
- reload nginx
10 changes: 5 additions & 5 deletions tasks/ensure-dirs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: Create the directories for site specific configurations
file:
path: "{{nginx_conf_dir}}/{{ item }}"
path: "{{ nginx_conf_dir }}/{{ item }}"
state: directory
owner: "{{ nginx_conf_user }}"
group: "{{ nginx_conf_group }}"
mode: "{{nginx_dir_perm}}"
mode: "{{ nginx_dir_perm }}"
with_items:
- "sites-available"
- "sites-enabled"
Expand All @@ -20,6 +20,6 @@
file:
path: "{{ nginx_log_dir }}"
state: directory
owner: "{{nginx_log_user}}"
group: "{{nginx_log_group}}"
mode: "{{nginx_log_perm}}"
owner: "{{ nginx_log_user }}"
group: "{{ nginx_log_group }}"
mode: "{{ nginx_log_perm }}"
11 changes: 6 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---

- include_vars: "{{ item }}"
- name: include OS dependent vars
include_vars: "{{ item }}"
with_first_found:
- "../vars/{{ ansible_os_family }}.yml"
- "../vars/empty.yml"
Expand All @@ -12,7 +13,7 @@
tags: [packages, selinux, nginx]

- include_tasks: nginx-official-repo.yml
when: nginx_official_repo == True
when: nginx_official_repo|bool
tags: [packages, nginx]

- include_tasks: installation.packages.yml
Expand All @@ -37,14 +38,14 @@
tags: [configuration, nginx]

- include_tasks: cloudflare_configuration.yml
when: nginx_set_real_ip_from_cloudflare == True
when: nginx_set_real_ip_from_cloudflare|bool
tags: [configuration, nginx]

- include_tasks: amplify.yml
when: nginx_amplify == true and (ansible_distribution in ['RedHat', 'CentOS', 'Debian', 'Amazon', 'Ubuntu'])
when: nginx_amplify|bool and (ansible_distribution in ['RedHat', 'CentOS', 'Debian', 'Amazon', 'Ubuntu'])
tags: [amplify, nginx]

- name: Start the nginx service
service: name={{ nginx_service_name }} state={{nginx_start_service | ternary('started', 'stopped')}} enabled={{nginx_start_at_boot}}
service: name={{ nginx_service_name }} state={{ nginx_start_service | ternary('started', 'stopped') }} enabled={{ nginx_start_at_boot }}
when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on"
tags: [service, nginx]
6 changes: 3 additions & 3 deletions tasks/remove-defaults.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
- name: Disable the default site
file:
path: "{{nginx_conf_dir}}/sites-enabled/default"
path: "{{ nginx_conf_dir }}/sites-enabled/default"
state: absent
notify:
- reload nginx

- name: Disable the default site (on newer nginx versions)
file:
path: "{{nginx_conf_dir}}/sites-enabled/default.conf"
path: "{{ nginx_conf_dir }}/sites-enabled/default.conf"
state: absent
notify:
- reload nginx
Expand All @@ -17,7 +17,7 @@

- name: Remove the default configuration
file:
path: "{{nginx_conf_dir}}/conf.d/default.conf"
path: "{{ nginx_conf_dir }}/conf.d/default.conf"
state: absent
when: >
'default' not in nginx_configs.keys()
Expand Down
8 changes: 4 additions & 4 deletions tasks/remove-extras.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Find enabled sites
shell: ls -1 {{nginx_conf_dir}}/sites-enabled || true
shell: ls -1 {{ nginx_conf_dir }}/sites-enabled || true
register: enabled_sites
changed_when: False

- name: Disable unmanaged sites
file:
path: "{{nginx_conf_dir}}/sites-enabled/{{ item }}"
path: "{{ nginx_conf_dir }}/sites-enabled/{{ item }}"
state: absent
with_items: "{{ enabled_sites.stdout_lines | default([]) }}"
# 'item.conf' => 'item'
Expand All @@ -15,13 +15,13 @@
- reload nginx

- name: Find config files
shell: find {{nginx_conf_dir}}/conf.d -maxdepth 1 -type f -name '*.conf' -exec basename {} \;
shell: find {{ nginx_conf_dir }}/conf.d -maxdepth 1 -type f -name '*.conf' -exec basename {} \;
register: config_files
changed_when: False

- name: Remove unmanaged config files
file:
name: "{{nginx_conf_dir}}/conf.d/{{ item }}"
name: "{{ nginx_conf_dir }}/conf.d/{{ item }}"
state: absent
with_items: "{{ config_files.stdout_lines | default([]) }}"
# 'item.conf' => 'item'
Expand Down
6 changes: 3 additions & 3 deletions tasks/remove-unwanted.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Remove unwanted sites
file:
path: "{{nginx_conf_dir}}/{{ item[0] }}/{{ item[1] }}.conf"
path: "{{ nginx_conf_dir }}/{{ item[0] }}/{{ item[1] }}.conf"
state: absent
with_nested:
- ['sites-enabled', 'sites-available']
Expand All @@ -11,7 +11,7 @@

- name: Remove unwanted conf
file:
path: "{{nginx_conf_dir}}/conf.d/{{ item }}.conf"
path: "{{ nginx_conf_dir }}/conf.d/{{ item }}.conf"
state: absent
with_items: "{{ nginx_remove_configs }}"
notify:
Expand All @@ -27,7 +27,7 @@

- name: Remove unwanted auth_basic_files
file:
path: "{{nginx_conf_dir}}/auth_basic/{{ item }}"
path: "{{ nginx_conf_dir }}/auth_basic/{{ item }}"
state: absent
with_items: "{{ nginx_remove_auth_basic_files }}"
notify:
Expand Down
2 changes: 1 addition & 1 deletion tasks/selinux.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install the selinux python module
package: name={{ nginx_python_selinux_pkgs | default(omit)}} state=present
package: name={{ nginx_python_selinux_pkgs | default(omit) }} state=present
when: ansible_os_family == "RedHat" or ansible_os_family == "Debian"

- name: Set SELinux boolean to allow nginx to set rlimit
Expand Down