From fa47586fc8e1221a19ba6551833d1bbcc55a31e4 Mon Sep 17 00:00:00 2001 From: Gian Klug Date: Wed, 11 Sep 2024 14:31:48 +0200 Subject: [PATCH] lint: make ansible-lint happy --- .ansible-lint | 4 ++-- .yamllint | 8 ++++++++ defaults/main.yml | 25 +++++++++---------------- handlers/main.yml | 1 - meta/main.yml | 20 ++++++++++---------- tasks/configuration.yml | 31 +++++++++++++++---------------- tasks/installation.yml | 31 +++++++++++++++---------------- tasks/main.yml | 21 ++++++++++----------- vars/Debian.yml | 2 +- vars/RedHat.yml | 2 +- 10 files changed, 71 insertions(+), 74 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 7313c5b..668951b 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,5 +1,5 @@ --- skip_list: - - '405' - - '106' # Role name {} does not match ``^[a-z][a-z0-9_]+$`` pattern' + - "405" + - "106" # Role name {} does not match ``^[a-z][a-z0-9_]+$`` pattern' diff --git a/.yamllint b/.yamllint index c704097..6367b7a 100644 --- a/.yamllint +++ b/.yamllint @@ -7,5 +7,13 @@ rules: line-length: disable brackets: disable truthy: disable + comments: + min-spaces-from-content: 1 + comments-indentation: false + braces: + max-spaces-inside: 1 + octal-values: + forbid-implicit-octal: true + forbid-explicit-octal: true # vim: set ts=2 sw=2 tw=2 : diff --git a/defaults/main.yml b/defaults/main.yml index bc9a29e..772c26b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,7 @@ --- # The icingaweb2 web ui password -icinga2_web_admin_pass: 'passw0rd' +icinga2_web_admin_pass: passw0rd # icinga2 API host icinga2_web_api_host: 127.0.0.1 @@ -13,7 +13,7 @@ icinga2_web_api_port: 5665 icinga2_web_api_user: icingaweb2 # icinga2 API password -icinga2_web_api_pass: 'passw0rd' +icinga2_web_api_pass: passw0rd # icinga2 director API host icinga2_web_director_api_host: 127.0.0.1 @@ -25,9 +25,9 @@ icinga2_web_director_api_port: 5665 icinga2_web_director_api_user: director # icinga2 director API password -icinga2_web_director_api_pass: 'passw0rd' +icinga2_web_director_api_pass: passw0rd -#icingadb instead of ido +# icingadb instead of ido icinga2_web_use_icingadb: false ## icingaweb2 database settings @@ -38,7 +38,7 @@ icinga2_web_icingaweb2_database_name: icingaweb2 icinga2_web_icingaweb2_database_user: icingaweb2 # The icingaweb2 database password -icinga2_web_icingaweb2_database_pass: 'passw0rd' +icinga2_web_icingaweb2_database_pass: passw0rd # The icingaweb2 database host icinga2_web_icingaweb2_database_host: 127.0.0.1 @@ -47,7 +47,7 @@ icinga2_web_icingaweb2_database_host: 127.0.0.1 icinga2_web_icingaweb2_database_port: 3306 # the hostpattern which can access and login with the icingaweb2 user -icinga2_web_icingaweb2_database_hostpattern: 'localhost' +icinga2_web_icingaweb2_database_hostpattern: localhost # icingaweb2 database ssl connection (1 or 0) icinga2_web_icingaweb2_database_ssl: 0 @@ -60,8 +60,7 @@ icinga2_web_icingaweb2_database_ssl_ca: /etc/pki/tls/certs/ca-bundle.crt icinga2_web_database_user: icingaweb2 # corresponding password to the root user -icinga2_web_database_root_pass: 'passw0rd' - +icinga2_web_database_root_pass: passw0rd ## Icinga2 database settings # icinga2 database name @@ -77,7 +76,7 @@ icinga2_web_icinga2_database_port: 3306 icinga2_web_icinga2_database_user: icinga2 # icinga2 database password -icinga2_web_icinga2_database_pass: 'passw0rd' +icinga2_web_icinga2_database_pass: passw0rd # icinga2 database ssl connection (1 or 0) icinga2_web_icinga2_database_ssl: 0 @@ -128,7 +127,6 @@ icinga2_web_modules: [] # timeout: 5 icinga2_web_ldap: [] - # Icingaweb2 LDAP User configuration # For further information, consult the official icingaweb2 documentation at # https://icinga.com/docs/icingaweb2/latest/doc/05-Authentication/#ldap @@ -142,7 +140,6 @@ icinga2_web_ldap: [] # filter: "(somefilter)" # optional icinga2_web_ldap_userconf: [] - # Icingaweb2 LDAP Group configuration # For further information, consult the official icingaweb2 documentation at # https://icinga.com/docs/icingaweb2/latest/doc/05-Authentication/#ldap-groups @@ -159,7 +156,6 @@ icinga2_web_ldap_userconf: [] # group_filter: '(somefilter)' # optional icinga2_web_ldap_groupconf: [] - # Icingaweb2 database group configuration # For further information, consult the official icingaweb2 documentation at # https://icinga.com/docs/icinga-web-2/latest/doc/05-Authentication/#database-groups @@ -170,7 +166,6 @@ icinga2_web_ldap_groupconf: [] # resource: icingaweb_db icinga2_web_database_groupconf: [] - # Icinga2 Permissions configuration # For further information, consult the official icingaweb2 documentation at # https://icinga.com/docs/icingaweb2/latest/doc/06-Security/#configuration @@ -198,7 +193,7 @@ icinga2_web_permissions: groups: - Administrators permissions: - - '*' + - "*" # Director Resources configuration # For further information, consult the official icingaweb2 documentation at @@ -217,7 +212,6 @@ icinga2_web_permissions: # ssl_ca: '/etc/pki/tls/certs/ca-bundle.crt' icinga2_web_director: [] - # Reporting resources configuration # icinga2_web_reporting: @@ -233,7 +227,6 @@ icinga2_web_director: [] # ssl_ca: '/etc/pki/tls/certs/ca-bundle.crt' icinga2_web_reporting: [] - # IcingaDB resources configuration # icinga2_web_icingadb: diff --git a/handlers/main.yml b/handlers/main.yml index ac32774..a574684 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,4 @@ --- - - name: Icinga2_web reload icinga2 ansible.builtin.service: name: icinga2 diff --git a/meta/main.yml b/meta/main.yml index c93e7ed..b0f6ee6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,24 +1,24 @@ --- dependencies: - - name: 'adfinis.icinga2_agent' + - name: adfinis.icinga2_agent galaxy_info: - role_name: 'icinga2_web' + role_name: icinga2_web namespace: adfinis - author: 'Adfinis AG' - description: 'This role installs and configures icingaweb2' - company: 'Adfinis AG' - license: 'GNU General Public License v3' - min_ansible_version: '2.6.0' + author: Adfinis AG + description: This role installs and configures icingaweb2 + company: Adfinis AG + license: GNU General Public License v3 + min_ansible_version: 2.6.0 platforms: - name: EL versions: - "7" galaxy_tags: - - 'icinga2' - - 'monitoring' - - 'icingaweb2' + - icinga2 + - monitoring + - icingaweb2 github_branch: master collections: diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 8f1b27d..7b3cd33 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -1,9 +1,8 @@ --- - - name: Configure icingaweb2 ansible.builtin.template: - src: 'templates/etc/icingaweb2/{{ item }}.j2' - dest: '/etc/icingaweb2/{{ item }}' + src: templates/etc/icingaweb2/{{ item }}.j2 + dest: /etc/icingaweb2/{{ item }} owner: root group: icingaweb2 mode: "0660" @@ -11,7 +10,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - loop: '{{ icinga2_web_managed_config_files }}' + loop: "{{ icinga2_web_managed_config_files }}" - name: Create a symbolic link for module director ansible.builtin.file: @@ -51,7 +50,7 @@ failed_when: false changed_when: false -- name: Enable icingadb module # noqa changed-when +- name: Enable icingadb module # noqa no-changed-when ansible.builtin.command: icingacli module enable icingadb when: - icinga2_web_use_icingadb @@ -76,7 +75,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == true + when: icinga2_web_use_icingadb - name: Configure icingaweb2 icingadb module - redis.ini ansible.builtin.template: @@ -89,7 +88,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == true + when: icinga2_web_use_icingadb - name: Configure icingaweb2 icingadb module - commandtransports.ini ansible.builtin.template: @@ -102,13 +101,13 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == true + when: icinga2_web_use_icingadb - name: Create config directory for icingaweb2 module monitoring ansible.builtin.file: path: /etc/icingaweb2/modules/monitoring/ state: directory - mode: '0755' + mode: "0755" - name: Configure icingaweb2 monitoring module ansible.builtin.template: @@ -121,7 +120,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == false + when: not icinga2_web_use_icingadb - name: Configure icingaweb2 monitoring module commandtransport ansible.builtin.template: @@ -134,7 +133,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == false + when: not icinga2_web_use_icingadb - name: Configure icingaweb2 monitoring module backends ansible.builtin.template: @@ -147,7 +146,7 @@ serole: object_r setype: icingaweb2_config_t selevel: s0 - when: icinga2_web_use_icingadb == false + when: not icinga2_web_use_icingadb - name: Configure icingaweb2 director module ansible.builtin.template: @@ -181,13 +180,13 @@ failed_when: false register: director_pending_migrations -- name: Configure icingaweb2 director database # noqa no-changed-when +- name: Configure icingaweb2 director database # noqa no-changed-when ansible.builtin.command: icingacli director migration run when: - icinga2_web_director | length != 0 - director_pending_migrations.rc == 0 -- name: Check if director kickstart is done yet # noqa no-changed-when +- name: Check if director kickstart is done yet # noqa no-changed-when ansible.builtin.command: icingacli director kickstart required when: icinga2_web_director | length != 0 run_once: true @@ -200,7 +199,7 @@ var: icinga2_web_register_kickstart verbosity: 2 -- name: Run icingaweb2 director kickstart # noqa no-changed-when +- name: Run icingaweb2 director kickstart # noqa no-changed-when ansible.builtin.command: icingacli director kickstart run when: - icinga2_web_director | length != 0 @@ -221,7 +220,7 @@ selevel: s0 when: icinga2_web_reporting | length != 0 -- name: Create icingaweb2 admin password hash # noqa no-changed-when +- name: Create icingaweb2 admin password hash # noqa no-changed-when ansible.builtin.command: openssl passwd -1 '{{ icinga2_web_admin_pass }}' register: icinga2_web_register_admin_hash when: diff --git a/tasks/installation.yml b/tasks/installation.yml index 55c843e..bfe61a4 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -1,15 +1,14 @@ --- - - name: Install icinga2 web packages ansible.builtin.package: - name: '{{ icinga2_web_packages }}' + name: "{{ icinga2_web_packages }}" state: present - name: Install icingaDB web packages ansible.builtin.package: - name: '{{ icinga2_web_icingadb_packages }}' + name: "{{ icinga2_web_icingadb_packages }}" state: present - when: icinga2_web_use_icingadb == true + when: icinga2_web_use_icingadb - name: Install fail2ban using role ansible.builtin.include_role: @@ -54,30 +53,30 @@ - name: Import icingaweb2 database schema community.mysql.mysql_db: - name: '{{ icinga2_web_icingaweb2_database_name }}' - login_host: '{{ icinga2_web_icingaweb2_database_host }}' - login_port: '{{ icinga2_web_icingaweb2_database_port }}' - login_user: '{{ icinga2_web_database_user }}' - login_password: '{{ vault_icinga2_web_icingaweb2_database_pass }}' - ssl_ca: '{{ icinga2_web_ca_path }}' + name: "{{ icinga2_web_icingaweb2_database_name }}" + login_host: "{{ icinga2_web_icingaweb2_database_host }}" + login_port: "{{ icinga2_web_icingaweb2_database_port }}" + login_user: "{{ icinga2_web_database_user }}" + login_password: "{{ vault_icinga2_web_icingaweb2_database_pass }}" + ssl_ca: "{{ icinga2_web_ca_path }}" state: import - target: '{{ icinga2_web_mysql_schema_sql_path }}' + target: "{{ icinga2_web_mysql_schema_sql_path }}" run_once: true when: - not ansible_check_mode - icinga2_web_register_icingaweb2_imported.rc == 1 -- name: install icingaweb2 modules +- name: Install icingaweb2 modules ansible.builtin.package: - name: '{{ icinga2_web_modules }}' + name: "{{ icinga2_web_modules }}" state: present - name: Create icingaweb2 director user for background daemon ansible.builtin.user: name: icingadirector group: icingaweb2 - shell: '/bin/false' - home: '/var/lib/icingadirector' + shell: /bin/false + home: /var/lib/icingadirector system: true when: icinga2_web_director | length != 0 @@ -126,7 +125,7 @@ - ansible_distribution == 'RedHat' - name: Install grafana - ansible.builtin.yum: + ansible.builtin.dnf: name: grafana state: present when: diff --git a/tasks/main.yml b/tasks/main.yml index c866558..d813bfc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,23 +1,22 @@ --- - - name: Include os specific vars - ansible.builtin.include_vars: '{{ item }}' + ansible.builtin.include_vars: "{{ item }}" with_first_found: - - '{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yml' - - '{{ ansible_os_family }}.yml' + - "{{ ansible_distribution }}_{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_os_family }}.yml" tags: - - 'role::icinga2_web' - - 'role::icinga2_web:install' - - 'role::icinga2_web:config' + - role::icinga2_web + - role::icinga2_web:install + - role::icinga2_web:config - name: Include installation tasks ansible.builtin.import_tasks: installation.yml tags: - - 'role::icinga2_web' - - 'role::icinga2_web:install' + - role::icinga2_web + - role::icinga2_web:install - name: Include configuration tasks ansible.builtin.import_tasks: configuration.yml tags: - - 'role::icinga2_web' - - 'role::icinga2_web:config' + - role::icinga2_web + - role::icinga2_web:config diff --git a/vars/Debian.yml b/vars/Debian.yml index 03688a2..77aedd2 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -20,4 +20,4 @@ icinga2_web_monitoring_packages: - icingaweb2-module-monitoring # path to ca store -icinga2_web_ca_path: "/etc/ssl/certs/ca-certificates.crt" +icinga2_web_ca_path: /etc/ssl/certs/ca-certificates.crt diff --git a/vars/RedHat.yml b/vars/RedHat.yml index aa79f90..bee3d1b 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -16,4 +16,4 @@ icinga2_web_icingadb_packages: - icingadb-web # path to ca store -icinga2_web_ca_path: "/etc/ssl/certs/ca-bundle.crt" +icinga2_web_ca_path: /etc/ssl/certs/ca-bundle.crt