Files
Terraform/roles/lib/upgrade-packages.yml
2025-04-22 01:04:24 -05:00

42 lines
991 B
YAML

- name: Configure apt proxy
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/proxy
line: 'Acquire::http { Proxy "http://192.168.0.60:3142"; }'
state: present
create: yes
mode: '0644'
- name: Set up apt proxy configuration
copy:
content: |
Acquire::http::Proxy "http://debcache:3142";
dest: /etc/apt/apt.conf.d/00cacher
mode: '0644'
- name: Update apt cache
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600
- name: Upgrade all packages
ansible.builtin.apt:
upgrade: dist
force_apt_get: yes
- name: Check if reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
get_checksum: no
register: reboot_required
- name: Reboot the system if required
ansible.builtin.reboot:
msg: "{{ reboot_message }}"
when: reboot_required.stat.exists
- name: Clean up old packages
ansible.builtin.apt:
autoclean: yes