From cbad398d6389af8630df002df086ac963a78e4f3 Mon Sep 17 00:00:00 2001 From: "ansible-code-bot[bot]" <145416087+ansible-code-bot[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:40:33 +0000 Subject: [PATCH] Fix ansible-lint rule violations --- .../test/roles/common/handlers/main.yml | 2 +- .../test/roles/common/tasks/main.yml | 27 +++--- .../roles/databaseservers/defaults/main.yml | 16 ++-- .../roles/databaseservers/handlers/main.yml | 2 +- .../databaseservers/tasks/install_mysql.yml | 18 ++-- .../test/roles/databaseservers/tasks/main.yml | 3 +- .../databaseservers/tasks/setup_mysql.yml | 95 +++++++++---------- .../test/roles/databaseservers/vars/main.yml | 16 ++-- .../roles/loadbalancers/defaults/main.yml | 4 +- .../loadbalancers/tasks/configure_haproxy.yml | 12 +-- .../loadbalancers/tasks/install_haproxy.yml | 16 ++-- .../test/roles/loadbalancers/tasks/main.yml | 5 +- .../test/roles/loadbalancers/vars/main.yml | 8 +- .../test/roles/webservers/defaults/main.yml | 4 +- .../roles/webservers/tasks/install_apache.yml | 14 +-- .../roles/webservers/tasks/install_php.yml | 2 +- .../test/roles/webservers/tasks/main.yml | 8 +- .../roles/webservers/tasks/setup_site.yml | 38 ++++---- .../test/roles/webservers/vars/main.yml | 8 +- 19 files changed, 149 insertions(+), 149 deletions(-) diff --git a/klanten/testklant/test/roles/common/handlers/main.yml b/klanten/testklant/test/roles/common/handlers/main.yml index bc494fe..333d30d 100644 --- a/klanten/testklant/test/roles/common/handlers/main.yml +++ b/klanten/testklant/test/roles/common/handlers/main.yml @@ -2,4 +2,4 @@ - name: restart ntp service: name: ntp - state: restarted \ No newline at end of file + state: restarted diff --git a/klanten/testklant/test/roles/common/tasks/main.yml b/klanten/testklant/test/roles/common/tasks/main.yml index 336dcdf..fb1a914 100644 --- a/klanten/testklant/test/roles/common/tasks/main.yml +++ b/klanten/testklant/test/roles/common/tasks/main.yml @@ -1,41 +1,40 @@ --- - name: Add ufw rule for ssh - ufw: + community.general.ufw: rule: allow - port: '22' + port: "22" - name: Enable ufw when: firewall - ufw: + community.general.ufw: state: enabled - name: Disable ufw when: not firewall - ufw: + community.general.ufw: state: disabled - name: Install ntp when: custom_ntp - apt: + tags: ntp + ansible.builtin.apt: name: ntp state: present - update_cache: yes - tags: ntp + update_cache: true - name: Determine if timesyncd is enabled register: timesyncdstatus - command: timedatectl status changed_when: false + ansible.builtin.command: timedatectl status - name: Disable timesyncd - command: timedatectl set-ntp off - when: "'systemd-timesyncd.service active: yes' in timesyncdstatus.stdout and - custom_ntp" + when: "'systemd-timesyncd.service active: yes' in timesyncdstatus.stdout and custom_ntp" + ansible.builtin.command: timedatectl set-ntp off - name: Configure ntp file when: custom_ntp - template: - src: ntp.conf.j2 - dest: /etc/ntp.conf tags: ntp notify: restart ntp + ansible.builtin.template: + src: ntp.conf.j2 + dest: /etc/ntp.conf diff --git a/klanten/testklant/test/roles/databaseservers/defaults/main.yml b/klanten/testklant/test/roles/databaseservers/defaults/main.yml index 29dcfea..450ba41 100644 --- a/klanten/testklant/test/roles/databaseservers/defaults/main.yml +++ b/klanten/testklant/test/roles/databaseservers/defaults/main.yml @@ -1,18 +1,18 @@ --- -mysql_non_root_user_name: 'admin' +mysql_non_root_user_name: admin mysql_root_hosts: - - 'localhost' - - '127.0.0.1' - - '::1' + - localhost + - 127.0.0.1 + - ::1 mysql_non_root_user: true mysql_non_root_user_hosts: - - 'localhost' - - '127.0.0.1' - - '::1' + - localhost + - 127.0.0.1 + - ::1 mysql_enable: true mysql_use_dump: false mysql_remove_testdb: true mysql_remove_anon_users: true mysql_bind_addr: 127.0.0.1 mysql_check_ssl: true -mysql_non_root_user_privs: '*.*:USAGE' +mysql_non_root_user_privs: "*.*:USAGE" diff --git a/klanten/testklant/test/roles/databaseservers/handlers/main.yml b/klanten/testklant/test/roles/databaseservers/handlers/main.yml index c56e557..9ec0733 100644 --- a/klanten/testklant/test/roles/databaseservers/handlers/main.yml +++ b/klanten/testklant/test/roles/databaseservers/handlers/main.yml @@ -1,5 +1,5 @@ --- - name: restart mysql service: - name: 'mysql' + name: mysql state: restarted diff --git a/klanten/testklant/test/roles/databaseservers/tasks/install_mysql.yml b/klanten/testklant/test/roles/databaseservers/tasks/install_mysql.yml index daeead5..8343812 100644 --- a/klanten/testklant/test/roles/databaseservers/tasks/install_mysql.yml +++ b/klanten/testklant/test/roles/databaseservers/tasks/install_mysql.yml @@ -1,19 +1,19 @@ --- - name: Install MySQL Python libraries - apt: - name: 'python3-mysqldb' + ansible.builtin.apt: + name: python3-mysqldb state: present - update_cache: yes + update_cache: true - name: Install MySQL - apt: + ansible.builtin.apt: pkg: - - 'mysql-common' - - 'mysql-server' + - mysql-common + - mysql-server state: present - update_cache: yes + update_cache: true - name: Add UFW rule for MySQL - ufw: + community.general.ufw: rule: allow - port: '{{ mysql_port | mandatory }}' + port: "{{ mysql_port | mandatory }}" diff --git a/klanten/testklant/test/roles/databaseservers/tasks/main.yml b/klanten/testklant/test/roles/databaseservers/tasks/main.yml index 4aa3c03..af60215 100644 --- a/klanten/testklant/test/roles/databaseservers/tasks/main.yml +++ b/klanten/testklant/test/roles/databaseservers/tasks/main.yml @@ -1,3 +1,4 @@ --- -- import_tasks: install_mysql.yml +- ansible.builtin.import_tasks: install_mysql.yml + - import_tasks: setup_mysql.yml diff --git a/klanten/testklant/test/roles/databaseservers/tasks/setup_mysql.yml b/klanten/testklant/test/roles/databaseservers/tasks/setup_mysql.yml index f0320b4..746b059 100644 --- a/klanten/testklant/test/roles/databaseservers/tasks/setup_mysql.yml +++ b/klanten/testklant/test/roles/databaseservers/tasks/setup_mysql.yml @@ -1,97 +1,94 @@ --- - name: Copy MySQL configuration - template: + notify: restart mysql + ansible.builtin.template: src: my.cnf.j2 - dest: '/etc/mysql/my.cnf' + dest: /etc/mysql/my.cnf owner: root group: root - mode: '0644' - notify: restart mysql + mode: "0644" - name: Start MySQL - service: - name: 'mysql' + ansible.builtin.service: + name: mysql state: started - name: Enable MySQL when: mysql_enable - service: - name: 'mysql' - enabled: 'yes' + ansible.builtin.service: + name: mysql + enabled: true - name: Copy .my.cnf - template: - src: '.my.cnf.j2' - dest: '/root/.my.cnf' + ansible.builtin.template: + src: .my.cnf.j2 + dest: /root/.my.cnf owner: root group: root - mode: '0600' + mode: "0600" - name: Set root password - mysql_user: + no_log: true + community.mysql.mysql_user: name: root - host: '{{ item }}' - password: '{{ mysql_root_password | mandatory }}' + host: "{{ item }}" + password: "{{ mysql_root_password | mandatory }}" state: present - with_items: - - '{{ mysql_root_hosts }}' - no_log: true + loop: + - "{{ mysql_root_hosts }}" - name: Copy database dump file when: mysql_use_dump - copy: - src: '{{ mysql_db_file | mandatory }}' + ansible.builtin.copy: + src: "{{ mysql_db_file | mandatory }}" dest: /tmp - name: Restore database when: mysql_use_dump - mysql_db: - name: '{{ mysql_db_name | mandatory }}' + community.mysql.mysql_db: + name: "{{ mysql_db_name | mandatory }}" state: import - target: '/tmp/{{ mysql_db_file | mandatory }}' + target: /tmp/{{ mysql_db_file | mandatory }} - name: Create non-root user when: mysql_non_root_user - mysql_user: - name: '{{ mysql_non_root_user_name | mandatory }}' - host: '{{ item }}' - password: '{{ mysql_non_root_user_password }}' - priv: '{{ mysql_non_root_user_privs }}' - state: present - with_items: - - '{{ mysql_non_root_user_hosts }}' no_log: true + community.mysql.mysql_user: + name: "{{ mysql_non_root_user_name | mandatory }}" + host: "{{ item }}" + password: "{{ mysql_non_root_user_password }}" + priv: "{{ mysql_non_root_user_privs }}" + state: present + loop: + - "{{ mysql_non_root_user_hosts }}" - name: Remove test database when: mysql_remove_testdb - mysql_db: + community.mysql.mysql_db: name: test state: absent - name: Remove anonymous users when: mysql_remove_anon_users - mysql_user: - name: '' - state: absent - host_all: yes no_log: true + community.mysql.mysql_user: + name: "" + state: absent + host_all: true - name: Bind to interface(s) - lineinfile: - path: /etc/mysql/mysql.conf.d/mysqld.cnf - regexp: '^bind-address' - line: 'bind-address = {{ mysql_bind_addr | mandatory }}' notify: restart mysql + ansible.builtin.lineinfile: + path: /etc/mysql/mysql.conf.d/mysqld.cnf + regexp: ^bind-address + line: bind-address = {{ mysql_bind_addr | mandatory }} - name: Check if SSL is enabled when: mysql_check_ssl - mysql_info: - login_user: root - filter: settings register: ssl failed_when: > - ('have_openssl:\": \"\"' in ssl.settings) or - ('have_ssl:\": \"\"' in ssl.settings) or - ('ssl_ca:\": \"\"' in ssl.settings) or - ('ssl_cert:\": \"\"' in ssl.settings) or - ('ssl_key:\": \"\"' in ssl.settings) + ('have_openssl:\": \"\"' in ssl.settings) or ('have_ssl:\": \"\"' in ssl.settings) or ('ssl_ca:\": \"\"' in ssl.settings) or ('ssl_cert:\": \"\"' in ssl.settings) + or ('ssl_key:\": \"\"' in ssl.settings) + community.mysql.mysql_info: + login_user: root + filter: settings diff --git a/klanten/testklant/test/roles/databaseservers/vars/main.yml b/klanten/testklant/test/roles/databaseservers/vars/main.yml index 3104539..f37e634 100644 --- a/klanten/testklant/test/roles/databaseservers/vars/main.yml +++ b/klanten/testklant/test/roles/databaseservers/vars/main.yml @@ -1,11 +1,11 @@ --- mysql_use_dump: true -mysql_db_file: 'test.sql' +mysql_db_file: test.sql mysql_non_root_user_hosts: - - '10.0.1.11' - - '10.0.1.12' - - 'localhost' - - '127.0.0.1' - - '::1' -mysql_bind_addr: 0.0.0.0 -mysql_non_root_user_privs: 'vm2.test:SELECT' + - 10.0.1.11 + - 10.0.1.12 + - localhost + - 127.0.0.1 + - ::1 +mysql_bind_addr: "0.0.0.0" +mysql_non_root_user_privs: vm2.test:SELECT diff --git a/klanten/testklant/test/roles/loadbalancers/defaults/main.yml b/klanten/testklant/test/roles/loadbalancers/defaults/main.yml index 2ae8813..6c5dc3e 100644 --- a/klanten/testklant/test/roles/loadbalancers/defaults/main.yml +++ b/klanten/testklant/test/roles/loadbalancers/defaults/main.yml @@ -23,5 +23,5 @@ haproxy_timeout_connect: 5000 haproxy_timeout_client: 50000 haproxy_timeout_server: 50000 haproxy_enable_stats: false -haproxy_frontends: '' -haproxy_backends: '' +haproxy_frontends: "" +haproxy_backends: "" diff --git a/klanten/testklant/test/roles/loadbalancers/tasks/configure_haproxy.yml b/klanten/testklant/test/roles/loadbalancers/tasks/configure_haproxy.yml index e53cb17..0e6dba6 100644 --- a/klanten/testklant/test/roles/loadbalancers/tasks/configure_haproxy.yml +++ b/klanten/testklant/test/roles/loadbalancers/tasks/configure_haproxy.yml @@ -1,21 +1,21 @@ --- - name: Check if default configuration exists - stat: - path: /etc/haproxy/haproxy.cfg* register: haproxydefaultconfig + ansible.builtin.stat: + path: /etc/haproxy/haproxy.cfg* - name: Rename default configuration - command: mv /etc/haproxy/haproxy.cfg{,.original} when: haproxydefaultconfig.stat.exists + ansible.builtin.command: mv /etc/haproxy/haproxy.cfg{,.original} - name: Copy new configuration - template: + notify: restart haproxy + ansible.builtin.template: src: haproxy.cfg.j2 dest: /etc/haproxy/haproxy.cfg - notify: restart haproxy - name: Verify configuration - command: haproxy -f /etc/haproxy/haproxy.cfg -c register: haproxycfgchk failed_when: "'error' in haproxycfgchk.stdout" changed_when: false + ansible.builtin.command: haproxy -f /etc/haproxy/haproxy.cfg -c diff --git a/klanten/testklant/test/roles/loadbalancers/tasks/install_haproxy.yml b/klanten/testklant/test/roles/loadbalancers/tasks/install_haproxy.yml index 5ad604c..7e1f55f 100644 --- a/klanten/testklant/test/roles/loadbalancers/tasks/install_haproxy.yml +++ b/klanten/testklant/test/roles/loadbalancers/tasks/install_haproxy.yml @@ -1,20 +1,20 @@ --- - name: Install HAProxy - apt: - name: 'haproxy' + ansible.builtin.apt: + name: haproxy state: present - update_cache: yes + update_cache: true - name: Check if HAProxy is working - command: haproxy -v register: haproxystatus failed_when: "'version' not in haproxystatus.stdout" changed_when: false + ansible.builtin.command: haproxy -v - name: Add ufw rule for HAProxy when: haproxy_ports_list is defined - ufw: + community.general.ufw: rule: allow - port: '{{ item }}' - with_items: - - '{{ haproxy_ports_list }}' + port: "{{ item }}" + loop: + - "{{ haproxy_ports_list }}" diff --git a/klanten/testklant/test/roles/loadbalancers/tasks/main.yml b/klanten/testklant/test/roles/loadbalancers/tasks/main.yml index 581ee4b..2ae8c2f 100644 --- a/klanten/testklant/test/roles/loadbalancers/tasks/main.yml +++ b/klanten/testklant/test/roles/loadbalancers/tasks/main.yml @@ -1,3 +1,4 @@ --- -- import_tasks: install_haproxy.yml -- import_tasks: configure_haproxy.yml \ No newline at end of file +- ansible.builtin.import_tasks: install_haproxy.yml + +- import_tasks: configure_haproxy.yml diff --git a/klanten/testklant/test/roles/loadbalancers/vars/main.yml b/klanten/testklant/test/roles/loadbalancers/vars/main.yml index 16dd550..26c19f0 100644 --- a/klanten/testklant/test/roles/loadbalancers/vars/main.yml +++ b/klanten/testklant/test/roles/loadbalancers/vars/main.yml @@ -13,7 +13,7 @@ haproxy_stats_pass: !vault | 3566 haproxy_frontends: - name: site - bind: '*' + bind: "*" port: 80 options: forwardfor default_backend: webservers @@ -27,7 +27,7 @@ haproxy_backends: - name: testklant-test-web02 port: 80 options: check - extra_options: 'option httpchk' + extra_options: option httpchk haproxy_ports_list: - - '80' - - '8080' + - "80" + - "8080" diff --git a/klanten/testklant/test/roles/webservers/defaults/main.yml b/klanten/testklant/test/roles/webservers/defaults/main.yml index 80192f1..2640d89 100644 --- a/klanten/testklant/test/roles/webservers/defaults/main.yml +++ b/klanten/testklant/test/roles/webservers/defaults/main.yml @@ -1,6 +1,6 @@ --- -apache_directory_index: 'index.html index.cgi index.php index.pl index.xhtml index.htm' +apache_directory_index: index.html index.cgi index.php index.pl index.xhtml index.htm install_php: false apache_use_repo: https://github.com/muan/hello-world.git apache_use_template: false -apache_virtual_hosts: '' +apache_virtual_hosts: "" diff --git a/klanten/testklant/test/roles/webservers/tasks/install_apache.yml b/klanten/testklant/test/roles/webservers/tasks/install_apache.yml index 5c8f35a..8b49084 100644 --- a/klanten/testklant/test/roles/webservers/tasks/install_apache.yml +++ b/klanten/testklant/test/roles/webservers/tasks/install_apache.yml @@ -1,17 +1,17 @@ --- - name: Install apache - apt: - name: 'apache2' + ansible.builtin.apt: + name: apache2 state: present - update_cache: yes + update_cache: true - name: Add ufw rule for apache2 - ufw: + community.general.ufw: rule: allow - port: '80' + port: "80" - name: Apache service state - service: + ansible.builtin.service: name: apache2 state: started - enabled: yes + enabled: true diff --git a/klanten/testklant/test/roles/webservers/tasks/install_php.yml b/klanten/testklant/test/roles/webservers/tasks/install_php.yml index bcca06b..9d86afa 100644 --- a/klanten/testklant/test/roles/webservers/tasks/install_php.yml +++ b/klanten/testklant/test/roles/webservers/tasks/install_php.yml @@ -1,7 +1,7 @@ --- - name: Install PHP when: install_php - apt: + ansible.builtin.apt: pkg: - php - libapache2-mod-php diff --git a/klanten/testklant/test/roles/webservers/tasks/main.yml b/klanten/testklant/test/roles/webservers/tasks/main.yml index 2dc6d94..bbb5285 100644 --- a/klanten/testklant/test/roles/webservers/tasks/main.yml +++ b/klanten/testklant/test/roles/webservers/tasks/main.yml @@ -1,4 +1,6 @@ --- -- import_tasks: install_apache.yml -- import_tasks: install_php.yml -- import_tasks: setup_site.yml \ No newline at end of file +- ansible.builtin.import_tasks: install_apache.yml + +- ansible.builtin.import_tasks: install_php.yml + +- import_tasks: setup_site.yml diff --git a/klanten/testklant/test/roles/webservers/tasks/setup_site.yml b/klanten/testklant/test/roles/webservers/tasks/setup_site.yml index 8aed12e..c76ade7 100644 --- a/klanten/testklant/test/roles/webservers/tasks/setup_site.yml +++ b/klanten/testklant/test/roles/webservers/tasks/setup_site.yml @@ -1,49 +1,49 @@ --- - name: Set OS specific variables - include_vars: '{{ item }}' with_first_found: - - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' - - '{{ ansible_distribution }}.yml' + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_distribution }}.yml" + ansible.builtin.include_vars: "{{ item }}" - name: Delete default page - file: + ansible.builtin.file: path: /var/www/html/index.html state: absent - name: Copy dir config file - template: - src: dir.conf.j2 - dest: '{{ apache_dir }}/mods-enabled/dir.conf' notify: restart apache + ansible.builtin.template: + src: dir.conf.j2 + dest: "{{ apache_dir }}/mods-enabled/dir.conf" - name: Copy site config file - template: - src: site.conf.j2 - dest: '{{ apache_dir }}/sites-available/000-default.conf' notify: restart apache + ansible.builtin.template: + src: site.conf.j2 + dest: "{{ apache_dir }}/sites-available/000-default.conf" - name: Enable configuration - file: - src: '{{ apache_dir }}/sites-available/000-default.conf' - dest: '{{ apache_dir }}/sites-enabled/000-default.conf' - state: link notify: restart apache + ansible.builtin.file: + src: "{{ apache_dir }}/sites-available/000-default.conf" + dest: "{{ apache_dir }}/sites-enabled/000-default.conf" + state: link - name: Delete html directory when: apache_use_repo is defined - file: + ansible.builtin.file: path: /var/www/html state: absent - name: Copy the code from repository when: apache_use_repo is defined - git: - repo: '{{ apache_use_repo }}' + ansible.builtin.git: + repo: "{{ apache_use_repo }}" dest: /var/www/html - name: Copy index.php when: apache_use_template - template: + ansible.builtin.template: src: index.php.j2 dest: /var/www/html/index.php - mode: 0644 + mode: 420 diff --git a/klanten/testklant/test/roles/webservers/vars/main.yml b/klanten/testklant/test/roles/webservers/vars/main.yml index 4e4edb5..e278dd5 100644 --- a/klanten/testklant/test/roles/webservers/vars/main.yml +++ b/klanten/testklant/test/roles/webservers/vars/main.yml @@ -1,12 +1,12 @@ --- -apache_directory_index: 'index.php index.html index.cgi index.pl index.xhtml index.htm' +apache_directory_index: index.php index.html index.cgi index.pl index.xhtml index.htm apache_virtual_hosts: - - bind: '*' + - bind: "*" port: 80 server_admin: webmaster@localhost root: /var/www/html - error_log: '${APACHE_LOG_DIR}/error.log' - custom_log: '${APACHE_LOG_DIR}/access.log' + error_log: ${APACHE_LOG_DIR}/error.log + custom_log: ${APACHE_LOG_DIR}/access.log custom_log_options: combined install_php: true apache_use_template: true