--- - hosts: debianhosts gather_facts: no tasks: - name: change working directory ansible.builtin.shell: cmd: ls -l chdir: /tmp - name: Install a list of packages ansible.builtin.apt: pkg: - apt-transport-https - curl - gnupg - name: Get GPG key ansible.builtin.shell: cmd: curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg - name: Move GPG key ansible.builtin.shell: cmd: mv bazel-archive-keyring.gpg /usr/share/keyrings - name: Add Key and repo to system ansible.builtin.shell: cmd: echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8' > /etc/apt/sources.list.d/bazel.list - name: Run the equivalent of "apt-get update" as a separate step ansible.builtin.apt: update_cache: yes # - name: Update all installed packages using APT module # apt: # name: '*' # state: latest # update_cache: yes # only_upgrade: yes # register: apt_update_status # - name: Update all installed packages using APT module # apt: # name: '*' # state: latest # update_cache: yes # only_upgrade: yes # register: apt_update_status # - name: Remove packages not needed anymore # apt: # autoremove: yes # - name: Reboot when packages were updated # reboot: # post_reboot_delay: 60 # when: apt_update_status.changed #