Auto-fix usage of modules via FQCN

Since ansible-core 2.10 it is recommended to use modules via FQCN
In order to align with recommendation, we perform migration
by applying suggestions made by `ansible-lint --fix=fqcn`

Change-Id: I9c3a86af107728cbddb4e2cdb778065001d66b93
This commit is contained in:
Dmitriy Rabotyagov 2025-02-13 09:29:40 +01:00
parent e1e62d3f57
commit 9e1a3749da
8 changed files with 44 additions and 44 deletions

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Regen pem # noqa: no-changed-when - name: Regen pem # noqa: no-changed-when
shell: >- ansible.builtin.shell: >-
cat {{ item_base_path ~ '.crt' }} $(test -f {{ item_base_path ~ '-ca.crt' }} && cat {{ item_base_path ~ '.crt' }} $(test -f {{ item_base_path ~ '-ca.crt' }} &&
echo {{ item_base_path ~ '-ca.crt' }}) {{ item_base_path ~ '.key' }} > {{ item_base_path ~ '.pem' }} echo {{ item_base_path ~ '-ca.crt' }}) {{ item_base_path ~ '.key' }} > {{ item_base_path ~ '.pem' }}
vars: vars:
@ -28,7 +28,7 @@
- name: Regenerate maps - name: Regenerate maps
vars: vars:
all_changed_results: "{{ (map_create.results + map_delete.results) | select('changed') }}" all_changed_results: "{{ (map_create.results + map_delete.results) | select('changed') }}"
assemble: ansible.builtin.assemble:
src: "/etc/haproxy/map.conf.d/{{ item }}" src: "/etc/haproxy/map.conf.d/{{ item }}"
dest: "/etc/haproxy/{{ item }}.map" dest: "/etc/haproxy/{{ item }}.map"
mode: "0640" mode: "0640"
@ -37,7 +37,7 @@
with_items: "{{ all_changed_results | map(attribute='item') | flatten | selectattr('name', 'defined') | map(attribute='name') | unique }}" with_items: "{{ all_changed_results | map(attribute='item') | flatten | selectattr('name', 'defined') | map(attribute='name') | unique }}"
- name: Regenerate haproxy configuration - name: Regenerate haproxy configuration
assemble: ansible.builtin.assemble:
src: "/etc/haproxy/conf.d" src: "/etc/haproxy/conf.d"
dest: "/etc/haproxy/haproxy.cfg" dest: "/etc/haproxy/haproxy.cfg"
validate: /usr/sbin/haproxy -c -f %s validate: /usr/sbin/haproxy -c -f %s
@ -48,12 +48,12 @@
- haproxy-general-config - haproxy-general-config
- name: Get package facts - name: Get package facts
package_facts: ansible.builtin.package_facts:
manager: auto manager: auto
listen: Restart rsyslog listen: Restart rsyslog
- name: Restart rsyslog - name: Restart rsyslog
service: ansible.builtin.service:
name: "rsyslog" name: "rsyslog"
state: "restarted" state: "restarted"
enabled: true enabled: true
@ -62,7 +62,7 @@
- "'rsyslog' in ansible_facts.packages" - "'rsyslog' in ansible_facts.packages"
- name: Reload haproxy - name: Reload haproxy
service: ansible.builtin.service:
name: "haproxy" name: "haproxy"
state: "reloaded" state: "reloaded"
enabled: true enabled: true

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Install HAProxy Packages - name: Install HAProxy Packages
package: ansible.builtin.package:
name: "{{ haproxy_distro_packages }}" name: "{{ haproxy_distro_packages }}"
state: "{{ haproxy_package_state }}" state: "{{ haproxy_package_state }}"
update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
@ -27,13 +27,13 @@
- name: Install HATop Utility - name: Install HATop Utility
block: block:
- name: Ensure haproxy_hatop_download_path exists on haproxy - name: Ensure haproxy_hatop_download_path exists on haproxy
file: ansible.builtin.file:
path: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}" path: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}"
state: directory state: directory
mode: "0755" mode: "0755"
- name: Download hatop package - name: Download hatop package
get_url: ansible.builtin.get_url:
url: "{{ haproxy_hatop_download_url }}" url: "{{ haproxy_hatop_download_url }}"
dest: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename }}" dest: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename }}"
validate_certs: "{{ haproxy_hatop_download_validate_certs }}" validate_certs: "{{ haproxy_hatop_download_validate_certs }}"
@ -45,7 +45,7 @@
delay: 10 delay: 10
- name: Unarchive HATop - name: Unarchive HATop
unarchive: ansible.builtin.unarchive:
src: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename }}" src: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename }}"
dest: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}" dest: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}"
remote_src: true remote_src: true
@ -53,7 +53,7 @@
- --strip-components=1 - --strip-components=1
- name: Copy HATop binary - name: Copy HATop binary
copy: ansible.builtin.copy:
src: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}/bin/hatop" src: "{{ haproxy_hatop_download_path }}/{{ haproxy_hatop_download_url | basename | replace('.tar.gz', '') }}/bin/hatop"
dest: /usr/local/bin/hatop dest: /usr/local/bin/hatop
mode: "0755" mode: "0755"

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Make haproxy bindable on non local addresses - name: Make haproxy bindable on non local addresses
sysctl: ansible.posix.sysctl:
name: "{{ item }}" name: "{{ item }}"
value: 1 value: 1
sysctl_set: true sysctl_set: true
@ -30,7 +30,7 @@
# to handle log collection and log file rotation. This is not needed since # to handle log collection and log file rotation. This is not needed since
# journald is used for this purpose # journald is used for this purpose
- name: Delete rsyslog and logrotate configs - name: Delete rsyslog and logrotate configs
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
with_items: with_items:
@ -42,7 +42,7 @@
- haproxy-logging-config - haproxy-logging-config
- name: Drop base haproxy config - name: Drop base haproxy config
template: ansible.builtin.template:
src: "haproxy.cfg.j2" src: "haproxy.cfg.j2"
dest: "/etc/haproxy/conf.d/00-haproxy" dest: "/etc/haproxy/conf.d/00-haproxy"
mode: "0640" mode: "0640"
@ -53,7 +53,7 @@
- haproxy-base-config - haproxy-base-config
- name: Including haproxy_service_config tasks - name: Including haproxy_service_config tasks
include_tasks: haproxy_service_config.yml ansible.builtin.include_tasks: haproxy_service_config.yml
args: args:
apply: apply:
tags: tags:
@ -62,7 +62,7 @@
- haproxy-service-config - haproxy-service-config
- name: Create log directory if it does not exist - name: Create log directory if it does not exist
file: ansible.builtin.file:
path: "{{ haproxy_log_mount_point | dirname }}" path: "{{ haproxy_log_mount_point | dirname }}"
state: directory state: directory
mode: "0755" mode: "0755"
@ -72,7 +72,7 @@
# NOTE(jrosser) The next task fails on Centos without this, # NOTE(jrosser) The next task fails on Centos without this,
# an empty directory rather than a file is made and the bind mount fails # an empty directory rather than a file is made and the bind mount fails
- name: Ensure empty file is availble to bind mount log socket - name: Ensure empty file is availble to bind mount log socket
file: ansible.builtin.file:
state: touch state: touch
path: "{{ haproxy_log_mount_point }}" path: "{{ haproxy_log_mount_point }}"
access_time: preserve access_time: preserve
@ -80,7 +80,7 @@
mode: "0666" mode: "0666"
- name: Make log socket available to chrooted filesystem - name: Make log socket available to chrooted filesystem
mount: ansible.posix.mount:
src: "{{ haproxy_log_socket }}" src: "{{ haproxy_log_socket }}"
path: "{{ haproxy_log_mount_point }}" path: "{{ haproxy_log_mount_point }}"
opts: bind opts: bind
@ -88,7 +88,7 @@
fstype: none fstype: none
- name: Prevent SELinux from preventing haproxy from binding to arbitrary ports - name: Prevent SELinux from preventing haproxy from binding to arbitrary ports
seboolean: ansible.posix.seboolean:
name: haproxy_connect_any name: haproxy_connect_any
state: true state: true
persistent: true persistent: true

