refactor: improve Ansible tasks for Docker and Rust installation with enhanced error handling and updated conditions
All checks were successful
Nix Format Check / check-format (pull_request) Successful in 37s

This commit is contained in:
Menno van Leeuwen 2025-01-21 00:11:51 +01:00
parent cfb75d8765
commit 08d6685812
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
4 changed files with 36 additions and 22 deletions

View File

@ -4,15 +4,24 @@
changed_when: false changed_when: false
failed_when: false failed_when: false
- name: Download Docker installation script
ansible.builtin.get_url:
url: https://get.docker.com
dest: /tmp/get-docker.sh
mode: '0755'
when: docker_check.rc != 0
- name: Install Docker CE - name: Install Docker CE
ansible.builtin.shell: curl -fsSL https://get.docker.com | sh ansible.builtin.shell: bash -c 'set -o pipefail && sh /tmp/get-docker.sh'
args:
creates: /usr/bin/docker
when: docker_check.rc != 0 when: docker_check.rc != 0
- name: Add user to docker group - name: Add user to docker group
ansible.builtin.user: ansible.builtin.user:
name: "{{ ansible_user }}" name: "{{ ansible_user }}"
groups: docker groups: docker
append: yes append: true
become: true become: true
when: docker_check.rc != 0 when: docker_check.rc != 0
@ -20,13 +29,13 @@
ansible.builtin.systemd: ansible.builtin.systemd:
name: docker name: docker
state: started state: started
enabled: yes enabled: true
become: true become: true
register: docker_service register: docker_service
- name: Reload systemd - name: Reload systemd
ansible.builtin.systemd: ansible.builtin.systemd:
daemon_reload: yes daemon_reload: true
become: true become: true
when: docker_service.changed when: docker_service.changed
@ -34,7 +43,7 @@
ansible.builtin.systemd: ansible.builtin.systemd:
name: docker name: docker
state: started state: started
enabled: yes enabled: true
become: true become: true
when: docker_service.changed when: docker_service.changed
notify: Reload systemd

View File

@ -1,2 +1,2 @@
- name: Install Pano - Clipboard Manager - name: Install Pano - Clipboard Manager
import_tasks: tasks/gnome-extensions/pano.yml ansible.builtin.import_tasks: tasks/gnome-extensions/pano.yml

View File

@ -8,7 +8,7 @@
path: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io" path: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io"
state: directory state: directory
mode: '0755' mode: '0755'
when: pano_check.stat.exists == False when: not pano_check.stat.exists
# To update Pano, delete the existing directory and re-download the latest release # To update Pano, delete the existing directory and re-download the latest release
# Replace the URL with the latest release URL and rerun the playbook/dotf update # Replace the URL with the latest release URL and rerun the playbook/dotf update
@ -16,22 +16,25 @@
ansible.builtin.get_url: ansible.builtin.get_url:
url: https://github.com/oae/gnome-shell-pano/releases/download/v23-alpha3/pano@elhan.io.zip url: https://github.com/oae/gnome-shell-pano/releases/download/v23-alpha3/pano@elhan.io.zip
dest: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip" dest: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip"
when: pano_check.stat.exists == False mode: '0644'
when: not pano_check.stat.exists
- name: Extract Pano - Clipboard Manager - name: Extract Pano - Clipboard Manager
ansible.builtin.unarchive: ansible.builtin.unarchive:
src: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip" src: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip"
dest: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/" dest: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/"
when: pano_check.stat.exists == False when: not pano_check.stat.exists
- name: Cleanup post Pan - Clipboard Manager installation - name: Cleanup post Pan - Clipboard Manager installation
ansible.builtin.file: ansible.builtin.file:
path: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip" path: "{{ ansible_user_dir }}/.local/share/gnome-shell/extensions/pano@elhan.io/release.zip"
state: absent state: absent
when: pano_check.stat.exists == False when: not pano_check.stat.exists
- name: Notify user of required GNOME Shell extension reload - name: Notify user of required GNOME Shell extension reload
ansible.builtin.debug: ansible.builtin.debug:
msg: "Please reload GNOME Shell by pressing Alt + F2, typing 'r' and pressing Enter. Then enable the Pano - Clipboard Manager extension in GNOME Tweaks. Or on Wayland, log out and back in." msg: >
when: pano_check.stat.exists == False Please reload GNOME Shell by pressing Alt + F2, typing 'r' and pressing Enter.
Then enable the Pano - Clipboard Manager extension in GNOME Tweaks.
Or on Wayland, log out and back in.
when: not pano_check.stat.exists

View File

@ -6,15 +6,17 @@
args: args:
executable: /bin/bash executable: /bin/bash
- name: Download Rust installation script
ansible.builtin.get_url:
url: https://sh.rustup.rs
dest: /tmp/rustup.sh
mode: '0755'
when: rust_check.rc != 0
- name: Install Rust and Cargo - name: Install Rust and Cargo
shell: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ansible.builtin.shell: |
set -o pipefail
/tmp/rustup.sh -y
args: args:
creates: ~/.cargo/bin/rustc creates: ~/.cargo/bin/rustc
when: rust_check.rc != 0 when: rust_check.rc != 0
- name: Add Cargo to PATH
ansible.builtin.lineinfile:
path: ~/.bashrc
line: 'source $HOME/.cargo/env'
create: yes
when: rust_check.rc != 0