Skip to content

Instantly share code, notes, and snippets.

@ct27stf
Last active July 18, 2021 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ct27stf/14177d55a4c5a3cf640e96475741fcd3 to your computer and use it in GitHub Desktop.
Save ct27stf/14177d55a4c5a3cf640e96475741fcd3 to your computer and use it in GitHub Desktop.
Ubuntu minimal developer machine setup

Install script for minimal web developer machine

Linux

Ubuntu >= 20.04 is required.

This will run the setup.sh script, which is a convenience method that will doanload and run the ansible-dev-machine.yml playbook file into your $HOME dir, install ansible if not found and run the playbook

  • Open a terminal and paste the folowing

    bash <(wget -qO- https://gist.github.com/ct27stf/14177d55a4c5a3cf640e96475741fcd3/raw/setup.sh)
---
- hosts: localhost
vars_prompt:
- name: git_user
prompt: Enter the NAME you want to use in your git commits
unsafe: yes
private: no
- name: git_email
prompt: Enter the EMAIL you want to use in your git commits
unsafe: yes
private: no
- name: "install_slack"
prompt: "Do you want the Slack app installed? (type 1 or 2)\n1- No\n2- Yes\n"
private: no
- name: "install_postman"
prompt: "Do you want the Postman app installed? (type 1 or 2)\n1- No\n2- Yes\n"
private: no
- name: "vscode_plugins_all"
prompt: "Do you want extra VsCode plugins? (type 1 or 2)\n1- No\n2- Yes\n"
private: no
tasks:
- name: Install playbook deps
become: yes
apt:
name: '{{ packages }}'
vars:
packages:
- python-apt
- python3-apt
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install 3rd party repos keys
become: yes
apt_key:
url: '{{ item }}'
state: present
with_items:
- https://deb.nodesource.com/gpgkey/nodesource.gpg.key
- https://dl.google.com/linux/linux_signing_key.pub
- https://packages.cloud.google.com/apt/doc/apt-key.gpg
- http://packages.microsoft.com/keys/microsoft.asc
- https://download.docker.com/linux/ubuntu/gpg
- https://apt.releases.hashicorp.com/gpg
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install 3rd party repos
become: yes
apt_repository:
repo: '{{ item.repo }}'
filename: '{{ item.filename }}'
update_cache: yes
with_items:
- { repo: 'deb https://deb.nodesource.com/node_14.x focal main', filename: 'nodesource' }
- { repo: 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main', filename: 'google-chrome' }
- { repo: 'deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main', filename: 'vscode' }
- { repo: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable', filename: 'docker-ce'}
- { repo: 'deb [arch=amd64] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main', filename: 'hashicorp'}
- { repo: 'ppa:git-core/ppa', filename: ''}
- { repo: 'ppa:eosrei/fonts', filename: ''}
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install all the software
become: yes
apt:
name: '{{ packages }}'
update_cache: yes
vars:
packages:
- nodejs
- google-chrome-stable
- code
- docker-ce
- docker-ce-cli
- containerd.io
- terraform
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install utils
become: yes
apt:
name: '{{ packages }}'
vars:
packages:
- mc
- fonts-firacode
- pigz
- xz-utils
- git
- git-gui
- gitg
- gitk
- meld
- php-cli
- php-ast
- php-curl
- php-ssh2
- php-xml
- wine-stable
- winetricks
- gnome-tweaks
- gnome-shell-extensions
- chrome-gnome-shell
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install Kubectl
become: yes
snap:
name: kubectl
classic: yes
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install Helm
become: yes
snap:
name: helm
classic: yes
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install Lens
become: yes
snap:
name: kontena-lens
classic: yes
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install Microk8s
become: yes
snap:
name: microk8s
classic: yes
channel: '1.20/stable'
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install Slack
become: yes
snap:
name: slack
classic: yes
when:
- ansible_distribution == "Ubuntu"
- ansible_distribution_major_version >= "20"
- ( install_slack == "2" )
- name: Install Postman
become: yes
snap:
name: slack
when:
- ansible_distribution == "Ubuntu"
- ansible_distribution_major_version >= "20"
- ( install_slack == "2" )
- name: Get Mysql Workbench for Ubuntu 20.04
become: yes
apt:
deb: https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community_8.0.25-1ubuntu20.04_amd64.deb
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "20.04"
- name: Get Mysql Workbench for Ubuntu 21.04
become: yes
apt:
deb: https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community_8.0.25-1ubuntu21.04_amd64.deb
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "21.04"
- name: Adding current user to group docker
become: yes
user:
name: "{{ ansible_user }}"
groups: docker
append: yes
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Create NPM global dir
file:
path: '~/.npm-global'
state: directory
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Set NPM global dir in my home
shell: >
npm config set prefix '~/.npm-global'
args:
executable: /bin/bash
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Set NPM global bin in PATH
lineinfile:
state: present
path: ~/.profile
regexp: 'npm-global/bin'
line: 'export PATH=$HOME/.npm-global/bin:$PATH'
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Set Composer global bin in PATH
lineinfile:
state: present
path: ~/.profile
regexp: 'composer/vendor/bin'
line: 'export PATH=$HOME/.composer/vendor/bin:$PATH'
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Git global config
git_config:
name: '{{ item.name }}'
scope: global
value: '{{ item.value }}'
with_items:
- { name: user.email , value: '{{ git_user }}' }
- { name: user.name , value: '{{ git_email }}' }
- { name: core.editor , value: 'code -w' }
- { name: merge.tool , value: 'meld' }
- { name: mergetool.meld.cmd , value: 'meld $LOCAL $MERGED $REMOTE --output $MERGED' }
- { name: core.autocrlf , value: 'input' }
- { name: core.whitespace , value: 'trailing-space,space-before-tab' }
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install VSCode minimal plugins
shell: "code --install-extension {{ item }}"
with_items:
- bmewburn.vscode-intelephense-client
- editorconfig.editorconfig
- felixfbecker.php-debug
- neilbrayfield.php-docblocker
- ms-vscode-remote.vscode-remote-extensionpack
- redhat.vscode-yaml
- ms-kubernetes-tools.vscode-kubernetes-tools
- mindaro.mindaro
- ikappas.phpcs
args:
executable: /bin/bash
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "20"
- name: Install VSCode extra plugins
shell: "code --install-extension {{ item }}"
with_items:
# extensia pe care o asteptam de o viata
- coenraads.bracket-pair-colorizer-2
- johnpapa.vscode-peacock
- eamodio.gitlens
- mhutchie.git-graph
- mikestead.dotenv
- dbaeumer.vscode-eslint
- ms-vscode.vscode-typescript-tslint-plugin
- VisualStudioExptTeam.vscodeintellicode
- ms-azuretools.vscode-docker
- mrded.railscasts
- PKief.material-icon-theme
- yzhang.markdown-all-in-one
- hashicorp.terraform
- atlassian.atlascode
args:
executable: /bin/bash
when:
- ansible_distribution == "Ubuntu"
- ansible_distribution_major_version >= "20"
- ( vscode_plugins_all == "2" )
#!/usr/bin/env bash
if ! [ -x "$(command -v ansible)" ]; then
echo 'Ansible not found. Installing'
sudo apt update && sudo apt install -y -qq ansible </dev/null
fi
echo 'Downloading ansible-dev-machive playbook'
wget -O $HOME/ansible-dev-machine.yml https://gist.github.com/ct27stf/14177d55a4c5a3cf640e96475741fcd3/raw/ansible-dev-machine.yml
chown $(id -u):$(id -g) $HOME/ansible-dev-machine.yml
echo 'Running playbook'
ansible-playbook -l localhost -K $HOME/ansible-dev-machine.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment