From fd35807e8b933dd782e23ede0497279941c7c2bc Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 16:53:43 +0100 Subject: [PATCH 1/7] trailing whitespace --- tasks/configuration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 2048e8e..0fdf682 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -14,7 +14,7 @@ when: nginx_mime_types_file.stat.exists == False notify: - reload nginx - + - name: Copy the nginx configuration file template: src: nginx.conf.j2 @@ -137,4 +137,4 @@ when: (item not in nginx_remove_modules) and (item not in nginx_disabled_modules) ignore_errors: "{{ ansible_check_mode }}" notify: - - reload nginx \ No newline at end of file + - reload nginx From c2eea3400864aeb128cc701eab8d247d439cf76b Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 16:55:33 +0100 Subject: [PATCH 2/7] [701] Role info should contain description --- meta/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/meta/main.yml b/meta/main.yml index 4aaa163..88eae6d 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,6 +1,7 @@ --- galaxy_info: author: "DAUPHANT Julien" + description: Ansible role to install Nginx. license: BSD min_ansible_version: 2.4 platforms: From d47abcac8381a1a772f703dae3cbcaa9dd8bf1c2 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 16:59:45 +0100 Subject: [PATCH 3/7] [601] Don't compare to literal True/False --- tasks/amplify.yml | 6 ++++-- tasks/configuration.yml | 2 +- tasks/main.yml | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/amplify.yml b/tasks/amplify.yml index 074464d..4377526 100644 --- a/tasks/amplify.yml +++ b/tasks/amplify.yml @@ -27,14 +27,16 @@ 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 + when: + - not amplify_agent_installed.failed|bool + - nginx_amplify_update_agent|bool tags: [packages] - name: Verify Amplify agent is up and running diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 0fdf682..a256fa4 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -11,7 +11,7 @@ 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 diff --git a/tasks/main.yml b/tasks/main.yml index 0cb55b8..8471fac 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,7 +12,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 @@ -37,11 +37,11 @@ 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 From 7324a15274dfb8388708042e07bd49c9839b7465 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 17:01:34 +0100 Subject: [PATCH 4/7] [502] All tasks should be named --- tasks/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 8471fac..c9877a4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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" From d8e4a251bf334f6f5ad7f3ac4f2d45a8ac5c0f67 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 17:05:15 +0100 Subject: [PATCH 5/7] [206] Variables should have spaces before and after: {{ var_name }} --- tasks/ensure-dirs.yml | 10 +++++----- tasks/main.yml | 2 +- tasks/remove-defaults.yml | 6 +++--- tasks/remove-extras.yml | 8 ++++---- tasks/remove-unwanted.yml | 6 +++--- tasks/selinux.yml | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tasks/ensure-dirs.yml b/tasks/ensure-dirs.yml index ab480ef..a37eb10 100644 --- a/tasks/ensure-dirs.yml +++ b/tasks/ensure-dirs.yml @@ -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" @@ -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 }}" diff --git a/tasks/main.yml b/tasks/main.yml index c9877a4..d3d0f62 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -46,6 +46,6 @@ 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] diff --git a/tasks/remove-defaults.yml b/tasks/remove-defaults.yml index 28b29a4..6d9244d 100644 --- a/tasks/remove-defaults.yml +++ b/tasks/remove-defaults.yml @@ -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 @@ -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() diff --git a/tasks/remove-extras.yml b/tasks/remove-extras.yml index f971111..0b68b0d 100644 --- a/tasks/remove-extras.yml +++ b/tasks/remove-extras.yml @@ -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' @@ -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' diff --git a/tasks/remove-unwanted.yml b/tasks/remove-unwanted.yml index e8ea16c..aaaf972 100644 --- a/tasks/remove-unwanted.yml +++ b/tasks/remove-unwanted.yml @@ -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'] @@ -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: @@ -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: diff --git a/tasks/selinux.yml b/tasks/selinux.yml index c37ad52..276d25d 100644 --- a/tasks/selinux.yml +++ b/tasks/selinux.yml @@ -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 From 85e97161897ac6b29494794d641ccaf5069529d6 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 17:09:09 +0100 Subject: [PATCH 6/7] skip_ansible_lint rule [403] Package installs should not use latest --- tasks/amplify.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/amplify.yml b/tasks/amplify.yml index 4377526..6b3be59 100644 --- a/tasks/amplify.yml +++ b/tasks/amplify.yml @@ -37,7 +37,9 @@ when: - not amplify_agent_installed.failed|bool - nginx_amplify_update_agent|bool - tags: [packages] + tags: + - packages + - skip_ansible_lint # latest package version - name: Verify Amplify agent is up and running service: From 1201b3a50814feb7d82752c5c6a41deeafa21978 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Mon, 30 Dec 2019 17:09:30 +0100 Subject: [PATCH 7/7] [204] Lines should be no longer than 160 chars --- tasks/configuration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tasks/configuration.yml b/tasks/configuration.yml index a256fa4..f7a7e34 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -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"