View File

@ -19,7 +19,7 @@
# log aggregation links as well as ensure common user # log aggregation links as well as ensure common user
# functionality across various distros that we support. # functionality across various distros that we support.
- name: Create the haproxy system group - name: Create the haproxy system group
group: ansible.builtin.group:
name: "haproxy" name: "haproxy"
state: "present" state: "present"
system: "yes" system: "yes"
@ -32,7 +32,7 @@
# log aggregation links as well as ensure common user # log aggregation links as well as ensure common user
# functionality across various distros that we support. # functionality across various distros that we support.
- name: Create the haproxy system user - name: Create the haproxy system user
user: ansible.builtin.user:
name: "haproxy" name: "haproxy"
group: "haproxy" group: "haproxy"
comment: "haproxy user" comment: "haproxy user"
@ -44,7 +44,7 @@
- haproxy-user - haproxy-user
- name: Create haproxy conf.d dir - name: Create haproxy conf.d dir
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
mode: "0755" mode: "0755"
@ -55,7 +55,7 @@
- "{{ haproxy_ssl_cert_path }}" - "{{ haproxy_ssl_cert_path }}"
- name: Copy static files - name: Copy static files
copy: ansible.builtin.copy:
content: "{{ item.content }}" content: "{{ item.content }}"
dest: "{{ item.dest }}" dest: "{{ item.dest }}"
mode: "0644" mode: "0644"

View File

@ -16,11 +16,11 @@
# NOTE(damiandabrowski): Deprecated haproxy_service_configs format # NOTE(damiandabrowski): Deprecated haproxy_service_configs format
# conversion will be removed in 2024.1. # conversion will be removed in 2024.1.
- name: Define blank _haproxy_service_configs_simplified variable - name: Define blank _haproxy_service_configs_simplified variable
set_fact: ansible.builtin.set_fact:
_haproxy_service_configs_simplified: [] _haproxy_service_configs_simplified: []
- name: Append services to _haproxy_service_configs_simplified list - name: Append services to _haproxy_service_configs_simplified list
set_fact: ansible.builtin.set_fact:
_haproxy_service_configs_simplified: "{{ _haproxy_service_configs_simplified + [(item.service is defined) | ternary(item.service, item)] }}" _haproxy_service_configs_simplified: "{{ _haproxy_service_configs_simplified + [(item.service is defined) | ternary(item.service, item)] }}"
loop: "{{ haproxy_service_configs }}" loop: "{{ haproxy_service_configs }}"
@ -29,7 +29,7 @@
########################################################################### ###########################################################################
- name: Create haproxy service config files - name: Create haproxy service config files
template: ansible.builtin.template:
src: service.j2 src: service.j2
dest: "/etc/haproxy/conf.d/{{ service.haproxy_service_name }}" dest: "/etc/haproxy/conf.d/{{ service.haproxy_service_name }}"
owner: root owner: root
@ -51,7 +51,7 @@
notify: Regenerate haproxy configuration notify: Regenerate haproxy configuration
- name: Remove haproxy service config files for absent services - name: Remove haproxy service config files for absent services
file: ansible.builtin.file:
path: "/etc/haproxy/conf.d/{{ service.haproxy_service_name }}" path: "/etc/haproxy/conf.d/{{ service.haproxy_service_name }}"
state: absent state: absent
notify: Regenerate haproxy configuration notify: Regenerate haproxy configuration
@ -68,7 +68,7 @@
########################################################################### ###########################################################################
- name: Create haproxy map fragment directories - name: Create haproxy map fragment directories
file: ansible.builtin.file:
state: directory state: directory
path: "/etc/haproxy/map.conf.d/{{ item }}" path: "/etc/haproxy/map.conf.d/{{ item }}"
owner: root owner: root
@ -86,7 +86,7 @@
- name: Create haproxy map files - name: Create haproxy map files
vars: vars:
map_file: "/etc/haproxy/map.conf.d/{{ item.1.name }}/{{ item.1.order | default('00') }}-{{ item.0.haproxy_service_name }}.map" map_file: "/etc/haproxy/map.conf.d/{{ item.1.name }}/{{ item.1.order | default('00') }}-{{ item.0.haproxy_service_name }}.map"
template: ansible.builtin.template:
src: map.j2 src: map.j2
dest: "{{ map_file }}" dest: "{{ map_file }}"
owner: root owner: root
@ -105,7 +105,7 @@
# remove map entries when the service is not enabled, the service is absent or the map is absent # remove map entries when the service is not enabled, the service is absent or the map is absent
- name: Delete unused map entries - name: Delete unused map entries
file: ansible.builtin.file:
state: absent state: absent
path: "/etc/haproxy/map.conf.d/{{ item.1.name }}/{{ item.1.order | default('00') }}-{{ item.0.haproxy_service_name }}.map" path: "/etc/haproxy/map.conf.d/{{ item.1.name }}/{{ item.1.order | default('00') }}-{{ item.0.haproxy_service_name }}.map"
when: when:

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Gather variables for each operating system - name: Gather variables for each operating system
include_vars: "{{ lookup('first_found', params) }}" ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
vars: vars:
params: params:
files: files:
@ -27,7 +27,7 @@
- "{{ role_path }}/vars" - "{{ role_path }}/vars"
- name: Including haproxy_service_config tasks - name: Including haproxy_service_config tasks
include_tasks: haproxy_service_config.yml ansible.builtin.include_tasks: haproxy_service_config.yml
args: args:
apply: apply:
tags: tags:

View File

