Fix linter

feature/add_main_opts
Emilien Mantel 2022-11-25 09:52:40 +01:00
parent 55e075ac2b
commit 9f727adcb5
15 changed files with 61 additions and 59 deletions

2
.gitignore vendored
View File

@ -2,4 +2,4 @@
*.swp
*.retry
*.pyc
/tests/HanXHX.php
/tests/hanxhx.php

View File

@ -28,7 +28,7 @@ install:
- sudo pip install "ansible-core$ANSIBLE_VERSION"
- sudo pip install ansible-lint
- ansible-galaxy collection install community.general
- ansible-galaxy install -p ./tests HanXHX.php
- ansible-galaxy install -p ./tests hanxhx.php
script:
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM

View File

@ -1,46 +1,46 @@
---
- name: reload nginx
- name: Reload nginx
ansible.builtin.command: nginx -t
notify:
- real-reload nginx
- docker reload nginx
- Real-reload nginx
- Docker reload nginx
- name: restart nginx
- name: Restart nginx
ansible.builtin.command: nginx -t
notify:
- real-restart nginx
- docker restart nginx
- Real-restart nginx
- Docker restart nginx
- name: real-reload nginx
- name: Real-reload nginx
ansible.builtin.service:
name: nginx
state: reloaded
when: ansible_virtualization_type != 'docker'
- name: real-restart nginx
- name: Real-restart nginx
ansible.builtin.service:
name: nginx
state: restarted
when: ansible_virtualization_type != 'docker'
- name: docker reload nginx
- name: Docker reload nginx
ansible.builtin.command: service nginx reload
args:
warn: false
when: ansible_virtualization_type == 'docker'
- name: docker restart nginx
- name: Docker restart nginx
ansible.builtin.command: service nginx restart
args:
warn: false
when: ansible_virtualization_type == 'docker'
- name: restart nginx freebsd
- name: Restart nginx freebsd
ansible.builtin.service:
name: nginx
state: restarted
when: ansible_distribution == "FreeBSD"
- name: setup
- name: Setup
ansible.builtin.setup:

View File

@ -5,9 +5,9 @@ galaxy_info:
namespace: hanxhx
role_name: nginx
description: Nginx for Debian / FreeBSD
company:
company: TripleStack
license: GPLv2
min_ansible_version: 2.11
min_ansible_version: '2.11'
platforms:
- name: Debian
versions:
@ -15,9 +15,9 @@ galaxy_info:
- bullseye
- name: FreeBSD
versions:
- 11.0
- 11.1
- 12.0
- '11.0'
- '11.1'
- '12.0'
galaxy_tags:
- web
- debian

View File

@ -7,7 +7,7 @@
mode: 0644
owner: root
group: root
notify: reload nginx
notify: Reload nginx
- name: TEMPLATE | Deploy all helpers
ansible.builtin.template:
@ -17,7 +17,7 @@
owner: root
group: root
with_fileglob: '../templates/etc/nginx/helper/*.j2'
notify: reload nginx
notify: Reload nginx
- name: TEMPLATE | Deploy custom http configuration
ansible.builtin.template:
@ -26,7 +26,7 @@
mode: 0644
owner: root
group: root
notify: reload nginx
notify: Reload nginx
- name: LINEINFILE | Fix path
ansible.builtin.lineinfile:
@ -54,4 +54,4 @@
mode: 0644
owner: root
group: root
notify: reload nginx
notify: Reload nginx

View File

@ -1,7 +1,7 @@
---
- name: PKGNG | Install nginx and related tools
pkgng:
community.general.pkgng:
name: "{{ item }}"
state: present
loop:
@ -13,7 +13,9 @@
#
# Bypass https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224166#c1
#
- block:
- name: Bypass https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224166#c1
when: true
block:
- name: COMMAND | Create /usr/local/etc/fdfs/http.conf
ansible.builtin.command: touch /usr/local/etc/fdfs/http.conf
@ -34,8 +36,6 @@
state: restarted
when: fd1.changed or fd2.changed
when: true
- name: FILE | Create configuration dir (like Debian)
ansible.builtin.file:
path: "{{ nginx_etc_dir }}/{{ item }}"

View File

@ -5,7 +5,9 @@
path: "{{ nginx_acmesh_dir }}"
register: acme
- block:
- name: Install acme.sh if needed
when: not acme.stat.exists
block:
- name: APT | Install git
ansible.builtin.apt:
@ -26,8 +28,7 @@
- name: COMMAND | Force acme.sh to use letsencrypt (instead of zerossl)
ansible.builtin.command: '{{ nginx_acmesh_dir }}/acme.sh --set-default-ca --server letsencrypt --home "{{ nginx_acmesh_dir }}"'
when: not acme.stat.exists
changed_when: true
- name: FILE | Remove temp acme.sh dir
ansible.builtin.file:

View File

