From 64caa5554dedde87c7dcc850f79f27cc731f3dda Mon Sep 17 00:00:00 2001 From: Freezed <2160318-free_zed@users.noreply.gitlab.com> Date: Tue, 11 Jan 2022 00:17:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20APT=20&=20pakages=20managemen?= =?UTF-8?q?t=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 + tasks/apt.yml | 82 +++++++++++++++++++++++++++++++++++++++ tasks/become_user_cfg.yml | 1 - tasks/vars/Debian.yml | 9 +++++ tasks/vars/Gnome.yml | 5 +++ tasks/vars/Mate.yml | 5 +++ tasks/vars/Ubuntu.yml | 14 +++++++ tasks/vars/main.yml | 59 ++++++++++++++++++++++++++++ 8 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 tasks/apt.yml create mode 100644 tasks/vars/Debian.yml create mode 100644 tasks/vars/Gnome.yml create mode 100644 tasks/vars/Mate.yml create mode 100644 tasks/vars/Ubuntu.yml create mode 100644 tasks/vars/main.yml diff --git a/Makefile b/Makefile index f958078..3befe11 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ clean: open_all: ${EDITOR} .gitignore inventory Makefile README.md + ${EDITOR} tasks/files/* + ${EDITOR} tasks/vars/* ${EDITOR} tasks/*.yml inventory_generation: diff --git a/tasks/apt.yml b/tasks/apt.yml new file mode 100644 index 0000000..f456c96 --- /dev/null +++ b/tasks/apt.yml @@ -0,0 +1,82 @@ +--- +- hosts: "{{ host_list }}" + remote_user: root + + tasks: + + - name: INCLUDE_VARS | base + ansible.builtin.include_vars: "main.yml" + + - name: INCLUDE_VARS | OS + ansible.builtin.include_vars: "{{ ansible_distribution }}.yml" + + - name: INCLUDE_VARS | Gnome + when: "'gnome' in group_names" + ansible.builtin.include_vars: "Gnome.yml" + + - name: INCLUDE_VARS | Mate + when: "'mate' in group_names" + ansible.builtin.include_vars: "Mate.yml" + + - name: Remove snap packages + when: snap_uninstall_pkg is defined + community.general.snap: + name: "{{ snap_uninstall_pkg }}" + state: absent + + - name: APT | Install base packages + ansible.builtin.apt: + cache_valid_time: 3600 + force_apt_get: yes + pkg: "{{ lookup('flattened', base_pkg) }}" + state: present + update_cache: true + + - name: APT | Install OS packages + ansible.builtin.apt: + cache_valid_time: 3600 + force_apt_get: yes + pkg: "{{ lookup('flattened', os_pkg) }}" + state: present + update_cache: true + + - name: APT | Install workstation packages + when: inventory_hostname in groups.station + ansible.builtin.apt: + cache_valid_time: 3600 + force_apt_get: yes + pkg: "{{ lookup('flattened', station_pkg, station_os_pkg, station_wm_pkg) }}" + state: present + update_cache: true + + - name: APT | Uninstall packages + ansible.builtin.apt: + pkg: "{{ lookup('flattened', base_uninstall_pkg, os_uninstall_pkg) }}" + state: absent + + - name: APT | Upgrade all packages to the latest version + ansible.builtin.apt: + force_apt_get: yes + upgrade: safe + + - name: APT | Remove useless packages from the cache + ansible.builtin.apt: + force_apt_get: yes + autoclean: yes + autoremove: yes + + - name: APT | Check for restarts + ansible.builtin.stat: path={{ item }} + register: restart_required + loop: + - /var/run/firefox-restart-required + - /var/run/reboot-required + no_log: yes + + - name: APT | Restart message + ansible.builtin.debug: + msg: "{{ item.stat.path | basename }} on {{ ansible_hostname }}" + when: item.stat.exists + loop: "{{ restart_required.results }}" + loop_control: + label: "{{ item.item | basename }}" diff --git a/tasks/become_user_cfg.yml b/tasks/become_user_cfg.yml index ea041dc..53801a2 100644 --- a/tasks/become_user_cfg.yml +++ b/tasks/become_user_cfg.yml @@ -36,7 +36,6 @@ state: present user: "{{ my_user }}" - - name: SSH | Disallow SSHÂ password authentication for root become: yes copy: diff --git a/tasks/vars/Debian.yml b/tasks/vars/Debian.yml new file mode 100644 index 0000000..109b270 --- /dev/null +++ b/tasks/vars/Debian.yml @@ -0,0 +1,9 @@ +--- + +os_pkg: [] + +os_uninstall_pkg: [] + +station_os_pkg: + - chromium-l10n + - firefox-esr-l10n-fr diff --git a/tasks/vars/Gnome.yml b/tasks/vars/Gnome.yml new file mode 100644 index 0000000..3717a48 --- /dev/null +++ b/tasks/vars/Gnome.yml @@ -0,0 +1,5 @@ +--- + +station_wm_pkg: + - gnome-tweaks + - nautilus-nextcloud diff --git a/tasks/vars/Mate.yml b/tasks/vars/Mate.yml new file mode 100644 index 0000000..4fb645d --- /dev/null +++ b/tasks/vars/Mate.yml @@ -0,0 +1,5 @@ +--- + +station_wm_pkg: + - mate-tweak + - caja-nextcloud diff --git a/tasks/vars/Ubuntu.yml b/tasks/vars/Ubuntu.yml new file mode 100644 index 0000000..e2d262c --- /dev/null +++ b/tasks/vars/Ubuntu.yml @@ -0,0 +1,14 @@ +--- + +os_pkg: [] + +os_uninstall_pkg: + - thunderbird + +snap_uninstall_pkg: + - firefox + +station_os_pkg: + - chromium-browser-l10n + - firefox-locale-fr + - firefox diff --git a/tasks/vars/main.yml b/tasks/vars/main.yml new file mode 100644 index 0000000..41ff73f --- /dev/null +++ b/tasks/vars/main.yml @@ -0,0 +1,59 @@ +--- + +base_pkg: + - htop + - iotop + - locales + - lsb-release + - lsof + - lynx + - most + - progress + - python3-apt + - rsync + - screen + - sudo + - tmux + - unattended-upgrades + - unzip + - vim + - wget + - xkcdpass + +base_uninstall_pkg: [] + +station_pkg: + - ansible + - cheese + - easytag + - evolution + - evolution-plugins + - geany-plugin-addons + - geany-plugin-extrasel + - geany-plugin-git-changebar + - geany-plugin-markdown + - geany-plugin-prettyprinter + - geany-plugin-shiftcolumn + - geany-plugin-spellcheck + - geany-plugin-workbench + - geany-plugin-xmlsnippets + - git + - gnome-disk-utility + - gpsprune + - hplip + - jhead + - keepassx + - make + - meld + - mhwaveedit + - network-manager-gnome + - nextcloud-desktop + - pdftk + - photocollage + - sshpass + - tree + - simple-scan + - soundconverter + - system-config-printer + - torbrowser-launcher + - unrar-free -- GitLab