Skip to content

Instantly share code, notes, and snippets.

@Nebula83
Last active August 15, 2019 09:58
Show Gist options
  • Save Nebula83/fa4412d4c3b0bed588b0673d32d21247 to your computer and use it in GitHub Desktop.
Save Nebula83/fa4412d4c3b0bed588b0673d32d21247 to your computer and use it in GitHub Desktop.
Setup a VM
---
# $ sudo pip install ansible
# wget --no-cache https://gist.github.com/Nebula83/fa4412d4c3b0bed588b0673d32d21247/raw && ansible-playbook raw; rm raw
- hosts: localhost
connection: local
tasks:
#######################################################################
# SSH
- name: Ensure key exists
tags: ssh
authorized_key:
user: developer
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAznxdIrEZl4XJ7BvcAnVw9VVZJ/LQV9/+kJ/9Tw1kEKzqhBbEyiT7XTwziSqcK7LiZgZdSG5SxJgGCQ4ycXNzpVfDKmPaBt+7LhYQLwz63KzBg1OImjNDxy1dXArLx9L56srb1Y6ZYzwRUYfDuBMJXXCppUsg5/vSOfLbAj62jcimMejMyfq4nQ1Hy7P1sK62ewM6jLWEqJteBz34yxatV/wh05rqA49NPCLPkUvXtqi/ctK1oS82PntHvGgSfVbMiufwPJyK8ADpJeeou6A7AusDD7kjrKQbyXv0dVunC7BMNusabu8HtKx6EvZ+UQjaDMKkZHnxLNnhA3vzGjHgsw== moba-laptop"
#######################################################################
# git
- name: "Ensure git is installed"
tags: git
apt:
pkg: git
- name: Ensure username and email are correct
tags: git
git_config:
scope: global
name: "user.{{ item.name }}"
value: "{{ item.value }}"
loop:
- { name: 'name', value: 'Jasper van Zuijlen' }
- { name: 'email', value: 'jasper.van.zuijlen@moba.net' }
- name: Ensure git config has all the global aliases
tags: git
git_config:
scope: global
name: "alias.{{ item.name }}"
value: "{{ item.cmd }}"
loop:
- { name: "camno", cmd: "commit --amend --no-edit" }
- { name: "glog", cmd: "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset) %C(bold red)%an%C(reset)%n'' %C(white)%s%C(reset)'" }
- name: Ensure git's default editor is vi
tags: git
git_config:
scope: global
name: core.editor
value: vim
#######################################################################
# prompt
- name: Ensure profile is up-to-date
tags: prompt
git:
repo: https://gist.github.com/33bd1489a53ce4ebbf7b9f0d3b191a88.git
dest: profile.nebula
- name: Make sure the old profile is backed up
tags: prompt
command: mv ~/.profile.cust ~/.profile.cust.toz
args:
creates: ~/.profile.cust.toz
- name: Make sure .profile.cust symlinks to personal profile
tags: prompt
file:
src: ~/profile.nebula/profile.nebula
dest: ~/.profile.cust
state: link
#######################################################################
# svn
- name: Ensure global-ignores
tags: svn
lineinfile:
path: ~/.subversion/config
regex: "^(# |)global-ignores"
line: "global-ignores: .git .gitignore cmake-build* .idea"
#######################################################################
# hosts
- name: Add entries to hosts
tags: hosts
become: yes
lineinfile:
path: /etc/hosts
regex: "rhodecode.lan$"
line: "192.168.56.1 rhodecode.lan"
#######################################################################
# GDB
- name: Ensure build prerequisites exist
tags: gdb
become: yes
apt:
pkg:
- libncurses5-dev
- python-dev
- name: Ensure build dir exists
tags: gdb
file:
path: ~/Soft/gdb-8.2
state: directory
register: gdb_build_dir
- name: Ensure source package is available
tags: gdb
get_url:
url: http://ftp.gnu.org/gnu/gdb/gdb-8.2.tar.xz
dest: "{{ gdb_build_dir.path }}/gdb-8.2.tar.xz"
- name: Ensure source package is extracted
tags: gdb
unarchive:
src: "{{ gdb_build_dir.path }}/gdb-8.2.tar.xz"
dest: "{{ gdb_build_dir.path }}"
remote_src: yes
- name: Ensure the builds are configured
tags: gdb
command: ./configure --with-python
args:
chdir: "{{ item.chdir }}"
creates: "{{ item.creates }}"
with_items:
- { chdir: '{{ gdb_build_dir.path }}', creates: '{{ gdb_build_dir.path }}/gdb-8.2/Makefile' }
- { chdir: '{{ gdb_build_dir.path }}/gdb-8.2/gdb/gdbserver', creates: '{{ gdb_build_dir.path }}/gdb-8.2/gdb/gdbserver/Makefile' }
- name: Ensure gdb binaries are built
tags: gdb
make:
chdir: "{{ item }}"
target: all
params:
NUM_THREADS: 4
with_items:
- '{{ gdb_build_dir.path }}/gdb-8.2'
- '{{ gdb_build_dir.path }}/gdb-8.2/gdb/gdbserver'
- name: Ensure gdb binaries are installed
tags: gdb
become: yes
make:
chdir: "{{ item }}"
target: install
with_items:
- '{{ gdb_build_dir.path }}/gdb-8.2'
- '{{ gdb_build_dir.path }}/gdb-8.2/gdb/gdbserver'
#######################################################################
# CLion
- name: Query CLion data
tags: clion
uri:
url: "https://data.services.jetbrains.com/products/releases?code=CL&latest=true&type=release"
method: GET
return_content: yes
status_code: 200
headers:
Content-Type: "application/json"
body_format: json
register: clion_json_response
- name: Abstract latest CLion version
tags: clion
set_fact:
clion_version: "{{ clion_json_response.json.CL[0].version }}"
clion_major_version: "{{ clion_json_response.json.CL[0].majorVersion }}"
# CLion 2019 crashes on 32 bits linux, so select the latest 2018 version
- name: Sanity check for version agains architecture (32bits == 2018.3.4)
tags: clion
set_fact:
clion_version: 2018.3.4
clion_major_version: 2018.3
when: ansible_architecture == "i386"
- name: Show CLion version for this target
tags: clion
debug:
msg: "Selected CLion version {{ clion_version }}"
- name: Adjust rights on opt so we can install as user
become: yes
tags: clion
file:
path: /opt
mode: 0777
- name: Ensure selected CLion exists on disk
tags: clion
get_url:
url: "https://download.jetbrains.com/cpp/CLion-{{ clion_version }}.tar.gz"
dest: "/opt/CLion-{{ clion_version }}.tar.gz"
- name: Ensure selected version is available
tags: clion
unarchive:
src: "/opt/CLion-{{ clion_version }}.tar.gz"
dest: /opt
remote_src: yes
- name: Ensure compiler settings are correct
tags: clion
lineinfile:
path: "~/.CLion{{ clion_major_version }}/config/settingsRepository/repository/_linux/cpp.toolchains.xml"
insertafter: "<toolchains"
regex: '<toolchain name="MOBA"'
line: '<toolchain name="MOBA" toolSetKind="SYSTEM_UNIX_TOOLSET" customCMakePath="/usr/bin/cmake" debuggerKind="CUSTOM_GDB" customGDBPath="/usr/local/bin/gdb" />'
- name: Make sure that the launcher matches the current version
tags: clion
lineinfile:
path: "~/.local/share/applications/jetbrains-clion.desktop"
regex: "{{ item.regex }}"
line: "{{ item.line }}"
with_items:
- { regex: '^Icon=', line: 'Icon=/opt/clion-{{ clion_version }}/bin/clion.svg' }
- { regex: '^Exec=', line: 'Exec="/opt/clion-{{ clion_version }}/bin/clion.sh" %f' }
register: clion_desktop_launcher
- name: Restart X when launcher updated
tags: clion
become: yes
service:
name: display-manager
state: restarted
when: clion_desktop_launcher.changed
#######################################################################
# FiraCode
- name: Ensure custom fonts folder exists
tags: firacode
file:
path: ~/.local/share/fonts
state: directory
- name: Ensure firacode is available
tags: firacode
get_url:
url: "https://github.com/tonsky/FiraCode/blob/master/distr/ttf/FiraCode-{{ item }}.ttf?raw=true"
dest: ~/.local/share/fonts/
with_items:
- Bold
- Light
- Medium
- Regular
- Retina
# For CLion, follow this: https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?page=3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment