From f49056d79bdec662eea7c51005407a1e56b362a1 Mon Sep 17 00:00:00 2001 From: Luka Petrovic Date: Fri, 18 Oct 2024 16:11:34 +0200 Subject: [PATCH] lint --- defaults/main.yml | 3 ++- handlers/main.yml | 2 +- tasks/main.yml | 57 ++++++++++++++++++++++++----------------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index ce577bb..ca8624c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,3 +1,4 @@ +--- haproxy_version: 2.8 # Global config section @@ -14,8 +15,8 @@ haproxy_global_vars: haproxy_default_vars: - log global - mode tcp - - option dontlognull - option tcplog + - option dontlognull # Frontends haproxy_frontends: diff --git a/handlers/main.yml b/handlers/main.yml index 47d58e8..80b96ad 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,5 +1,5 @@ --- - name: Reload HAProxy - service: + ansible.builtin.service: name: haproxy state: reloaded diff --git a/tasks/main.yml b/tasks/main.yml index d10c3d0..c9de326 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,40 +3,41 @@ ansible.builtin.apt: name: software-properties-common state: present - update_cache: yes + update_cache: true cache_valid_time: 3600 -- name: Check if PPA vbernat/haproxy-{{ haproxy_version }} is present - ansible.builtin.shell: add-apt-repository --list | grep vbernat/haproxy-{{ haproxy_version }} +- name: Check if PPA present - vbernat/haproxy-{{ haproxy_version }} + ansible.builtin.shell: | + set -o pipefail + add-apt-repository --list | grep vbernat/haproxy-{{ haproxy_version }} + args: + executable: /bin/bash failed_when: haproxy_repo_present.rc not in [0,1] changed_when: false register: haproxy_repo_present -- name: Print return information from the previous task - ansible.builtin.debug: - var: haproxy_repo_present -# - name: Add HAProxy {{ haproxy_version }} repository into sources list -# ansible.builtin.apt_repository: -# repo: "ppa:vbernat/haproxy-{{ haproxy_version }}" -# state: present -# update_cache: true +- name: Add PPA vbernat/haproxy-{{ haproxy_version }} + ansible.builtin.command: add-apt-repository ppa:vbernat/haproxy-{{ haproxy_version }} -y + changed_when: true + when: haproxy_repo_present.stdout == '' -# - name: Install HAProxy -# ansible.builtin.apt: -# name: "haproxy={{ haproxy_version }}.*" -# state: present +- name: Install HAProxy + ansible.builtin.apt: + name: "haproxy={{ haproxy_version }}.*" + state: present + update_cache: true -# - name: Copy HAProxy configuration -# ansible.builtin.template: -# src: haproxy.cfg.j2 -# dest: /etc/haproxy/haproxy.cfg -# mode: 0644 -# validate: haproxy -f %s -c -q -# force: true -# notify: Reload HAProxy +- name: Copy HAProxy configuration + ansible.builtin.template: + src: haproxy.cfg.j2 + dest: /etc/haproxy/haproxy.cfg + mode: "0644" + validate: haproxy -f %s -c -q + force: true + notify: Reload HAProxy -# - name: Ensure HAProxy is started and enabled at boot -# ansible.builtin.service: -# name: haproxy -# state: started -# enabled: true +- name: Ensure HAProxy is started and enabled at boot + ansible.builtin.service: + name: haproxy + state: started + enabled: true