added os-update playbook for debian
This commit is contained in:
34
roles/os-updates/tasks/update_major_version.yaml
Normal file
34
roles/os-updates/tasks/update_major_version.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
- name: Backup existing sources in /etc/apt
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ item }}.bak"
|
||||
remote_src: yes
|
||||
loop: "{{ lookup('ansible.builtin.fileglob', '/etc/apt/sources.list.d/*.list') + ['/etc/apt/sources.list'] }}"
|
||||
when: item | file
|
||||
|
||||
- name: Update sources.list for new major version
|
||||
template:
|
||||
src: sources.list.j2
|
||||
dest: /etc/apt/sources.list
|
||||
vars:
|
||||
os_update_version_codename: "{{ new_version_codename }}" # Variable gets passed by main.yml task
|
||||
|
||||
- name: Update additional repositories in /etc/apt/sources.list.d
|
||||
lineinfile:
|
||||
path: "{{ item }}"
|
||||
regexp: '^(deb .* )({{ os_update_version_codename }})'
|
||||
line: '\1{{ new_version_codename }}'
|
||||
loop: "{{ lookup('ansible.builtin.fileglob', '/etc/apt/sources.list.d/*.list') }}"
|
||||
when: item | file
|
||||
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: Perform distribution upgrade
|
||||
apt:
|
||||
upgrade: yes
|
||||
allow_unauthenticated: yes
|
||||
notify:
|
||||
- Reboot system
|
||||
- apt cleanup
|
||||
Reference in New Issue
Block a user