Skip to content

Instantly share code, notes, and snippets.

@pedropombeiro
Last active December 30, 2020 19:15
Show Gist options
  • Save pedropombeiro/efecae688ad90d1a04a9854a2cbca15e to your computer and use it in GitHub Desktop.
Save pedropombeiro/efecae688ad90d1a04a9854a2cbca15e to your computer and use it in GitHub Desktop.
Ansible script to set up Ubuntu Dev PC
- hosts: DEV-PC
remote_user: pedro
vars:
usr_path: /usr/local
bin_path: '{{ usr_path }}/bin'
profile_path: '{{ ansible_env.HOME }}/.profile'
downloads_path: '{{ ansible_env.HOME }}/Downloads'
docker_compose_url: https://github.com/docker/compose/releases/download/1.18.0/docker-compose-{{ ansible_system }}-{{ ansible_userspace_architecture }}
ngrok_url: https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
bc4_url: https://www.scootersoftware.com/bcompare-4.2.4.22795_amd64.deb
bluejeans_url: https://swdl.bluejeans.com/desktop/linux/1.33/1.33.15/bluejeans-1.33.15.x86_64.rpm
plexamp_url: https://plexamp.plex.tv/plexamp.plex.tv/plexamp-1.0.5-x86_64.AppImage
jaxx_url: https://github.com/Jaxx-io/Jaxx/releases/download/v1.3.15/jaxx-1.3.15-x86_64.AppImage
tasks:
- name: Set authorized key taken from Gist
authorized_key:
user: pedro
state: present
key: https://gist.githubusercontent.com/PombeirP/60ada4d7dbd3acd8dceb5ce80ee7feef/raw/e8e1b20a43c12eb3273982c192ff047bbf4b55ab/id_rsa.pub
tags:
- ssh
- always
become: true
- name: Ensure system paths exist
block:
- file:
path: '{{ bin_path }}'
state: directory
mode: 0755
- file:
path: '{{ usr_path }}/share/applications'
state: directory
mode: 0755
tags: always
become: true
#- name: Lock Mono to 5.2.0.224 because later versions have a bug when PUTting files over HTTPS which breaks KeePass sync
# lineinfile:
# path: /etc/apt/sources.list.d/mono-xamarin.list
# regexp: '^deb http://download.mono-project.com/repo/debian wheezy bionic main'
# line: 'deb http://download.mono-project.com/repo/ubuntu/dists/stable-xenial/snapshots/5.2.0.224/ main'
# create: true
# tags: mono
# become: true
- name: Install NTP
block:
- apt:
package: ntp
state: present
update_cache: yes
- service:
name: ntp
state: stopped
enabled: yes
- lineinfile:
path: /etc/ntp.conf
line: 'server ntp.pedropombeiro.com'
- service:
name: ntp
state: started
enabled: yes
tags: ntp
become: true
- name: Update repositories cache and install basic packages
apt:
name: '{{item}}'
update_cache: yes
with_items:
- preload
- gnome-tweak-tool
- unity-tweak-tool
- build-essential
- gdebi-core
- gksu
- httpie
tags: software
become: true
- name: Install RescueTime
apt:
deb: https://www.rescuetime.com/installers/rescuetime_current_amd64.deb
tags: software
become: true
- name: Install Toggl, Skype, PushBullet and Slack
block:
# Install Toggl prerequisites
- apt:
name: '{{item}}'
update_cache: yes
with_items:
- libgstreamer-plugins-base0.10-0
- libgstreamer0.10-0
# Install Toggl, Skype, PushBullet
- apt:
deb: '{{item}}'
with_items:
- https://toggl.com/api/v8/installer?app=td&platform=deb64&channel=stable
- https://repo.skype.com/latest/skypeforlinux-64.deb
- https://github.com/sidneys/pb-for-desktop/releases/download/v6.8.1/pb-for-desktop-6.8.1-amd64.deb
# Install Slack
- apt:
name: slack
tags:
- software
- comms
become: true
- name: Install Docker CE
block:
# Install Docker CE prerequisites
- apt:
name: '{{item}}'
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
# Add Docker GPG key
- apt_key: url=https://download.docker.com/linux/ubuntu/gpg
# Add Docker APT repository
- apt_repository:
repo: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable'
# Install Docker
- apt:
name: docker-ce
# Add our user to docker group
- user:
name: '{{ ansible_env.LOGNAME }}'
groups: docker
append: yes
tags:
- software
- docker
become: true
- name: Ensure docker-compose is installed and available
get_url:
url: '{{ docker_compose_url }}'
dest: '{{ bin_path }}/docker-compose'
mode: 0755
tags:
- software
- docker
become: true
- name: Install Ansible
block:
# Add Ansible APT repository
- apt_repository:
repo: 'ppa:ansible/ansible'
# Install Ansible
- apt:
name: '{{item}}'
update_cache: yes
with_items:
- software-properties-common
- ansible
tags:
- software
- devtools
become: true
- name: Install Beyond Compare 4
apt:
deb: '{{ bc4_url }}'
tags:
- software
- devtools
become: true
- name: Create temporary directory for P4Merge download
tempfile:
state: directory
suffix: _p4v
register: p4v_download
tags:
- software
- devtools
- name: Download P4Merge
unarchive:
src: https://www.perforce.com/downloads/perforce/r17.3/bin.linux26x86_64/p4v.tgz
dest: '{{ p4v_download.path }}'
remote_src: yes
tags:
- software
- devtools
- name: Find P4Merge directory in extracted structure
find:
paths: '{{ p4v_download.path }}'
file_type: directory
patterns: 'p4v-*'
register: p4v_extracted_dir
tags:
- software
- devtools
- name: Copy P4Merge files
command: 'cp -r -u "{{ p4v_extracted_dir.files[0].path }}" "{{ usr_path }}"'
tags:
- software
- devtools
become: true
- name: Install P4Merge
file:
src: '{{ p4v_extracted_dir.files[0].path }}/bin/p4merge'
dest: /usr/bin/p4merge
state: link
tags:
- software
- devtools
become: true
- name: Install VS Code
block:
# Add Microsoft GPG key
- apt_key:
url: https://packages.microsoft.com/keys/microsoft.asc
# Add VSCode APT repository
- apt_repository:
repo: deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main
# Install VS Code
- apt:
name: '{{item}}'
update_cache: yes
with_items:
- code
# Install xclip so that clipboard works inside VS Code
- xclip
tags:
- software
- devtools
become: true
- name: Install Yubikey
block:
# Add Yukico PPA repository
- apt_repository:
repo: 'ppa:yubico/stable'
# Install Yubikey
- apt:
name: '{{item}}'
with_items:
- yubikey-neo-manager
- pinentry-curses
- scdaemon
- pcscd
- yubikey-personalization
- libusb-1.0-0-dev
tags:
- software
- yubikey
become: true
# TODO Follow https://github.com/drduh/YubiKey-Guide#install---linux
- name: Install the keyservers CA file
lineinfile:
path: '{{ ansible_env.HOME }}/.gnupg/dirmngr.conf'
line: 'hkp-cacert /etc/sks-keyservers.netCA.pem'
create: true
tags: yukikey
- name: Install GPG prerequisites
apt:
name: '{{item}}'
with_items:
- gnupg2
- gnupg-agent
tags:
- software
- gpg
- name: Install Yubikey public key
shell: gpg2 --recv 0x91527A684B864DC0
tags: gpg
- name: List GPG secret keys
shell: gpg2 --list-secret-keys --keyid-format LONG
register: secret_keys
tags: gpg
- name: Print GPG secret keys
debug:
var: secret_keys.stdout_lines
verbosity: 0
- name: Add GPG_TTY to ~/.profile
lineinfile:
path: '{{ profile_path }}'
line: 'export GPG_TTY=$(tty)'
tags: gpg
- name: Configure ~/.gnupg/gpg-agent.conf
blockinfile:
path: '{{ ansible_env.HOME }}/.gnupg/gpg-agent.conf'
block: |
enable-ssh-support
default-cache-ttl 60
max-cache-ttl 120
tags: gpg
- name: Install Git
block:
# Add Git PPA repository
- apt_repository:
repo: 'ppa:git-core/ppa'
state: present
# Install Git
- apt:
name: git
update_cache: yes
tags:
- software
- devtools
- git
become: true
- name: Configure Git
shell: 'git config --global {{ item }}'
with_items:
- user.name 'Pedro Pombeiro'
- user.email [email protected]
- user.signingkey C4A24185B2AA48A1
- commit.gpgsign true
- push.default simple
- gpg.program $(whereis -b gpg2 | cut -d ' ' -f2)
- diff.tool beyondcompare4
- diff.guitool beyondcompare4
- difftool.prompt false
- difftool.beyondcompare4.cmd 'bcompare "$LOCAL" "$REMOTE"'
- difftool.beyondcompare4.path /usr/bin/bcompare
- difftool.beyondcompare4.keepTemporaries false
- difftool.beyondcompare4.keepBackup false
- difftool.beyondcompare4.trustExitCode true
- merge.keepBackup false
- merge.tool p4merge
- merge.guitool p4merge
- mergetool.prompt false
- mergetool.p4merge.cmd 'p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'
- mergetool.p4merge.keepTemporaries false
- mergetool.p4merge.keepBackup false
- mergetool.p4merge.trustExitCode false
tags:
- devtools
- git
- name: Install GitExtensions prerequisites (Mono)
apt:
name: mono-complete
tags:
- software
- devtools
- git
become: true
- name: Download GitExtensions
unarchive:
src: https://github.com/gitextensions/gitextensions/releases/download/v2.51.02/GitExtensions-2.51.02-Mono.zip
dest: '{{ bin_path }}'
remote_src: yes
tags:
- software
- devtools
- git
become: true
- name: Fix GitExtensions path in gitext.sh
replace:
path: '{{ bin_path }}/GitExtensions/gitext.sh'
regexp: '^(mono) (GitExtensions\.exe)'
replace: '\1 {{ bin_path }}/GitExtensions/\2'
mode: 0755
tags:
- devtools
- git
become: true
- name: Configure {{ usr_path }}/share/applications/GitExtensions.desktop
blockinfile:
path: '{{ usr_path }}/share/applications/GitExtensions.desktop'
block: |
[Desktop Entry]
Type=Application
Terminal=false
Name=GitExtensions
Icon='{{ bin_path }}/GitExtensions/git-extensions-logo-final-256.ico'
Exec='mono {{ bin_path }}/GitExtensions/GitExtensions.exe'
tags:
- devtools
- git
become: true
- name: Install KeePass
block:
# Add jtaylor/keepass PPA repository
- apt_repository:
repo: 'ppa:jtaylor/keepass'
state: present
# Add dlech/keepass2-plugins PPA repository
- apt_repository:
repo: 'ppa:dlech/keepass2-plugins'
state: present
# Install KeePass prerequisites
- apt:
name: '{{item}}'
update_cache: yes
with_items:
- keepass2
- keepass2-plugin-keeagent
- xdotool
# Download KeeOtp
- unarchive:
src: https://bitbucket.org/devinmartin/keeotp/downloads/KeeOtp-1.3.9.zip
dest: /usr/lib/keepass2/plugins/
remote_src: yes
tags:
- software
- keepass
become: true
- name: Install Golang
block:
- unarchive:
src: https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz
dest: '{{ usr_path }}'
remote_src: yes
become: true
# add GOPATH, STATUS_GO_HOME, STATUS_REACT_HOME environment variables
- lineinfile:
dest: '{{ profile_path }}'
line: '{{ item }}'
with_items:
- 'export GOPATH={{ ansible_env.HOME }}/go'
- 'export STATUS_GO_HOME={{ ansible_env.HOME }}/go/src/github.com/status-im/status-go'
- 'export STATUS_REACT_HOME={{ ansible_env.HOME }}/src/github.com/status-im/status-react'
tags:
- software
- devtools
- name: Download Android Studio
unarchive:
src: https://dl.google.com/dl/android/studio/ide-zips/3.1.2.0/android-studio-ide-173.4720617-linux.zip
dest: '{{ usr_path }}'
remote_src: yes
tags:
- software
- devtools
become: true
- name: Install Android Studio addons
apt:
name: '{{item}}'
with_items:
- libc6:i386
- libncurses5:i386
- libstdc++6:i386
- lib32z1
- libbz2-1.0:i386
tags:
- software
- devtools
become: true
- name: add ANDROID_NDK_HOME, ANDROID_HOME, ANDROID_SDK environment variables
vars:
- android_sdk: '{{ ansible_env.HOME }}/Android/Sdk'
lineinfile:
dest: '{{ profile_path }}'
line: '{{ item }}'
with_items:
- 'export ANDROID_NDK_HOME={{ android_sdk }}/ndk-bundle'
- 'export ANDROID_HOME={{ android_sdk }}'
- 'export ANDROID_SDK={{ android_sdk }}'
tags:
- software
- devtools
- name: Install KVM
apt:
name: '{{item}}'
with_items:
- qemu-kvm
- libvirt-bin
- ubuntu-vm-builder
- bridge-utils
tags:
- software
become: true
# https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
- name: Install IntelliJ Idea
block:
# Increase max_user_watches for IntelliJ Idea
- sysctl:
name: fs.inotify.max_user_watches
value: 524288
state: present
# Set vm.swappiness=10 for IntelliJ Idea
- sysctl:
name: vm.swappiness
value: 10
state: present
reload: yes
# Install IntelliJ Idea
- command: snap install intellij-idea-community --classic --edge
tags: software
become: true
- name: Install ngrok
unarchive:
src: '{{ ngrok_url }}'
dest: '{{ bin_path }}'
remote_src: yes
tags:
- software
- devtools
become: true
- name: Add paths to PATH
vars:
extra_path: '{{ usr_path }}/go/bin:$HOME/go/bin:$PATH:$ANDROID_SDK/platform-tools/:$ANDROID_SDK/tools/:{{ bin_path }}/GitExtensions/'
lineinfile:
dest: '{{ profile_path }}'
state: present
backrefs: yes
regexp: 'PATH=(["]*)((?!.*?{{extra_path}}).*?)(["]*)$'
line: 'PATH=\1\2:{{extra_path}}\3'
# https://developer.android.com/studio/run/device.html
- name: Add udev rule for Nexus 6P
block:
# Add our user to plugdev group
- user:
name: '{{ ansible_env.LOGNAME }}'
groups: plugdev
append: yes
# Add udev rule for Nexus 6P
- blockinfile:
path: /etc/udev/rules.d/51-android.rules
block: |
# Google Nexus 6P
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0664", GROUP="plugdev"
# Restart udev service
- service:
name: udev
state: restarted
tags: devtools
become: true
- name: Install BlueJeans
block:
# Download BlueJeans
- get_url:
url: '{{ bluejeans_url }}'
dest: '{{ downloads_path }}/bluejeans.x86_64.rpm'
# Install BlueJeans
- command: 'alien {{ downloads_path }}/bluejeans.x86_64.rpm -i -k --scripts'
become: true
tags:
- software
- comms
- name: Install jq
apt:
name: jq
tags:
- software
- devtools
become: true
- name: Install Geth
block:
# Add ethereum PPA repository
- apt_repository:
repo: 'ppa:ethereum/ethereum'
state: present
# Install Geth
- apt:
name: ethereum
tags:
- software
- crypto
become: true
- name: Install Plexamp
get_url:
url: '{{ plexamp_url }}'
dest: '{{ bin_path }}/plexamp-x86_64.AppImage'
mode: 0755
tags:
- software
- music
become: true
- name: Install Jaxx
get_url:
url: '{{ jaxx_url }}'
dest: /opt/jaxx-x86_64.AppImage
mode: 0755
tags:
- software
- crypto
become: true
- name: Fix broken installs
shell: apt --fix-broken install -y
tags: software
become: true
- name: Remove dependencies that are no longer required
apt:
autoremove: yes
tags: software
become: true
- name: Set launcher-minimize-window to true
command: gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-minimize-window true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment