- hosts: all become: yes become_method: sudo become_user: root tasks: - name: disable phased updates copy: dest: /etc/apt/apt.conf.d/99-Phased-Updates content: "Update-Manager::Always-Include-Phased-Updates true;\n APT::Get::Always-Include-Phased-Updates true;" - name: update apt list apt: update_cache: yes - name: Update and upgrade apt packages apt: upgrade: yes # - hosts: all # become: true # become_method: sudo # become_user: root # tasks: # - name: get user # # uses_shell: true # ansible.builtin.shell: whoami # - name: Run whoami without become. # command: whoami # changed_when: false # become: false # register: whoami # - name: Set a fact with the user name. # set_fact: # login_user: "{{ whoami.stdout }}" # - name: Update Ubuntu # apt: # upgrade: true # update_cache: true # become: true