@ -49,7 +49,7 @@
mode: 0644
owner: root
group: root
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: (item.state is not defined or item.state != 'absent') and item.custom_template is not defined
loop: "{{ nginx_sites }}"
loop_control:
@ -62,7 +62,7 @@
mode: 0644
owner: root
group: root
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: (item.state is not defined or item.state != 'absent') and item.custom_template is defined
loop: "{{ nginx_sites }}"
loop_control:
@ -73,7 +73,7 @@
path: "{{ nginx_etc_dir }}/{{ item.1 }}/{{ item.0 | nginx_site_filename }}"
state: absent
loop: "{{ nginx_sites | product(dirs) | list }}"
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: item.0.state is defined and item.0.state == 'absent'
vars:
dirs: ['sites-available', 'sites-enabled']
@ -86,7 +86,7 @@
dest: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
state: link
loop: "{{ nginx_sites }}"
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: >
item.state is not defined or item.state == 'present'
loop_control:
@ -97,7 +97,7 @@
path: "{{ nginx_etc_dir }}/sites-enabled/{{ item | nginx_site_filename }}"
state: absent
loop: "{{ nginx_sites }}"
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: item.state is defined and item.state == 'disabled'
loop_control:
label: "{{ item | nginx_site_name }}"
@ -106,7 +106,7 @@
ansible.builtin.file:
path: "{{ nginx_etc_dir }}/sites-enabled/default"
state: absent
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: nginx_default_site is not none
- name: FILE | Auto set default site
@ -114,7 +114,7 @@
src: "{{ nginx_etc_dir }}/sites-available/default"
dest: "{{ nginx_etc_dir }}/sites-enabled/default"
state: link
notify: ['reload nginx', 'restart nginx freebsd']
notify: ['Reload nginx', 'Restart nginx freebsd']
when: nginx_default_site is none
- name: TEMPLATE | Deploy facts
@ -122,4 +122,4 @@
src: etc/ansible/facts.d/nginx.fact.j2
dest: /etc/ansible/facts.d/nginx.fact
mode: 0644
notify: ['setup']
notify: ['Setup']

View File

@ -80,7 +80,7 @@
creates: "{{ item | nginx_cert_path(nginx_ssl_dir) }}"
loop: "{{ nginx_ssl_pairs }}"
when: item.acme is defined and item.acme
notify: restart nginx
notify: Restart nginx
rescue:
@ -95,7 +95,7 @@
path: "{{ nginx_etc_dir }}/conf.d/FAKESITE_{{ item | nginx_site_name }}.conf"
state: absent
loop: "{{ acme_create }}"
notify: restart nginx
notify: Restart nginx
- name: META | Flush handlers
ansible.builtin.meta: flush_handlers

View File

@ -1,8 +1,8 @@
---
- name: IMPORT_TASKS | standard.yml
import_tasks: standard.yml
ansible.builtin.import_tasks: standard.yml
- name: IMPORT_TASKS | acme.yml
import_tasks: acme.yml
ansible.builtin.import_tasks: acme.yml
when: nginx_acmesh

View File

@ -1,6 +1,8 @@
---
- block:
- name: Generate DH if needed
when: nginx_dh is not string
block:
- name: STAT | Get info about DH file
ansible.builtin.stat:
@ -17,9 +19,7 @@
- name: COMMAND | Generate DH file
ansible.builtin.command: openssl dhparam -out {{ nginx_dh_path }} {{ nginx_dh_length }}
when: not stat_dh_file.stat.exists or (dh_info.stdout | int != nginx_dh_length | int)
notify: restart nginx
when: nginx_dh is not string
notify: Restart nginx
- name: COPY | Deploy DH file from vars
ansible.builtin.copy:
@ -29,7 +29,7 @@
group: root
mode: 0640
when: nginx_dh is string
notify: restart nginx
notify: Restart nginx
- name: FILE | Create SSL directories
ansible.builtin.file:
@ -51,7 +51,7 @@
mode: 0640
loop: "{{ nginx_ssl_pairs }}"
when: item.key is defined
notify: restart nginx
notify: Restart nginx
no_log: "{{ not nginx_debug_role }}"
- name: COPY | Deploy SSL certs
@ -63,7 +63,7 @@
mode: 0644
loop: "{{ nginx_ssl_pairs }}"
when: item.cert is defined
notify: restart nginx
notify: Restart nginx
no_log: "{{ not nginx_debug_role }}"
- name: COMMAND | Create self-signed certificates
@ -78,5 +78,5 @@
creates: "{{ '/tmp/dummy' if item.force is defined and item.force else item | nginx_cert_path(nginx_ssl_dir) }}"
loop: "{{ nginx_ssl_pairs }}"
when: item.self_signed is defined
notify: restart nginx
notify: Restart nginx
no_log: "{{ not nginx_debug_role }}"

View File

@ -7,7 +7,7 @@
mode: 0644
owner: root
group: root
notify: reload nginx
notify: Reload nginx
- name: TEMPLATE | Deploy other upstreams
ansible.builtin.template:
@ -18,7 +18,7 @@
group: root
loop: "{{ nginx_upstreams }}"
when: item.state is not defined or item.state == 'present'
notify: reload nginx
notify: Reload nginx
- name: FILE | Delete other upstreams
ansible.builtin.file:
@ -26,4 +26,4 @@
state: absent
loop: "{{ nginx_upstreams }}"
when: item.state is defined and item.state == 'absent'
notify: reload nginx
notify: Reload nginx

View File

@ -66,9 +66,9 @@
name: foo
system: true
- name: INCLUDE_ROLE | HanXHX.php
- name: INCLUDE_ROLE | hanxhx.php
include_role:
name: "{{ playbook_dir }}/HanXHX.php"
name: "{{ playbook_dir }}/hanxhx.php"
vars:
php_version: "{{ cur_php_version.stdout }}"
php_autoremove_default_pool: false

View File

@ -1,6 +1,7 @@
---
- hosts: all
- name: Launch tests
hosts: all
pre_tasks:
- name: INCLUDE_TASKS | Pre_tasks related to OS version
ansible.builtin.include_tasks: "includes/pre_{{ ansible_distribution }}.yml"