rolle: apt_install_packages umgebaut + Pakete entfernen eingebaut (#237)

Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#237
Co-authored-by: mg <michael.grote@posteo.de>
Co-committed-by: mg <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2021-11-05 21:10:27 +01:00
parent d5ecd4f2d1
commit 10bc3a7f98
14 changed files with 47 additions and 38 deletions

View file

@ -174,8 +174,8 @@
- production - production
- test - test
- laptop - laptop
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_common: apt_packages_common:
- locales - locales
- python3 - python3
- build-essential - build-essential
@ -203,16 +203,18 @@
- rsync - rsync
- at - at
- ripgrep - ripgrep
programs_only_physical: apt_packages_physical:
- hddtemp - hddtemp
- ipmitool - ipmitool
- s-tui - s-tui
- smartmontools - smartmontools
- lm-sensors - lm-sensors
- ethtool - ethtool
programs_only_vms: apt_packages_vm:
- qemu-guest-agent - qemu-guest-agent
- open-vm-tools - open-vm-tools
apt_packages_absent:
- nano

View file

@ -12,6 +12,6 @@
ansible_install_version_pip: '2.10' ansible_install_version_pip: '2.10'
### mgrote.restic ### mgrote.restic
restic_folders_to_backup: "/usr/local /etc /root /home" restic_folders_to_backup: "/usr/local /etc /root /home"
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- sshpass - sshpass

View file

@ -35,7 +35,7 @@
### geerlingguy.ansible ### geerlingguy.ansible
ansible_install_method: pip ansible_install_method: pip
ansible_install_version_pip: '2.10' ansible_install_version_pip: '2.10'
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- graphviz # für ansible-playbook-grapher - graphviz # für ansible-playbook-grapher
- sshpass - sshpass

View file

@ -31,8 +31,8 @@
- path: /home/mg/.config/flameshot - path: /home/mg/.config/flameshot
dotfiles_owner: mg dotfiles_owner: mg
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- bmon - bmon
- hddtemp - hddtemp
- s-tui - s-tui

View file

@ -1,6 +1,6 @@
--- ---
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- ifupdown2 - ifupdown2
- bmon - bmon
### mgrote.smart ### mgrote.smart

View file

@ -1,5 +1,5 @@
--- ---
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- qemu-guest-agent - qemu-guest-agent
- open-vm-tools - open-vm-tools

View file

@ -80,8 +80,8 @@
tmux_conf_destination: "/home/mg/.tmux.conf" tmux_conf_destination: "/home/mg/.tmux.conf"
tmux_bashrc_destination: "/home/mg/.bashrc" tmux_bashrc_destination: "/home/mg/.bashrc"
tmux_standardsession_name: "default" tmux_standardsession_name: "default"
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- python3-stem # für munin-tor_ - python3-stem # für munin-tor_
- geoip-bin # für munin-tor_ - geoip-bin # für munin-tor_
- geoip-database # für munin-tor_ - geoip-database # für munin-tor_

View file

@ -41,8 +41,8 @@
protocol: tcp protocol: tcp
comment: 'munin' comment: 'munin'
from_ip: 0.0.0.0/0 from_ip: 0.0.0.0/0
### mgrote.apt_install_packages ### mgrote.apt_manage_packages
programs_extra: apt_packages_extra:
- libwww-curl-perl # für munin-plugin: unifi - libwww-curl-perl # für munin-plugin: unifi
- libjson-perl # für munin-plugin: unifi - libjson-perl # für munin-plugin: unifi
### mgrote.munin-node ### mgrote.munin-node

View file

@ -1,6 +1,6 @@
--- ---
- import_playbook: base/apt_sources.yml - 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/ntp_client.yml
- import_playbook: base/restic.yml - import_playbook: base/restic.yml
- import_playbook: base/users.yml - import_playbook: base/users.yml

View file

@ -1,5 +0,0 @@
---
- hosts: all
serial: 3
roles:
- { role: mgrote.apt_install_packages, tags: "install"}

View file

@ -0,0 +1,5 @@
---
- hosts: all
serial: 3
roles:
- { role: mgrote.apt_manage_packages, tags: "install"}

View file

@ -1,20 +1,20 @@
## mgrote.apt_install_packages ## mgrote.apt_manage_packages
### Beschreibung ### Beschreibung
Fuehrt: Fuehrt:
`apt install {{ programme }}` `apt install {{ programme }}`
aus. aus.
```yaml ```yaml
programs_common: apt_packages_common:
- locales - locales
- wird überall installiert - wird überall installiert
programs_only_physical: apt_packages_physical:
- hddtemp - hddtemp
- nur auf Hardware-Maschinen - nur auf Hardware-Maschinen
programs_only_vms: apt_packages_vm:
- qemu-guest-agent - qemu-guest-agent
- nur in VMs - nur in VMs
programs_extra: apt_packages_extra:
- Extra-Parameter für einzelne Hosts - Extra-Parameter für einzelne Hosts
``` ```
Es wird unterschieden ob das Ziel eine VM ist oder nicht. Es wird unterschieden ob das Ziel eine VM ist oder nicht.

View file

@ -1,5 +1,5 @@
--- ---
programs_common: apt_packages_common:
- locales - locales
- build-essential - build-essential
- ntp - ntp
@ -22,12 +22,13 @@
- acl - acl
- python3 - python3
- vim - vim
programs_only_physical: apt_packages_physical:
- hddtemp - hddtemp
- ipmitool - ipmitool
- powertop - powertop
- s-tui - s-tui
programs_only_vms: apt_packages_vm:
- qemu-guest-agent - qemu-guest-agent
- open-vm-tools - open-vm-tools
programs_extra: apt_packages_extra:
apt_packages_absent:

View file

@ -2,26 +2,32 @@
- name: install common-packages - name: install common-packages
become: yes become: yes
ansible.builtin.package: ansible.builtin.package:
name: "{{ programs_common }}" name: "{{ apt_packages_common }}"
state: present state: present
- name: install extra-packages - name: install extra-packages
become: yes become: yes
ansible.builtin.package: ansible.builtin.package:
name: "{{ programs_extra }}" name: "{{ apt_packages_extra }}"
state: present state: present
when: programs_extra is defined when: apt_packages_extra is defined
- name: install vm-packages - name: install vm-packages
become: yes become: yes
ansible.builtin.package: ansible.builtin.package:
name: "{{ programs_only_vms }}" name: "{{ apt_packages_vm }}"
state: present state: present
when: ansible_virtualization_role == 'guest' when: ansible_virtualization_role == 'guest'
- name: install physical-packages - name: install physical-packages
become: yes become: yes
ansible.builtin.package: ansible.builtin.package:
name: "{{ programs_only_physical }}" name: "{{ apt_packages_physical }}"
state: present state: present
when: ansible_virtualization_role != 'guest' when: ansible_virtualization_role != 'guest'
- name: remove packages
become: yes
ansible.builtin.package:
name: "{{ apt_packages_absent }}"
state: absent