upgrade.yml (2652B)
1 --- 2 # Unlike a blanket policy_rc_d: 101, this policy still permits unrelated OS 3 # daemons to perform their normal package upgrade actions. 4 - name: Reset temporary upgrade policy state 5 ansible.builtin.set_fact: 6 common_upgrade_policy_backup: {} 7 common_upgrade_policy_move: {} 8 common_upgrade_policy_install: {} 9 10 - name: Upgrade system packages with application starts denied 11 block: 12 - name: Allocate a backup beside the existing policy to preserve relative symlinks 13 ansible.builtin.tempfile: 14 state: file 15 path: /usr/sbin 16 prefix: .taler-upgrade-policy- 17 register: common_upgrade_policy_backup 18 when: not ansible_check_mode 19 20 - name: Inspect the existing package service policy 21 ansible.builtin.stat: 22 path: /usr/sbin/policy-rc.d 23 follow: false 24 register: common_upgrade_original_policy 25 when: not ansible_check_mode 26 27 - name: Preserve the existing package service policy 28 ansible.builtin.command: 29 argv: 30 - mv 31 - -- 32 - /usr/sbin/policy-rc.d 33 - "{{ common_upgrade_policy_backup.path }}" 34 register: common_upgrade_policy_move 35 when: 36 - not ansible_check_mode 37 - common_upgrade_original_policy.stat.exists 38 39 - name: Install temporary application service policy 40 ansible.builtin.template: 41 src: upgrade-policy-rc.d.j2 42 dest: /usr/sbin/policy-rc.d 43 owner: root 44 group: root 45 mode: '0755' 46 register: common_upgrade_policy_install 47 when: not ansible_check_mode 48 49 - name: Deploy current base distro 50 ansible.builtin.apt: 51 state: latest 52 update_cache: true 53 autoclean: true 54 autoremove: true 55 upgrade: safe 56 57 always: 58 - name: Restore the original package service policy 59 ansible.builtin.command: 60 argv: 61 - mv 62 - -- 63 - "{{ common_upgrade_policy_backup.path }}" 64 - /usr/sbin/policy-rc.d 65 when: 66 - not ansible_check_mode 67 - common_upgrade_policy_move.rc | default(-1) == 0 68 69 - name: Remove the temporary policy when none existed before 70 ansible.builtin.file: 71 path: /usr/sbin/policy-rc.d 72 state: absent 73 when: 74 - not ansible_check_mode 75 - common_upgrade_policy_move.rc | default(-1) != 0 76 - common_upgrade_policy_install is changed 77 78 - name: Remove the unused backup placeholder 79 ansible.builtin.file: 80 path: "{{ common_upgrade_policy_backup.path }}" 81 state: absent 82 when: 83 - not ansible_check_mode 84 - common_upgrade_policy_backup.path is defined