automatrop: Run ansible-lint --fix

This commit is contained in:
Geoffrey Frogeye 2023-11-02 19:51:54 +01:00
parent d60f5aaa9d
commit 9c3dcba2e5
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
18 changed files with 342 additions and 333 deletions

View file

@ -1,43 +1,43 @@
---
# TODO Install python if not done
# Or maybe not, it requires a lot of automation for something that can be done
# very quickly manually and is usually already installed
- name: Install python-apt dependency for Termux
when: termux
vars:
version: 2.39
block:
# TODO Check if the correct version
- name: Check for DistUtilsExtra (Termux)
command: python -c 'import DistUtilsExtra'
changed_when: False
ansible.builtin.command: python -c 'import DistUtilsExtra'
changed_when: false
rescue:
- name: Create temporarty folder for DistUtilsExtra (Termux)
tempfile:
ansible.builtin.tempfile:
state: directory
suffix: python-distutils-extra
# path: /data/data/com.termux/files/usr/tmp/
register: pde_tempdir
- name: Download DistUtilsExtra (Termux)
get_url:
url: "https://launchpad.net/python-distutils-extra/trunk/{{ version }}/+download/python-distutils-extra-{{ version }}.tar.gz"
ansible.builtin.get_url:
url: https://launchpad.net/python-distutils-extra/trunk/{{ version }}/+download/python-distutils-extra-{{ version }}.tar.gz
dest: "{{ pde_tempdir.path }}/python-distutils-extra.tar.gz"
- name: Extract DistUtilsExtra (Termux)
unarchive:
ansible.builtin.unarchive:
src: "{{ pde_tempdir.path }}/python-distutils-extra.tar.gz"
remote_src: yes
remote_src: true
dest: "{{ pde_tempdir.path }}"
- name: Install DistUtilsExtra (Termux)
command:
ansible.builtin.command:
cmd: python3 setup.py install
chdir: "{{ pde_tempdir.path }}/python-distutils-extra-{{ version }}"
when: termux
vars:
version: 2.39
- name: Install python-apt (Termux)
pip:
ansible.builtin.pip:
name: python-apt
when: termux
@ -62,112 +62,110 @@
# TODO Patch sudo-fake so it allows using -u so `become` works
- name: Enable multilib repo
lineinfile:
ansible.builtin.lineinfile:
path: /etc/pacman.conf
regexp: '^#?\s*\[multilib\]$'
line: '[multilib]'
become: yes
regexp: ^#?\s*\[multilib\]$
line: "[multilib]"
become: true
when: arch_based and ansible_architecture == "x86_64"
notify: udpate pacman cache
- name: Configure multilib repo
lineinfile:
ansible.builtin.lineinfile:
path: /etc/pacman.conf
regexp: '^#?\s*Include\s*=\s*/etc/pacman.d/mirrorlist'
line: 'Include = /etc/pacman.d/mirrorlist'
insertafter: '^\[multilib\]$'
become: yes
regexp: ^#?\s*Include\s*=\s*/etc/pacman.d/mirrorlist
line: Include = /etc/pacman.d/mirrorlist
insertafter: ^\[multilib\]$
become: true
when: arch_based and ansible_architecture == "x86_64"
notify: udpate pacman cache
- name: Update cache if needed
meta: flush_handlers
ansible.builtin.meta: flush_handlers
- name: Install ccache
pacman:
community.general.pacman:
name: ccache
state: present
extra_args: "--asdeps"
become: yes
extra_args: --asdeps
become: true
when: arch_based
- name: Enable makepkg color
replace:
ansible.builtin.replace:
path: /etc/makepkg.conf
regexp: '^BUILDENV=(.+)!color(.+)$'
replace: 'BUILDENV=\1color\2'
become: yes
regexp: ^BUILDENV=(.+)!color(.+)$
replace: BUILDENV=\1color\2
become: true
when: arch_based
- name: Enable makepkg ccache
replace:
ansible.builtin.replace:
path: /etc/makepkg.conf
regexp: '^BUILDENV=(.+)!ccache(.+)$'
replace: 'BUILDENV=\1ccache\2'
become: yes
regexp: ^BUILDENV=(.+)!ccache(.+)$
replace: BUILDENV=\1ccache\2
become: true
when: arch_based
- name: Remove -mtune from makepkg CFLAGS
replace:
ansible.builtin.replace:
path: /etc/makepkg.conf
regexp: '^#? *CFLAGS=(.+)-mtune=\S+\s(.*)$'
replace: "CFLAGS=\\1\\2"
become: yes
regexp: ^#? *CFLAGS=(.+)-mtune=\S+\s(.*)$
replace: CFLAGS=\1\2
become: true
when: arch_based
- name: Change -march to native from makepkg CFLAGS
replace:
ansible.builtin.replace:
path: /etc/makepkg.conf
regexp: '^#? *CFLAGS=(.+)-march=\S+(\s)(.*)$'
replace: "CFLAGS=\\1-march=native\\2\\3"
become: yes
regexp: ^#? *CFLAGS=(.+)-march=\S+(\s)(.*)$
replace: CFLAGS=\1-march=native\2\3
become: true
when: arch_based
- name: Set makepkg MAKEFLAGS
replace:
ansible.builtin.replace:
path: /etc/makepkg.conf
regexp: '^#? *MAKEFLAGS=(.+)-j[0-9]+(.+)$'
replace: "MAKEFLAGS=\\1-j{{ j }}\\2"
become: yes
regexp: ^#? *MAKEFLAGS=(.+)-j[0-9]+(.+)$
replace: MAKEFLAGS=\1-j{{ j }}\2
become: true
vars:
j: "{{ [ansible_processor_nproc - 1, 1] | max | int }}"
when: arch_based
- name: Enable pacman ParallelDownloads
lineinfile:
ansible.builtin.lineinfile:
path: /etc/pacman.conf
regexp: '^#?ParallelDownloads'
line: 'ParallelDownloads = 5'
insertafter: '^\[options\]$'
become: yes
regexp: ^#?ParallelDownloads
line: ParallelDownloads = 5
insertafter: ^\[options\]$
become: true
when: arch_based
- name: Enable pacman colors
lineinfile:
ansible.builtin.lineinfile:
path: /etc/pacman.conf
regexp: '^#?Color'
line: 'Color'
insertafter: '^\[options\]$'
become: yes
regexp: ^#?Color
line: Color
insertafter: ^\[options\]$
become: true
when: arch_based
- name: Enable pacman pac-man
lineinfile:
ansible.builtin.lineinfile:
path: /etc/pacman.conf
regexp: '^#?ILoveCandy'
line: 'ILoveCandy'
insertafter: '^#?Color'
become: yes
regexp: ^#?ILoveCandy
line: ILoveCandy
insertafter: ^#?Color
become: true
when: arch_based
# Install alternative package managers
- name: Install dependencies for AUR helpers
pacman:
community.general.pacman:
name:
- base-devel
- fakeroot
become: yes
become: true
when: arch_based
# Do not install sudo because maybe sudo-fake is installed (otherwise it conflicts)
# It should already be installed already anyway
@ -178,41 +176,41 @@
when: arch
- name: Install AUR package manager (Manjaro)
pacman:
community.general.pacman:
name: yay
become: yes
become: true
when: manjaro
# Not sure if regular Manjaro has yay in its community packages,
# but Manjaro-ARM sure does
- name: Create cache folder
file:
ansible.builtin.file:
state: directory
mode: "u=rwx,g=rx,o=rx"
mode: u=rwx,g=rx,o=rx
path: "{{ ansible_user_dir }}/.cache/automatrop"
- name: Generate list of packages for package manager
set_fact:
ansible.builtin.set_fact:
packages: "{{ query('template', 'package_manager.j2')[0].split('\n')[:-1]|sort|unique }}"
tags: softwarelist
- name: Install packages (Arch-based)
aur:
name: "{{ packages }}"
extra_args: "--asdeps --needed"
extra_args: --asdeps --needed
# Nothing is set as installed manually so it can
# be removed by dependency check.
# Current packages will be kept by the meta package
use: yay
notify: "software changed"
notify: software changed
tags: softwarelist
when: arch_based
- name: Check if list of packages changed
copy:
ansible.builtin.copy:
content: "{% for package in packages %}{{ package }}\n{% endfor %}"
dest: "{{ ansible_user_dir }}/.cache/automatrop/package_manager"
notify: "software changed"
notify: software changed
tags: softwarelist
# translate-shell