@ -12,13 +12,13 @@
# limitations under the License. # limitations under the License.
- name: Install certbot from distro package - name: Install certbot from distro package
package: ansible.builtin.package:
name: "{{ haproxy_distro_certbot_packages }}" name: "{{ haproxy_distro_certbot_packages }}"
state: present state: present
- name: Create first time ssl cert with certbot - name: Create first time ssl cert with certbot
throttle: 1 throttle: 1
shell: > ansible.builtin.shell: >
{% if haproxy_ssl_letsencrypt_certbot_challenge == 'http-01' %} {% if haproxy_ssl_letsencrypt_certbot_challenge == 'http-01' %}
timeout {{ haproxy_ssl_letsencrypt_pre_hook_timeout }} timeout {{ haproxy_ssl_letsencrypt_pre_hook_timeout }}
python3 -m http.server {{ haproxy_ssl_letsencrypt_certbot_backend_port }} python3 -m http.server {{ haproxy_ssl_letsencrypt_certbot_backend_port }}
@ -45,7 +45,7 @@
# Certbot automatically installs its systemd timer responsible for renewals # Certbot automatically installs its systemd timer responsible for renewals
- name: Create certbot pre hook - name: Create certbot pre hook
template: ansible.builtin.template:
src: letsencrypt_pre_hook_certbot_distro.j2 src: letsencrypt_pre_hook_certbot_distro.j2
dest: /etc/letsencrypt/renewal-hooks/pre/haproxy-pre dest: /etc/letsencrypt/renewal-hooks/pre/haproxy-pre
mode: "0755" mode: "0755"
@ -53,13 +53,13 @@
- haproxy_ssl_letsencrypt_certbot_challenge == 'http-01' - haproxy_ssl_letsencrypt_certbot_challenge == 'http-01'
- name: Create certbot post renewal hook - name: Create certbot post renewal hook
template: ansible.builtin.template:
src: letsencrypt_renew_certbot_distro.j2 src: letsencrypt_renew_certbot_distro.j2
dest: /etc/letsencrypt/renewal-hooks/post/haproxy-renew dest: /etc/letsencrypt/renewal-hooks/post/haproxy-renew
mode: "0755" mode: "0755"
- name: Create new pem file for haproxy - name: Create new pem file for haproxy
assemble: ansible.builtin.assemble:
src: "{{ haproxy_ssl_letsencrypt_config_path }}/{{ haproxy_ssl_letsencrypt_domains | first }}" src: "{{ haproxy_ssl_letsencrypt_config_path }}/{{ haproxy_ssl_letsencrypt_domains | first }}"
dest: >- dest: >-
{{ {{

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
- name: Gather variables for each operating system - name: Gather variables for each operating system
include_vars: "{{ lookup('first_found', params) }}" ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
vars: vars:
params: params:
files: files:
@ -29,19 +29,19 @@
- always - always
- name: Importing haproxy_pre_install tasks - name: Importing haproxy_pre_install tasks
import_tasks: haproxy_pre_install.yml ansible.builtin.import_tasks: haproxy_pre_install.yml
tags: tags:
- haproxy_server-install - haproxy_server-install
- name: Importing haproxy_install tasks - name: Importing haproxy_install tasks
import_tasks: haproxy_install.yml ansible.builtin.import_tasks: haproxy_install.yml
tags: tags:
- haproxy_server-install - haproxy_server-install
# NOTE (jrosser) the self signed certificate is also needed for bootstrapping # NOTE (jrosser) the self signed certificate is also needed for bootstrapping
# letsencrypt, as haproxy will not start with ssl config but a missing certificate # letsencrypt, as haproxy will not start with ssl config but a missing certificate
- name: Create and install SSL certificates - name: Create and install SSL certificates
include_role: ansible.builtin.include_role:
name: pki name: pki
apply: apply:
tags: tags:
@ -66,16 +66,16 @@
- pki - pki
- name: Importing haproxy_post_install tasks - name: Importing haproxy_post_install tasks
import_tasks: haproxy_post_install.yml ansible.builtin.import_tasks: haproxy_post_install.yml
tags: tags:
- haproxy_server-config - haproxy_server-config
# NOTE(jrosser) we must reload the haproxy config before doing the first time certbot setup to ensure the letsencypt backend is configured # NOTE(jrosser) we must reload the haproxy config before doing the first time certbot setup to ensure the letsencypt backend is configured
- name: Flush handlers - name: Flush handlers
meta: flush_handlers ansible.builtin.meta: flush_handlers
- name: Including haproxy_ssl_letsencrypt tasks - name: Including haproxy_ssl_letsencrypt tasks
include_tasks: haproxy_ssl_letsencrypt.yml ansible.builtin.include_tasks: haproxy_ssl_letsencrypt.yml
when: when:
- haproxy_ssl | bool - haproxy_ssl | bool
- haproxy_ssl_letsencrypt_enable | bool - haproxy_ssl_letsencrypt_enable | bool