From c63bed3647080781f09fc362670a883cf857be62 Mon Sep 17 00:00:00 2001 From: maheshrijal <62394512+maheshrijal@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:10:59 +0530 Subject: [PATCH 1/4] feat: add new tools --- .gitignore | 1 + local.yml | 18 ++++++++++++++++++ tasks/brave.yml | 20 ++++++++++++++++++++ tasks/flathub.yml | 16 ++++++++++++++++ tasks/install-tools.yml | 1 + tasks/signal.yml | 30 ++++++++++++++++++++++++++++++ tasks/spotify.yml | 21 +++++++++++++++++++++ tasks/vscode.yml | 19 +++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 .gitignore create mode 100644 tasks/brave.yml create mode 100644 tasks/flathub.yml create mode 100644 tasks/signal.yml create mode 100644 tasks/spotify.yml create mode 100644 tasks/vscode.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d8ed32 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +wget-log \ No newline at end of file diff --git a/local.yml b/local.yml index 5c8cec9..2ce9616 100644 --- a/local.yml +++ b/local.yml @@ -46,6 +46,24 @@ file: tasks/nodejs.yml when: ansible_os_family == "Debian" + # - name: Install brave + # ansible.builtin.include_tasks: + # file: tasks/brave.yml + # NOT TESTED + + - name: Install signal + ansible.builtin.include_tasks: + file: tasks/signal.yml + + - name: Install spotify + ansible.builtin.include_tasks: + file: tasks/spotify.yml + + - name: Install flatpak apps + ansible.builtin.include_tasks: + file: tasks/flathub.yml + tags: fresh + - name: Configure Git ansible.builtin.include_tasks: file: tasks/git.yml diff --git a/tasks/brave.yml b/tasks/brave.yml new file mode 100644 index 0000000..18df070 --- /dev/null +++ b/tasks/brave.yml @@ -0,0 +1,20 @@ +- name: Download Brave browser GPG key + get_url: + url: https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg + dest: /usr/share/keyrings/brave-browser-archive-keyring.gpg + mode: '0644' + +- name: Add Brave browser repository + lineinfile: + path: /etc/apt/sources.list.d/brave-browser-release.list + line: "deb [arch=amd64 signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" + create: yes + +- name: Update APT package index + apt: + update_cache: yes + +- name: Install Brave browser + apt: + name: brave-browser + state: present \ No newline at end of file diff --git a/tasks/flathub.yml b/tasks/flathub.yml new file mode 100644 index 0000000..d1569fb --- /dev/null +++ b/tasks/flathub.yml @@ -0,0 +1,16 @@ +--- +- name: Add or update Flathub remote + community.general.flatpak_remote: + name: flathub + state: present + flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo + method: user + tags: fresh + +- name: Install packages from flathub + community.general.flatpak: + name: + - org.mozilla.Thunderbird + - com.notesnook.Notesnook + method: user + tags: fresh \ No newline at end of file diff --git a/tasks/install-tools.yml b/tasks/install-tools.yml index dbc1e81..3c1ead3 100644 --- a/tasks/install-tools.yml +++ b/tasks/install-tools.yml @@ -20,6 +20,7 @@ - gpg - net-tools - zip + - vlc state: latest - name: Upgrade pip diff --git a/tasks/signal.yml b/tasks/signal.yml new file mode 100644 index 0000000..01dd11e --- /dev/null +++ b/tasks/signal.yml @@ -0,0 +1,30 @@ +--- +- name: Download Signal GPG key and add to keyring + ansible.builtin.shell: + cmd: "wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > /tmp/signal-desktop-keyring.gpg" + args: + creates: /tmp/signal-desktop-keyring.gpg + +- name: Move GPG key to /usr/share/keyrings + ansible.builtin.copy: + src: /tmp/signal-desktop-keyring.gpg + dest: /usr/share/keyrings/signal-desktop-keyring.gpg + remote_src: false + owner: root + group: root + mode: '0644' + +- name: Add Signal repository to apt sources + ansible.builtin.apt_repository: + repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main" + state: present + filename: signal-xenial + +- name: Update APT package index + apt: + update_cache: true + +- name: Install Signal Desktop + apt: + name: signal-desktop + state: present diff --git a/tasks/spotify.yml b/tasks/spotify.yml new file mode 100644 index 0000000..7537164 --- /dev/null +++ b/tasks/spotify.yml @@ -0,0 +1,21 @@ +--- +- name: Add Spotify GPG key + ansible.builtin.shell: > + curl -sS https://download.spotify.com/debian/pubkey_6224F9941A8AA6D1.gpg | gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/spotify.gpg + args: + creates: /etc/apt/trusted.gpg.d/spotify.gpg + +- name: Add Spotify repository + lineinfile: + path: /etc/apt/sources.list.d/spotify.list + line: 'deb http://repository.spotify.com stable non-free' + create: true + +- name: Update APT package index + apt: + update_cache: true + +- name: Install Spotify client + apt: + name: spotify-client + state: present \ No newline at end of file diff --git a/tasks/vscode.yml b/tasks/vscode.yml new file mode 100644 index 0000000..c1147b1 --- /dev/null +++ b/tasks/vscode.yml @@ -0,0 +1,19 @@ +--- +- name: Add Microsoft GPG key + apt_key: + url: https://packages.microsoft.com/keys/microsoft.asc + state: present + +- name: Add VSCode repository + apt_repository: + repo: 'deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main' + state: present + +- name: Update APT package index + apt: + update_cache: yes + +- name: Install Visual Studio Code + apt: + name: code + state: present From 4583ad1fb7b6be93307036e94f06e3263a8edf5c Mon Sep 17 00:00:00 2001 From: maheshrijal <62394512+maheshrijal@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:26:11 +0530 Subject: [PATCH 2/4] feat: add flatpak --- local.yml | 1 - tasks/flathub.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/local.yml b/local.yml index 2ce9616..7cd4d8f 100644 --- a/local.yml +++ b/local.yml @@ -62,7 +62,6 @@ - name: Install flatpak apps ansible.builtin.include_tasks: file: tasks/flathub.yml - tags: fresh - name: Configure Git ansible.builtin.include_tasks: diff --git a/tasks/flathub.yml b/tasks/flathub.yml index d1569fb..3ddc736 100644 --- a/tasks/flathub.yml +++ b/tasks/flathub.yml @@ -5,7 +5,7 @@ state: present flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo method: user - tags: fresh + become: false - name: Install packages from flathub community.general.flatpak: @@ -13,4 +13,4 @@ - org.mozilla.Thunderbird - com.notesnook.Notesnook method: user - tags: fresh \ No newline at end of file + become: false From 157c3b7ef4ece5f3dd56063b6768b2708ac24910 Mon Sep 17 00:00:00 2001 From: maheshrijal <62394512+maheshrijal@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:43:41 +0530 Subject: [PATCH 3/4] chore: lint --- .github/workflows/ansible-lint.yml | 2 +- .gitignore | 3 ++- local.yml | 14 ++++++-------- tasks/install-tools.yml | 4 ++-- tasks/signal.yml | 4 ++-- tasks/spotify.yml | 8 ++++---- tasks/terraform.yml | 3 --- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 8666bcb..94fbb2c 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -9,4 +9,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: Run ansible-lint - uses: ansible/ansible-lint@v6.20.2 + uses: ansible/ansible-lint@main diff --git a/.gitignore b/.gitignore index 1d8ed32..170e51c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -wget-log \ No newline at end of file +wget-log +.vscode \ No newline at end of file diff --git a/local.yml b/local.yml index 7cd4d8f..a4ba16b 100644 --- a/local.yml +++ b/local.yml @@ -12,16 +12,15 @@ ansible.builtin.import_tasks: handlers/main.yml pre_tasks: - - name: Update package caches if required (Debian) + + - name: End play if the system is not Debian + ansible.builtin.meta: end_play + when: ansible_facts['os_family'] != 'Debian' + + - name: Update package caches if required ansible.builtin.apt: update_cache: true cache_valid_time: 3600 - when: ansible_os_family == "Debian" - - - name: Update package caches if required (RedHat) - ansible.builtin.yum: - update_cache: true - when: ansible_os_family == "RedHat" tasks: - name: Install tools @@ -44,7 +43,6 @@ - name: Install NodeJS ansible.builtin.include_tasks: file: tasks/nodejs.yml - when: ansible_os_family == "Debian" # - name: Install brave # ansible.builtin.include_tasks: diff --git a/tasks/install-tools.yml b/tasks/install-tools.yml index 3c1ead3..30784a8 100644 --- a/tasks/install-tools.yml +++ b/tasks/install-tools.yml @@ -21,11 +21,11 @@ - net-tools - zip - vlc - state: latest + state: present - name: Upgrade pip ansible.builtin.pip: name: pip - state: latest + state: present vars: ansible_python_interpreter: /usr/bin/python3 diff --git a/tasks/signal.yml b/tasks/signal.yml index 01dd11e..30e25b1 100644 --- a/tasks/signal.yml +++ b/tasks/signal.yml @@ -21,10 +21,10 @@ filename: signal-xenial - name: Update APT package index - apt: + ansible.builtin.apt: update_cache: true - name: Install Signal Desktop - apt: + ansible.builtin.apt: name: signal-desktop state: present diff --git a/tasks/spotify.yml b/tasks/spotify.yml index 7537164..599b2eb 100644 --- a/tasks/spotify.yml +++ b/tasks/spotify.yml @@ -6,16 +6,16 @@ creates: /etc/apt/trusted.gpg.d/spotify.gpg - name: Add Spotify repository - lineinfile: + ansible.builtin.lineinfile: path: /etc/apt/sources.list.d/spotify.list line: 'deb http://repository.spotify.com stable non-free' create: true - name: Update APT package index - apt: + ansible.builtin.apt: update_cache: true - name: Install Spotify client - apt: + ansible.builtin.apt: name: spotify-client - state: present \ No newline at end of file + state: present diff --git a/tasks/terraform.yml b/tasks/terraform.yml index ab51329..15d2385 100644 --- a/tasks/terraform.yml +++ b/tasks/terraform.yml @@ -4,20 +4,17 @@ url: https://apt.releases.hashicorp.com/gpg state: present keyring: /etc/apt/trusted.gpg.d/hashicorp.gpg - when: ansible_os_family == "Debian" - name: Add hashicorp repository ansible.builtin.apt_repository: repo: deb [arch=amd64] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main state: present - when: ansible_os_family == "Debian" - name: Install Terraform ansible.builtin.apt: name: terraform state: present update_cache: true - when: ansible_os_family == "Debian" - name: Enable autocomplete for Terraform ansible.builtin.lineinfile: From 325273d47aed5477db9a2c5a6c990767b03965fe Mon Sep 17 00:00:00 2001 From: maheshrijal <62394512+maheshrijal@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:47:34 +0530 Subject: [PATCH 4/4] fix more lint --- tasks/vscode.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tasks/vscode.yml b/tasks/vscode.yml index c1147b1..db935c2 100644 --- a/tasks/vscode.yml +++ b/tasks/vscode.yml @@ -1,19 +1,19 @@ --- - name: Add Microsoft GPG key - apt_key: + ansible.builtin.apt_key: url: https://packages.microsoft.com/keys/microsoft.asc state: present - name: Add VSCode repository - apt_repository: + ansible.builtin.apt_repository: repo: 'deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main' state: present - name: Update APT package index - apt: - update_cache: yes + ansible.builtin.apt: + update_cache: true - name: Install Visual Studio Code - apt: + ansible.builtin.apt: name: code state: present