diff --git a/group_vars/all.yml b/group_vars/all.yml index 5fab21a0..783f26cc 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -68,8 +68,7 @@ postfix_smtp_server_port: 587 postfix_smtp_use_tls: "yes" ### mgrote.apt_manage_sources - manage_sources_apt_proxy_server: acng.grote.lan - manage_sources_apt_proxy_port: 9999 + manage_sources_apt_proxy: "acng.grote.lan:9999" ### mgrote.restic restic_folders_to_backup: "/usr/local /etc /root /home" restic_cron_hours: "19" diff --git a/group_vars/laptop.yml b/group_vars/laptop.yml index ef1b1584..1b2f8400 100644 --- a/group_vars/laptop.yml +++ b/group_vars/laptop.yml @@ -52,7 +52,7 @@ - python3-pip - gramps # stammbaum ### mgrote.apt_manage_sources - manage_sources_apt_proxy_url: "" + manage_sources_apt_proxy: "" ### mgrote.ntp_chrony_server ntp_chrony_timezone: "Europe/Berlin" # Zeitzone in der sich der Computer befindet ntp_chrony_servers: # welche Server sollen befragt werden diff --git a/group_vars/pihole.yml b/group_vars/pihole.yml index fa46eaa8..f3426ef6 100644 --- a/group_vars/pihole.yml +++ b/group_vars/pihole.yml @@ -29,8 +29,7 @@ - address: pool.ntp.org options: iburst #optionaler parameter ### mgrote.apt_manage_sources - manage_sources_apt_proxy_server: "" - manage_sources_apt_proxy_port: "" + manage_sources_apt_proxy: "" ### geerlingguy.munin-node munin_node_plugins: - name: chrony diff --git a/group_vars/proxmox.yml b/group_vars/proxmox.yml index fe8ba6e1..517de424 100644 --- a/group_vars/proxmox.yml +++ b/group_vars/proxmox.yml @@ -68,6 +68,8 @@ env.client /usr/bin/fail2ban-client env.config_dir /etc/fail2ban user root + ### mgrote.apt_manage_sources + manage_sources_apt_proxy: "" # Ansible Variablen ### sudo sudo: false diff --git a/group_vars/tor.yml b/group_vars/tor.yml index ebefad9d..17c387e7 100644 --- a/group_vars/tor.yml +++ b/group_vars/tor.yml @@ -1,4 +1,6 @@ --- + ### mgrote.apt_manage_sources + manage_sources_apt_proxy: "" ### mgrote.tor-node tor_relay_name: tor1mgrote tor_or_port: 9001 diff --git a/playbooks/base/apt_sources.yml b/playbooks/base/apt_sources.yml index d9296d77..1594c9d5 100644 --- a/playbooks/base/apt_sources.yml +++ b/playbooks/base/apt_sources.yml @@ -3,6 +3,3 @@ roles: - role: mgrote.apt_manage_sources tags: "apt_sources" - when: - - "not 'laptop' in group_names" - - "not 'tor' in group_names" diff --git a/roles/mgrote.apt_manage_sources/README.md b/roles/mgrote.apt_manage_sources/README.md index 31e605c4..fa12dc6b 100644 --- a/roles/mgrote.apt_manage_sources/README.md +++ b/roles/mgrote.apt_manage_sources/README.md @@ -12,40 +12,4 @@ - [x] ProxMox (>=6.1) ### Variablen + Defaults -##### Ubuntu/Proxmox: FQDN Proxy, wenn leer wird kein Proxy gesetzt -```yaml -manage_sources_apt_proxy_url: "" # leer = kein proxy, sonst "acng.grote.lan:9999" -``` - -##### Proxmox: Pfad lokal zum Enterprise-Repository -```yaml - manage_sources_enterprise_repo_path: /etc/apt/sources.list.d/pve-enterprise.list # wo ist das enterprise-repo - -``` - -##### Proxmox: Releases-Key URL für no-subscrition-Repository -```yaml -manage_sources_apt_repo_key_url: http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg # url zum key für no-subscription-repo -``` - -##### Proxmox: Releases-Key Pfad lokal für no-subscrition-Repository -```yaml -manage_sources_apt_repo_key_path: /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg # pfad lokal zum key für no-subscription-repo -``` - -##### Proxmox: URL no-subscrition-Repository -```yaml -manage_sources_apt_repo_no_subscription: deb http://{{ manage_sources_apt_proxy_url }}/download.proxmox.com/debian/pve buster pve-no-subscription # url zum für no-subscription-repo, manage_sources_apt_proxy_url wird aus der variable entnommen -``` - -##### Proxmox: Basis-Repositories URLs -```yaml -manage_sources_proxmox_base_repos: # welche debian standard repos sollen gesetzt werden, werden vorher gelöscht damit ein proxy dann gesetzt werden kann - - repo_url: deb http://ftp.de.debian.org/debian buster main contrib - - repo_url: deb http://ftp.de.debian.org/debian buster-updates main contrib - - repo_url: deb http://security.debian.org buster/updates main contrib``` -``` - -##### Proxmox: Pfad lokal für Basis-Repositories -```yaml -manage_sources_debian_repo_path: /etc/apt/sources.list.d/debian # , wo sollen die standard-repos gespeichert werden; nicht auf /etc/apt/sources setzen, diese datei wird gelöscht``` +see [defaults](./defaults/main.yml) diff --git a/roles/mgrote.apt_manage_sources/defaults/main.yml b/roles/mgrote.apt_manage_sources/defaults/main.yml index 1009cbb8..ffb17e3d 100644 --- a/roles/mgrote.apt_manage_sources/defaults/main.yml +++ b/roles/mgrote.apt_manage_sources/defaults/main.yml @@ -3,5 +3,4 @@ manage_sources_apt_repo_key_url: http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg # url zum key für no-subscription-repo manage_sources_apt_repo_key_path: /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg # pfad lokal zum key für no-subscription-repo manage_sources_apt_repo_no_subscription: deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription # url zum für no-subscription-repo, manage_sources_apt_proxy_url wird aus der variable entnommen - manage_sources_apt_proxy_server: acng.grote.lan - manage_sources_apt_proxy_port: 9999 + manage_sources_apt_proxy: acng.grote.lan:9999 diff --git a/roles/mgrote.apt_manage_sources/handlers/main.yml b/roles/mgrote.apt_manage_sources/handlers/main.yml new file mode 100644 index 00000000..917ac034 --- /dev/null +++ b/roles/mgrote.apt_manage_sources/handlers/main.yml @@ -0,0 +1,5 @@ +--- + - name: update package lists # noqa 503 503 + become: yes + ansible.builtin.apt: + update_cache: yes diff --git a/roles/mgrote.apt_manage_sources/tasks/main.yml b/roles/mgrote.apt_manage_sources/tasks/main.yml index ec987d9e..8d5272f3 100644 --- a/roles/mgrote.apt_manage_sources/tasks/main.yml +++ b/roles/mgrote.apt_manage_sources/tasks/main.yml @@ -1,18 +1,18 @@ --- - name: include ubuntu tasks (determined by "ansible_distribution") include_tasks: ubuntu.yml - when: ansible_distribution == 'Ubuntu' + when: + - ansible_distribution == 'Ubuntu' + - manage_sources_apt_proxy | length > 0 - name: include Linux Mint tasks (determined by "ansible_distribution") include_tasks: mint.yml - when: ansible_distribution == 'Linux Mint' + when: + - ansible_distribution == 'Linux Mint' + - manage_sources_apt_proxy | length > 0 - name: include proxmox tasks (determined by group) include_tasks: proxmox.yml - when: "'proxmox' in group_names" - - - name: update package lists # noqa 503 503 - become: yes - ansible.builtin.apt: - update_cache: yes - when: copy_src.changed + when: + - "'proxmox' in group_names" + - manage_sources_apt_proxy | length > 0 diff --git a/roles/mgrote.apt_manage_sources/tasks/mint.yml b/roles/mgrote.apt_manage_sources/tasks/mint.yml index 53097131..9fe54128 100644 --- a/roles/mgrote.apt_manage_sources/tasks/mint.yml +++ b/roles/mgrote.apt_manage_sources/tasks/mint.yml @@ -5,5 +5,4 @@ src: apt.conf dest: "{{ apt_proxy_apt_conf_path | default ('/etc/apt/apt.conf') }}" backup: yes - register: copy_src - when: manage_sources_apt_proxy_server is defined + notify: update package lists diff --git a/roles/mgrote.apt_manage_sources/tasks/proxmox.yml b/roles/mgrote.apt_manage_sources/tasks/proxmox.yml index f79146af..d7841c96 100644 --- a/roles/mgrote.apt_manage_sources/tasks/proxmox.yml +++ b/roles/mgrote.apt_manage_sources/tasks/proxmox.yml @@ -5,8 +5,7 @@ src: apt.conf dest: "{{ apt_proxy_apt_conf_path | default ('/etc/apt/apt.conf') }}" backup: yes - register: copy_src - when: manage_sources_apt_proxy_server is defined + notify: update package lists - name: remove enterprise-Repository become: yes @@ -24,7 +23,7 @@ ansible.builtin.apt_key: url: "{{ manage_sources_apt_repo_key_url }}" state: present - register: copy_src + notify: update package lists when: pve_no_subscription_repo_keys.stat.exists == false - name: add pve-no-subscription repo @@ -34,4 +33,4 @@ state: present filename: pve-no-subscription update_cache: no - register: copy_src + notify: update package lists diff --git a/roles/mgrote.apt_manage_sources/tasks/ubuntu.yml b/roles/mgrote.apt_manage_sources/tasks/ubuntu.yml index 53097131..9fe54128 100644 --- a/roles/mgrote.apt_manage_sources/tasks/ubuntu.yml +++ b/roles/mgrote.apt_manage_sources/tasks/ubuntu.yml @@ -5,5 +5,4 @@ src: apt.conf dest: "{{ apt_proxy_apt_conf_path | default ('/etc/apt/apt.conf') }}" backup: yes - register: copy_src - when: manage_sources_apt_proxy_server is defined + notify: update package lists diff --git a/roles/mgrote.apt_manage_sources/templates/apt.conf b/roles/mgrote.apt_manage_sources/templates/apt.conf index d14f90cf..495e5e87 100644 --- a/roles/mgrote.apt_manage_sources/templates/apt.conf +++ b/roles/mgrote.apt_manage_sources/templates/apt.conf @@ -1,3 +1,3 @@ {{ file_header | default () }} -Acquire::http::proxy "http://{{ manage_sources_apt_proxy_server | default() }}:{{ manage_sources_apt_proxy_port | default() }}"; -Acquire::https::proxy "http://{{ manage_sources_apt_proxy_server | default() }}:{{ manage_sources_apt_proxy_port | default() }}"; +Acquire::http::proxy "http://{{ manage_sources_apt_proxy | default() }}"; +Acquire::https::proxy "http://{{ manage_sources_apt_proxy | default() }}";