Fixed playbooks according to ansible linting

This commit is contained in:
Michele Cereda
2023-01-29 18:19:23 +01:00
parent 03d4278851
commit 1fed953c96
7 changed files with 22 additions and 18 deletions

View File

@@ -22,7 +22,8 @@
name: bluetooth.service name: bluetooth.service
state: restarted state: restarted
tasks: tasks:
- when: ansible_system == 'Linux' - name: Configure Bluetooth on Linux systems
when: ansible_system == 'Linux'
tags: linux tags: linux
block: block:
- name: Configure how long to stay in discoverable mode before going back to non-discoverable - name: Configure how long to stay in discoverable mode before going back to non-discoverable
@@ -32,7 +33,7 @@
notify: Restart Bluez notify: Restart Bluez
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "/etc/bluetooth/main.conf" path: "/etc/bluetooth/main.conf"
line: "DiscoverableTimeout = {{ discoverable_timeout|string|lower }}" line: "DiscoverableTimeout = {{ discoverable_timeout | string | lower }}"
regexp: '^.*DiscoverableTimeout\s*=\s*.*$' regexp: '^.*DiscoverableTimeout\s*=\s*.*$'
insertafter: '^[General]$' insertafter: '^[General]$'
mode: '0644' mode: '0644'
@@ -45,7 +46,7 @@
notify: Restart Bluez notify: Restart Bluez
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "/etc/bluetooth/main.conf" path: "/etc/bluetooth/main.conf"
line: "FastConnectable = {{ fast_connectable|string|lower }}" line: "FastConnectable = {{ fast_connectable | string | lower }}"
regexp: '^.*FastConnectable\s*=\s*.*$' regexp: '^.*FastConnectable\s*=\s*.*$'
insertafter: '^[General]$' insertafter: '^[General]$'
mode: '0644' mode: '0644'
@@ -58,7 +59,7 @@
notify: Restart Bluez notify: Restart Bluez
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "/etc/bluetooth/main.conf" path: "/etc/bluetooth/main.conf"
line: "Name = {{ name|string|lower }}" line: "Name = {{ name | string | lower }}"
regexp: '^.*Name\s*=\s*.*$' regexp: '^.*Name\s*=\s*.*$'
insertafter: '^[General]$' insertafter: '^[General]$'
mode: '0644' mode: '0644'
@@ -71,7 +72,7 @@
notify: Restart Bluez notify: Restart Bluez
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "/etc/bluetooth/main.conf" path: "/etc/bluetooth/main.conf"
line: "AutoEnable = {{ auto_enable|string|lower }}" line: "AutoEnable = {{ auto_enable | string | lower }}"
regexp: '^.*AutoEnable\s*=\s*.*$' regexp: '^.*AutoEnable\s*=\s*.*$'
insertafter: '^[Policy]$' insertafter: '^[Policy]$'
mode: '0644' mode: '0644'

View File

@@ -16,7 +16,8 @@
flathub_url: https://flathub.org/repo/flathub.flatpakrepo flathub_url: https://flathub.org/repo/flathub.flatpakrepo
remotes: [] remotes: []
tasks: tasks:
- when: ansible_system == 'Linux' - name: Install and configure Flatpak on Linux systems
when: ansible_system == 'Linux'
tags: linux tags: linux
block: block:
- name: Install flatpak - name: Install flatpak
@@ -34,8 +35,8 @@
block: block:
- name: Add flathub to the list of remotes of this run - name: Add flathub to the list of remotes of this run
when: flathub_enabled when: flathub_enabled
set_fact: ansible.builtin.set_fact:
remotes: "{{ remotes + [ { 'name': flathub_name, 'method': flathub_method, 'url': flathub_url } ] }}" remotes: "{{ remotes + [{'name': flathub_name, 'method': flathub_method, 'url': flathub_url}] }}"
- name: Enable system remotes - name: Enable system remotes
tags: tags:
- remote - remote

View File

@@ -24,14 +24,14 @@
installonly_limit: 2 installonly_limit: 2
gpgcheck: true gpgcheck: true
tasks: tasks:
- name: "Configure {{ ansible_pkg_mgr|upper }}" - name: "Configure {{ ansible_pkg_mgr | upper }}"
when: ansible_pkg_mgr in ['dnf', 'yum'] when: ansible_pkg_mgr in ['dnf', 'yum']
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "/etc/{{ ansible_pkg_mgr }}/{{ ansible_pkg_mgr }}.conf" path: "/etc/{{ ansible_pkg_mgr }}/{{ ansible_pkg_mgr }}.conf"
line: "{{ item.key }}={{ item.value|string }}" line: "{{ item.key }}={{ item.value | string }}"
regexp: '^.*{{ item.key }}\s*=\s*.*$' regexp: '^.*{{ item.key }}\s*=\s*.*$'
insertafter: '^[main]$' insertafter: '^[main]$'
mode: '0644' mode: '0644'
backup: true backup: true
loop: "{{ lookup('vars', [ansible_pkg_mgr, 'config']|join('_') ) | dict2items }}" loop: "{{ lookup('vars', [ansible_pkg_mgr, 'config'] | join('_')) | dict2items }}"

View File

@@ -12,7 +12,8 @@
- snapd - snapd
hosts: all hosts: all
tasks: tasks:
- when: ansible_system == 'Linux' - name: Install and configure Snap on Linux systems
when: ansible_system == 'Linux'
tags: linux tags: linux
block: block:
- name: Install snapd - name: Install snapd

View File

@@ -13,13 +13,14 @@
swappiness_sysctl_file_priority: 99 swappiness_sysctl_file_priority: 99
swappiness_value: 10 swappiness_value: 10
tasks: tasks:
- when: ansible_system == 'Linux' - name: Configure swappiness on Linux systems
when: ansible_system == 'Linux'
tags: linux tags: linux
block: block:
- name: Configure swappiness - name: Configure swappiness
become: true become: true
sysctl: ansible.builtin.sysctl:
name: vm.swappiness name: vm.swappiness
value: "{{ swappiness_value|string }}" value: "{{ swappiness_value | string }}"
sysctl_file: "{{ swappiness_sysctl_file }}" sysctl_file: "{{ swappiness_sysctl_file }}"
sysctl_set: true sysctl_set: true

View File

@@ -10,7 +10,7 @@
tasks: tasks:
- name: Pre-flight checks - name: Pre-flight checks
when: ansible_system != 'Darwin' when: ansible_system != 'Darwin'
fail: ansible.builtin.fail:
msg: "Unsupported OS '{{ ansible_system }}'" msg: "Unsupported OS '{{ ansible_system }}'"
- name: Check Command Line Tools are already installed - name: Check Command Line Tools are already installed
check_mode: false check_mode: false

View File

@@ -1,6 +1,6 @@
--- ---
- name: - name: Add Packman to Zypper's repositories list
tags: tags:
- opensuse - opensuse
- packman - packman
@@ -12,7 +12,7 @@
ansible_distribution_with_underscores: "{{ ansible_distribution | replace(' ', '_') }}" ansible_distribution_with_underscores: "{{ ansible_distribution | replace(' ', '_') }}"
repo_part_distribution: >- repo_part_distribution: >-
{{ {{
[ansible_distribution_with_underscores, ansible_distribution_version]|join('_') [ansible_distribution_with_underscores, ansible_distribution_version] | join('_')
if ansible_distribution is search('leap', ignorecase=true) if ansible_distribution is search('leap', ignorecase=true)
else ansible_distribution_with_underscores else ansible_distribution_with_underscores
}} }}