---
tags:
  - Scirpts
  - Desktop
---
This file is used in conjunction with run_once_install_ansible.sh. This file should be placed in the home/.local/dot_bootstrap directory. 

``` yaml
- name: Install applications on Ubuntu
  hosts: all
  become: yes
  tasks:
    - name: Update and upgrade apt packages
      apt:
        update_cache: yes
        upgrade: dist

# Install APT Applications
    - name: Install Apt packages
      apt:
        name: "{{ item }}"
        state: present
      loop:
        - curl
        - wget
        - git
        - bat
        - vim
        - zsh
        - build-essential
        - autoconf
        - make
        - libssl-dev
        - ca-certificates
        - htop
        - firefox
        - blender
        - vlc
        - filezilla
        - inotify-tools
        - eza
        - zoxide
        - fzf
        - docker-compose

# Installing Flatpak and Applications

    - name: Install Flatpak applications
      community.general.flatpak:
        name: "{{ item }}"  # Use the item from the loop as the Flatpak application name
        state: present
        remote: flathub  # Specify the Flathub remote for installation
#    - name: Install Flatpak packages
#      command: "flatpak install {{ item }}" -y
      loop:
        - com.obsproject.Studio
        - org.tenacityaudio.Tenacity
        - md.obsidian.Obsidian
        - org.gimp.GIMP
        - com.github.zadam.trilium
        - com.spotify.Client
        - io.github.shiftey.Desktop
        - com.brave.Browser
        - com.visualstudio.code
        - org.qbittorrent.qBittorrent
        - org.wezfurlong.wezterm

      register: result  # Register the result of the command
      failed_when: result.rc != 0 # Fail if return code is not 0
      retries: 3  # Add retries in case of transient network issues
      delay: 5    # Wait a few seconds between retries
      until: result.rc == 0
      tags: flatpak # Tagging for potential skipping

# Install Terraform
    - name: Add HashiCorp GPG key
      ansible.builtin.shell: |
        wget -O- https://apt.releases.hashicorp.com/gpg | \
        gpg --dearmor | \
        sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
      args:
        creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
      when: ansible_os_family == "Debian" #  Only run on Debian-based systems

    - name: Add HashiCorp APT repository
      ansible.builtin.apt_repository:
        repo: "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main"
        state: present
        filename: hashicorp
      when: ansible_os_family == "Debian"

    - name: Update apt cache again after adding repository
      ansible.builtin.apt:
        update_cache: yes
      when: ansible_os_family == "Debian"

    - name: Install Terraform
      ansible.builtin.apt:
        name: terraform
        state: present
      when: ansible_os_family == "Debian"

    # --- Zsh Completion ---
    - name: Install zsh (if not already installed)
      ansible.builtin.apt:
        name: zsh
        state: present

# Install flyctl
    - name: Ensure zsh is installed
      ansible.builtin.apt:
        name: zsh
        state: present

    - name: Download flyctl installation script
      ansible.builtin.get_url:
        url: https://fly.io/install.sh
        dest: /tmp/install.sh
        mode: '0755'  # Make the script executable

    - name: Run flyctl installation script
      ansible.builtin.shell: /tmp/install.sh
      args:
        creates: /usr/local/bin/flyctl  # Prevents rerunning if flyctl is already installed


# Install PowerLine10k and Oh-My-Zsh

    - name: Install Oh My Zsh
      shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
      args:
        creates: "/home/miker/.oh-my-zsh"

    - name: Add zsh-autosuggestions plugin
      git:
        repo: 'https://github.com/zsh-users/zsh-autosuggestions.git'
        dest: "/home/miker/.oh-my-zsh/custom/plugins/zsh-autosuggestions"
        depth: 1

    - name: Add zsh-syntax-highlighting plugin
      git:
        repo: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
        dest: "/home/miker/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
        depth: 1

    - name: Enable zsh-autosuggestions and zsh-syntax-highlighting plugins
      lineinfile:
        path: "/home/miker/.zshrc"
        regexp: '^plugins=\((.*)\)$'
        line: 'plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' # You can customize the plugins list
        backup: yes

# To run - run the following command. ansible-playbook -i inventory install_apps.yml




```