From 10bc3a7f982adf710a4fd36cf53d05041a8de68a Mon Sep 17 00:00:00 2001 From: mg Date: Fri, 5 Nov 2021 21:10:27 +0100 Subject: [PATCH] rolle: apt_install_packages umgebaut + Pakete entfernen eingebaut (#237) Co-authored-by: Michael Grote Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/237 Co-authored-by: mg Co-committed-by: mg --- group_vars/all.yml | 10 ++++++---- group_vars/ansible.yml | 4 ++-- group_vars/jenkins.yml | 4 ++-- group_vars/laptop.yml | 4 ++-- group_vars/proxmox.yml | 4 ++-- group_vars/proxmoxtest.yml | 4 ++-- group_vars/tor.yml | 4 ++-- host_vars/docker2.grote.lan.yml | 4 ++-- playbooks/2_all.yml | 2 +- playbooks/base/install_packages.yml | 5 ----- playbooks/base/packages.yml | 5 +++++ .../README.md | 10 +++++----- .../defaults/main.yml | 9 +++++---- .../tasks/main.yml | 16 +++++++++++----- 14 files changed, 47 insertions(+), 38 deletions(-) delete mode 100644 playbooks/base/install_packages.yml create mode 100644 playbooks/base/packages.yml rename roles/{mgrote.apt_install_packages => mgrote.apt_manage_packages}/README.md (78%) rename roles/{mgrote.apt_install_packages => mgrote.apt_manage_packages}/defaults/main.yml (78%) rename roles/{mgrote.apt_install_packages => mgrote.apt_manage_packages}/tasks/main.yml (60%) diff --git a/group_vars/all.yml b/group_vars/all.yml index 063ab97b..c66ac267 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -174,8 +174,8 @@ - production - test - laptop - ### mgrote.apt_install_packages - programs_common: + ### mgrote.apt_manage_packages + apt_packages_common: - locales - python3 - build-essential @@ -203,16 +203,18 @@ - rsync - at - ripgrep - programs_only_physical: + apt_packages_physical: - hddtemp - ipmitool - s-tui - smartmontools - lm-sensors - ethtool - programs_only_vms: + apt_packages_vm: - qemu-guest-agent - open-vm-tools + apt_packages_absent: + - nano diff --git a/group_vars/ansible.yml b/group_vars/ansible.yml index cb49dcc2..f1ff0834 100644 --- a/group_vars/ansible.yml +++ b/group_vars/ansible.yml @@ -12,6 +12,6 @@ ansible_install_version_pip: '2.10' ### mgrote.restic restic_folders_to_backup: "/usr/local /etc /root /home" - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - sshpass diff --git a/group_vars/jenkins.yml b/group_vars/jenkins.yml index 8386be5c..af90c74d 100644 --- a/group_vars/jenkins.yml +++ b/group_vars/jenkins.yml @@ -35,7 +35,7 @@ ### geerlingguy.ansible ansible_install_method: pip ansible_install_version_pip: '2.10' - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - graphviz # für ansible-playbook-grapher - sshpass diff --git a/group_vars/laptop.yml b/group_vars/laptop.yml index 1b2f8400..051dbfe6 100644 --- a/group_vars/laptop.yml +++ b/group_vars/laptop.yml @@ -31,8 +31,8 @@ - path: /home/mg/.config/flameshot dotfiles_owner: mg - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - bmon - hddtemp - s-tui diff --git a/group_vars/proxmox.yml b/group_vars/proxmox.yml index 517de424..43d9de46 100644 --- a/group_vars/proxmox.yml +++ b/group_vars/proxmox.yml @@ -1,6 +1,6 @@ --- - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - ifupdown2 - bmon ### mgrote.smart diff --git a/group_vars/proxmoxtest.yml b/group_vars/proxmoxtest.yml index 2509140c..eac00335 100644 --- a/group_vars/proxmoxtest.yml +++ b/group_vars/proxmoxtest.yml @@ -1,5 +1,5 @@ --- - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - qemu-guest-agent - open-vm-tools diff --git a/group_vars/tor.yml b/group_vars/tor.yml index c7bfc9a1..82309af8 100644 --- a/group_vars/tor.yml +++ b/group_vars/tor.yml @@ -80,8 +80,8 @@ tmux_conf_destination: "/home/mg/.tmux.conf" tmux_bashrc_destination: "/home/mg/.bashrc" tmux_standardsession_name: "default" - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - python3-stem # für munin-tor_ - geoip-bin # für munin-tor_ - geoip-database # für munin-tor_ diff --git a/host_vars/docker2.grote.lan.yml b/host_vars/docker2.grote.lan.yml index ef2de946..8e8817c0 100644 --- a/host_vars/docker2.grote.lan.yml +++ b/host_vars/docker2.grote.lan.yml @@ -41,8 +41,8 @@ protocol: tcp comment: 'munin' from_ip: 0.0.0.0/0 - ### mgrote.apt_install_packages - programs_extra: + ### mgrote.apt_manage_packages + apt_packages_extra: - libwww-curl-perl # für munin-plugin: unifi - libjson-perl # für munin-plugin: unifi ### mgrote.munin-node diff --git a/playbooks/2_all.yml b/playbooks/2_all.yml index f9312865..51581be8 100644 --- a/playbooks/2_all.yml +++ b/playbooks/2_all.yml @@ -1,6 +1,6 @@ --- - import_playbook: base/apt_sources.yml - - import_playbook: base/install_packages.yml + - import_playbook: base/packages.yml - import_playbook: base/ntp_client.yml - import_playbook: base/restic.yml - import_playbook: base/users.yml diff --git a/playbooks/base/install_packages.yml b/playbooks/base/install_packages.yml deleted file mode 100644 index bb7ce171..00000000 --- a/playbooks/base/install_packages.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - - hosts: all - serial: 3 - roles: - - { role: mgrote.apt_install_packages, tags: "install"} diff --git a/playbooks/base/packages.yml b/playbooks/base/packages.yml new file mode 100644 index 00000000..6d237bd5 --- /dev/null +++ b/playbooks/base/packages.yml @@ -0,0 +1,5 @@ +--- + - hosts: all + serial: 3 + roles: + - { role: mgrote.apt_manage_packages, tags: "install"} diff --git a/roles/mgrote.apt_install_packages/README.md b/roles/mgrote.apt_manage_packages/README.md similarity index 78% rename from roles/mgrote.apt_install_packages/README.md rename to roles/mgrote.apt_manage_packages/README.md index 847a6b2c..b0c7a234 100644 --- a/roles/mgrote.apt_install_packages/README.md +++ b/roles/mgrote.apt_manage_packages/README.md @@ -1,20 +1,20 @@ -## mgrote.apt_install_packages +## mgrote.apt_manage_packages ### Beschreibung Fuehrt: `apt install {{ programme }}` aus. ```yaml - programs_common: + apt_packages_common: - locales - wird überall installiert - programs_only_physical: + apt_packages_physical: - hddtemp - nur auf Hardware-Maschinen - programs_only_vms: + apt_packages_vm: - qemu-guest-agent - nur in VMs - programs_extra: + apt_packages_extra: - Extra-Parameter für einzelne Hosts ``` Es wird unterschieden ob das Ziel eine VM ist oder nicht. diff --git a/roles/mgrote.apt_install_packages/defaults/main.yml b/roles/mgrote.apt_manage_packages/defaults/main.yml similarity index 78% rename from roles/mgrote.apt_install_packages/defaults/main.yml rename to roles/mgrote.apt_manage_packages/defaults/main.yml index dd6ade78..4f223b2c 100644 --- a/roles/mgrote.apt_install_packages/defaults/main.yml +++ b/roles/mgrote.apt_manage_packages/defaults/main.yml @@ -1,5 +1,5 @@ --- - programs_common: + apt_packages_common: - locales - build-essential - ntp @@ -22,12 +22,13 @@ - acl - python3 - vim - programs_only_physical: + apt_packages_physical: - hddtemp - ipmitool - powertop - s-tui - programs_only_vms: + apt_packages_vm: - qemu-guest-agent - open-vm-tools - programs_extra: + apt_packages_extra: + apt_packages_absent: diff --git a/roles/mgrote.apt_install_packages/tasks/main.yml b/roles/mgrote.apt_manage_packages/tasks/main.yml similarity index 60% rename from roles/mgrote.apt_install_packages/tasks/main.yml rename to roles/mgrote.apt_manage_packages/tasks/main.yml index a8bd405c..a69d91a3 100644 --- a/roles/mgrote.apt_install_packages/tasks/main.yml +++ b/roles/mgrote.apt_manage_packages/tasks/main.yml @@ -2,26 +2,32 @@ - name: install common-packages become: yes ansible.builtin.package: - name: "{{ programs_common }}" + name: "{{ apt_packages_common }}" state: present - name: install extra-packages become: yes ansible.builtin.package: - name: "{{ programs_extra }}" + name: "{{ apt_packages_extra }}" state: present - when: programs_extra is defined + when: apt_packages_extra is defined - name: install vm-packages become: yes ansible.builtin.package: - name: "{{ programs_only_vms }}" + name: "{{ apt_packages_vm }}" state: present when: ansible_virtualization_role == 'guest' - name: install physical-packages become: yes ansible.builtin.package: - name: "{{ programs_only_physical }}" + name: "{{ apt_packages_physical }}" state: present when: ansible_virtualization_role != 'guest' + + - name: remove packages + become: yes + ansible.builtin.package: + name: "{{ apt_packages_absent }}" + state: absent