CHEZMOI - ANSIBLE Sample file (Setup.yaml) --- - name: Machine setup hosts: localhost become: true remote_user: tmeijn connection: local gather_facts: true vars: teams_for_linux_version: "v1.4.37" arch_mapping: # Map ansible architecture {{ ansible_architecture }} names to Docker's architecture names x86_64: amd64 aarch64: arm64 tasks: - name: Setting facts based on ansible_architecture block: - name: Set facts for amd64 ansible.builtin.set_fact: aws_ssm_plugin_deb_url: https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb teams_for_linux_deb_url: https://github.com/IsmaelMartinez/teams-for-linux/releases/download/{{ teams_for_linux_version }}/teams-for-linux_{{ teams_for_linux_version | regex_replace('^v','') }}_amd64.deb vscode_deb_url: https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64 when: ansible_architecture == 'x86_64' - name: Set facts for arm64 ansible.builtin.set_fact: aws_ssm_plugin_deb_url: https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_arm64/session-manager-plugin.deb teams_for_linux_deb_url: https://github.com/IsmaelMartinez/teams-for-linux/releases/download/{{ teams_for_linux_version }}/teams-for-linux_{{ teams_for_linux_version | regex_replace('^v','') }}_arm64.deb vscode_deb_url: https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-arm64 when: ansible_architecture == 'aarch64' - name: Install packages ansible.builtin.package: name: - build-essential - curl - gawk - git - gnome-shell-extensions - gnome-tweaks - graphviz - gtk2-engines-murrine - incus - jc - kitty # Our terminal! - nala - network-manager-l2tp - network-manager-l2tp-gnome - pavucontrol - px - qemu-system - timeshift - vim - virt-manager - xclip - name: Set Kitty as default ansible.builtin.shell: | sudo update-alternatives --set x-terminal-emulator "$(which kitty)" changed_when: false - name: "[BLOCK] Setting up Flatpak" block: - name: Install Flatpak and dependencies if not present ansible.builtin.package: name: - flatpak - gnome-software-plugin-flatpak - name: Setup Flathub as a remote community.general.flatpak_remote: name: flathub state: present flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo - name: Install Flatpak packages community.general.flatpak: name: - org.videolan.VLC - org.gnome.meld - io.podman_desktop.PodmanDesktop - org.flameshot.Flameshot - io.dbeaver.DBeaverCommunity # - org.chromium.Chromium - io.github.seadve.Kooha - com.axosoft.GitKraken - md.obsidian.Obsidian - app.getclipboard.Clipboard state: present - name: Install Firefox as snap (arm64 is not available yet on Flatpak) community.general.snap: name: firefox - name: "[BLOCK] Install AWS Session Manager Plugin if not present" block: - name: ==== Check if plugin is present become: false ansible.builtin.shell: cmd: command -v session-manager-plugin register: aws_ssm_plugin_installed ignore_errors: true changed_when: false - name: ==== Download Plugin ansible.builtin.apt: deb: "{{ aws_ssm_plugin_deb_url }}" state: present when: aws_ssm_plugin_installed is failed - name: "[BLOCK] Install Visual Studio Code if not present" block: - name: ==== Check if VSCode is present become: false ansible.builtin.shell: cmd: command -v code register: vscode_installed ignore_errors: true changed_when: false - name: ==== Download VSCode ansible.builtin.apt: deb: "{{ vscode_deb_url }}" state: present when: vscode_installed is failed - name: "[BLOCK] Install ble.sh if not present" block: - name: ==== Check if ble.sh is present become: false # noqa: command-instead-of-shell ansible.builtin.shell: cmd: command -v ble register: blesh_installed ignore_errors: true changed_when: false - name: ==== Fetch ble.sh repository and install ble.sh become: false # noqa: command-instead-of-shell command-instead-of-module no-changed-when ansible.builtin.shell: | git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git make -C ble.sh install PREFIX=~/.local rm -rf ble.sh when: blesh_installed is failed - name: "[BLOCK] Add repo, install and configure Docker" block: - name: Add Docker's official GPG key ansible.builtin.apt_key: url: https://download.docker.com/linux/ubuntu/gpg keyring: /etc/apt/keyrings/docker.gpg state: present - name: Add Docker repository ansible.builtin.apt_repository: repo: >- deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable filename: docker state: present - name: Install Docker and related packages ansible.builtin.apt: pkg: - docker-ce - docker-ce-cli - containerd.io state: present update_cache: true - name: Add Docker group ansible.builtin.group: name: docker state: present - name: Add user to Docker group ansible.builtin.user: name: "{{ ansible_user }}" groups: docker append: true - name: Enable and start Docker services ansible.builtin.systemd: name: "{{ item }}" enabled: true state: started loop: - docker.service - containerd.service # === NOTE: This is currently not working on Ubuntu Asahi # - name: "[BLOCK] Add repo, install and configure Firefox" # block: # - name: Add Firefox's official GPG key # ansible.builtin.apt_key: # url: https://packages.mozilla.org/apt/repo-signing-key.gpg # keyring: /etc/apt/keyrings/packages.mozilla.org.gpg # state: absent # - name: Add Firefox repository # ansible.builtin.apt_repository: # repo: >- # deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.gpg] # https://packages.mozilla.org/apt mozilla main # filename: mozilla # state: absent # - name: Install Firefox # ansible.builtin.apt: # pkg: # - firefox # state: absent # update_cache: true # === NOTE: This is currently not working on Ubuntu Asahi # - name: "[BLOCK] Add repo, install and configure Progressive Web Apps for Firefox" # block: # - name: ==== Add firefoxpwa's official GPG key # ansible.builtin.apt_key: # url: https://packagecloud.io/filips/FirefoxPWA/gpgkey # keyring: /usr/share/keyrings/firefoxpwa-keyring.gpg # state: absent # - name: Add firefoxpwa repository # ansible.builtin.apt_repository: # repo: >- # deb [signed-by=/usr/share/keyrings/firefoxpwa-keyring.gpg] # https://packagecloud.io/filips/FirefoxPWA/any any main # filename: firefoxpwa # state: absent # - name: Install Progressive Web Apps for Firefox # ansible.builtin.apt: # pkg: # - firefoxpwa # state: absent # update_cache: true # NOTE: this should be absolutely last as afterwards restart is needed. - name: Install Pop Shell if not present become: false block: - name: Check if extension is present ansible.builtin.shell: cmd: gnome-extensions list | grep pop-shell@system76.com -q register: gnome_pop_shell_installed ignore_errors: true changed_when: false - name: Download Plugin ansible.builtin.shell: | npm -g i typescript git clone --recursive --depth 1 --shallow-submodules --branch master_noble https://github.com/pop-os/shell.git cd shell make local-install cd .. rm -rf shell when: gnome_pop_shell_installed is failed # - name: Ensure fonts directory # ansible.builtin.file: # path: "~{{ remote_regular_user }}/.fonts" # state: directory # mode: "0755" # owner: "{{ remote_regular_user }}" # - name: Check if Jetbrains Mono exists # ansible.builtin.shell: "ls ~{{ remote_regular_user }}/.fonts/JetBrainsMonoNerd*FontMono*" # register: jetbrains_mono_exists # ignore_errors: true # changed_when: false # - name: Download Jetbrains mono # when: jetbrains_mono_exists is failed # ansible.builtin.unarchive: # src: https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip # dest: "~{{ remote_regular_user }}/.fonts/" # remote_src: true # mode: "0755" # owner: "{{ remote_regular_user }}"