chore: ansible-lint

This commit is contained in:
Clément Désiles
2025-11-02 21:18:15 +01:00
parent 2c6da106b2
commit 2c421611ae
53 changed files with 390 additions and 350 deletions
+6 -6
View File
@@ -1,15 +1,15 @@
---
- name: Configure locales
block:
- name: activate locale
command:
- name: Activate locale
ansible.builtin.command:
cmd: localectl set-locale LANG={{ arch_locale }}
- name: edit /etc/locale.gen
lineinfile:
- name: Edit /etc/locale.gen
ansible.builtin.lineinfile:
dest: /etc/locale.gen
state: present
regexp: "{{ arch_locale }}"
line: "{{ arch_locale }} UTF-8"
- name: regenerate locales
command:
- name: Regenerate locales
ansible.builtin.command:
cmd: locale-gen
+2 -2
View File
@@ -1,10 +1,10 @@
---
- name: Skip Archlinux installation
meta: end_play
ansible.builtin.meta: end_play
when: ansible_facts['os_family'] != 'Archlinux'
- name: Archlinux base setup
include_tasks: "{{ item }}"
ansible.builtin.include_tasks: "{{ item }}"
loop:
- pacman.yml
- locales.yml
+7 -9
View File
@@ -1,6 +1,6 @@
---
- name: Check if pacman is not locked
stat:
ansible.builtin.stat:
path: /var/lib/pacman/db.lck
register: pacman_lock
failed_when: pacman_lock.stat.exists
@@ -13,32 +13,30 @@
# state: absent
- name: Install reflector (looking for fastest mirror)
pacman:
community.general.pacman:
name: reflector
state: present
- name: Stat pacman mirrorlist
stat:
ansible.builtin.stat:
path: /etc/pacman.d/mirrorlist
register: mirrorlist
# Probably not here if it's a fresh install
- name: Stat pacman mirrorlist.bak
stat:
ansible.builtin.stat:
path: /etc/pacman.d/mirrorlist.bak
register: mirrorlist_bak
- name: Backup and update pacman mirrorlist if older than 7 days
shell: >
ansible.builtin.shell: >
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak &&
reflector --latest 20 --protocol https --sort rate
--save /etc/pacman.d/mirrorlist
when: mirrorlist_bak.stat.exists is false or
(mirrorlist.stat.exists and
(ansible_date_time.epoch | int - mirrorlist.stat.mtime) > 604800)
when: mirrorlist_bak.stat.exists is false or (mirrorlist.stat.exists and (ansible_date_time.epoch | int - mirrorlist.stat.mtime) > 604800)
- name: Configure pacman to output colors
lineinfile:
ansible.builtin.lineinfile:
dest: /etc/pacman.conf
state: present
regexp: "^(.*)Color"
+62 -62
View File
@@ -1,10 +1,68 @@
---
- name: Check if paru is already installed
stat:
ansible.builtin.stat:
path: /usr/bin/paru
register: paru
- name: Install paru
when: not paru.stat.exists
##
## Deprecated version with compilation
##
# - name: Install paru
# block:
# - name: Install build dependencies
# package:
# name:
# - base-devel
# - git
# state: present
# - name: Disable sudo password prompt (makepkg sudoers hack)
# lineinfile:
# dest: /etc/sudoers
# state: present
# regexp: "^#?%wheel"
# line: "%wheel ALL=(ALL) NOPASSWD: ALL"
# validate: /usr/sbin/visudo -cf %s
# - command:
# cmd: whoami
# no_log: true
# become: false
# register: main_user
# - set_fact:
# main_user: "{{ main_user.stdout }}"
# no_log: true
# - name: Create paru sources dir
# file:
# path: "{{ paru_src_path }}"
# state: directory
# owner: "{{ main_user }}"
# - name: Clone git sources
# become: false
# git:
# repo: "{{ paru_git_repo }}"
# dest: "{{ paru_src_path }}"
# # note: this only works because SUDOERS password prompt is disabled
# - name: Build and install
# become: false
# command:
# chdir: "{{ paru_src_path }}"
# cmd: "makepkg -si -f --noconfirm"
# - name: Restore sudo with password prompt
# lineinfile:
# dest: /etc/sudoers
# state: present
# regexp: "^#?%wheel"
# line: "%wheel ALL=(ALL:ALL) ALL"
# validate: /usr/sbin/visudo -cf %s
# when: not paru.stat.exists
block:
- name: Get the last github release
ansible.builtin.uri:
@@ -13,14 +71,14 @@
register: paru_release
- name: Extract tag_name
set_fact:
ansible.builtin.set_fact:
paru_version: "{{ (paru_release.json.tag_name | regex_replace('^v', '')) }}"
- name: Get the binary URL ({{ os_arch }})
set_fact:
ansible.builtin.set_fact:
paru_url: "{{ item.browser_download_url }}"
loop: "{{ paru_release.json.assets }}"
when: "'{{ os_arch }}.tar.zst' in item.name"
when: "'os_arch.tar.zst' in item.name"
- name: Download
ansible.builtin.get_url:
@@ -45,61 +103,3 @@
ansible.builtin.file:
path: "/tmp/paru-{{ os_arch }}.tar.zst"
state: absent
when: not paru.stat.exists
##
## Deprecated version with compilation
##
# - name: Install paru
# block:
# - name: Install build dependencies
# package:
# name:
# - base-devel
# - git
# state: present
# - name: Disable sudo password prompt (makepkg sudoers hack)
# lineinfile:
# dest: /etc/sudoers
# state: present
# regexp: "^#?%wheel"
# line: "%wheel ALL=(ALL) NOPASSWD: ALL"
# validate: /usr/sbin/visudo -cf %s
# - command:
# cmd: whoami
# no_log: true
# become: false
# register: main_user
# - set_fact:
# main_user: "{{ main_user.stdout }}"
# no_log: true
# - name: Create paru sources dir
# file:
# path: "{{ paru_src_path }}"
# state: directory
# owner: "{{ main_user }}"
# - name: Clone git sources
# become: false
# git:
# repo: "{{ paru_git_repo }}"
# dest: "{{ paru_src_path }}"
# # note: this only works because SUDOERS password prompt is disabled
# - name: Build and install
# become: false
# command:
# chdir: "{{ paru_src_path }}"
# cmd: "makepkg -si -f --noconfirm"
# - name: Restore sudo with password prompt
# lineinfile:
# dest: /etc/sudoers
# state: present
# regexp: "^#?%wheel"
# line: "%wheel ALL=(ALL:ALL) ALL"
# validate: /usr/sbin/visudo -cf %s
# when: not paru.stat.exists
+10 -10
View File
@@ -1,60 +1,60 @@
---
- name: Check if yay is already installed
stat:
ansible.builtin.stat:
path: /usr/bin/yay
register: yay
- name: Install yay
when: not yay.stat.exists
block:
- name: Install build dependencies
package:
ansible.builtin.package:
name:
- base-devel
- git
state: present
- name: Disable sudo password prompt (makepkg sudoers hack)
lineinfile:
ansible.builtin.lineinfile:
dest: /etc/sudoers
state: present
regexp: "^#?%wheel"
line: "%wheel ALL=(ALL) NOPASSWD: ALL"
validate: /usr/sbin/visudo -cf %s
- command:
- ansible.builtin.command:
cmd: whoami
no_log: true
become: false
register: main_user
- set_fact:
- ansible.builtin.set_fact:
main_user: "{{ main_user.stdout }}"
no_log: true
- name: Create yay sources dir
file:
ansible.builtin.file:
path: "{{ yay_src_path }}"
state: directory
owner: "{{ main_user }}"
- name: Clone git sources
become: false
git:
ansible.builtin.git:
repo: "{{ yay_git_repo }}"
dest: "{{ yay_src_path }}"
# note: this only works because SUDOERS password prompt is disabled
- name: Build and install
become: false
command:
ansible.builtin.command:
chdir: "{{ yay_src_path }}"
cmd: "makepkg -si -f --noconfirm"
- name: Restore sudo with password prompt
lineinfile:
ansible.builtin.lineinfile:
dest: /etc/sudoers
state: present
regexp: "^#?%wheel"
line: "%wheel ALL=(ALL:ALL) ALL"
validate: /usr/sbin/visudo -cf %s
when: not yay.stat.exists