Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu distirbution support #23

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#!/usr/bin/env bash

sudo dnf install ansible
ansible-galaxy install geerlingguy.docker
case "${1}" in
(--apt|--deb)
export dist_type=Debian
sudo apt install ansible
ansible-galaxy install geerlingguy.docker
;;
(''|*)
export dist_type=Fedora
sudo dnf install ansible
ansible-galaxy install geerlingguy.docker
;;
esac
11 changes: 11 additions & 0 deletions roles/ubuntu/git/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Install git
become: true
apt:
name: git
state: present

- name: Setup gitconfig file
template:
src: gitconfig.j2
dest: "{{ home_dir }}/.gitconfig"
mode: 0644
60 changes: 60 additions & 0 deletions roles/ubuntu/git/templates/gitconfig.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[alias]
ci = commit
co = checkout
cp = cherry-pick
br = branch
sh = show
st = status
df = diff
dc = diff --cached
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
lolb = log --graph --decorate --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all --simplify-by-decoration
hist = log --pretty=format:\"%h %ad|%s%d [%an]\" --graph --date=short
lolg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
ls = ls-files
edit-unmerged = "!$EDITOR `git diff --name-only --diff-filter=U`"
# Show files ignored by git:
ign = ls-files -o -i --exclude-standard
dt = difftool
tags = for-each-ref --sort=taggerdate --format '%(refname) %(taggerdate)' refs/tags
sm = submodule update --init --recursive
[user]
name = {{ git_name }}
email = {{ git_email }}
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow
frag = magenta
old = red
new = green
[color "status"]
added = yellow
changed = green
untracked = cyan
[diff]
tool = vimdiff
[core]
abbrev = 12
pager = less -F -X
autocrlf = input
excludesfile = /home/{{ username }}/.global_ignore
editor = nvim
[pack]
windowMemory = 100m
SizeLimit = 100m
threads = 1
[sendemail]
smtpserver = /usr/bin/msmtp
[push]
default = matching
[gpg]
program = gpg
[commit]
gpgsign = true
44 changes: 44 additions & 0 deletions roles/ubuntu/ohmyzsh/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Install Zsh and git
become: true
apt:
name:
- git
- zsh
state: present

- name: Cloning oh-my-zsh
git:
repo: https://github.com/robbyrussell/oh-my-zsh
dest: "{{ home_dir }}/.oh-my-zsh"

- name: Cloning zsh-256color plugin
git:
repo: https://github.com/chrissicool/zsh-256color
dest: "{{ home_dir }}/.oh-my-zsh/custom/plugins/zsh-256color"

- name: Cloning zsh-completions
git:
repo: https://github.com/zsh-users/zsh-completions
dest: "{{ home_dir }}/.oh-my-zsh/custom/plugins/zsh-completions"

- name: Creating new ~/.zshrc from template
template:
src: "{{ zshrc_template }}"
dest: "{{ home_dir }}/.zshrc"
mode: '0644'

- name: Ensure ~/.zkbd exists
file:
path: "{{ home_dir }}/.zkbd"
state: directory

- name: Creating new ~/.zkbd/xterm-256color-:0 from template
template:
src: "{{ zkbd_template }}"
dest: "{{ home_dir }}/.zkbd/xterm-256color-:0"
mode: '0644'

- name: Set Zsh as defult shell
become: true
command: "chsh -s /bin/zsh {{ username }}"
26 changes: 26 additions & 0 deletions roles/ubuntu/ohmyzsh/templates/xterm-256color-:0.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
typeset -g -A key

key[F1]='^[OP'
key[F2]='^[OQ'
key[F3]='^[OR'
key[F4]='^[OS'
key[F5]='^[[15~'
key[F6]='^[[17~'
key[F7]='^[[18~'
key[F8]='^[[19~'
key[F9]='^[[20~'
key[F10]='^[[21~'
key[F11]='^[[23~'
key[F12]='^[[24~'
key[Backspace]='^?'
key[Insert]='^[[2~'
key[Home]='^[[H'
key[PageUp]='^[[5~'
key[Delete]='^[[3~'
key[End]='^[[F'
key[PageDown]='^[[6~'
key[Up]='^[[A'
key[Left]='^[[D'
key[Down]='^[[B'
key[Right]='^[[C'
key[Menu]=''''
101 changes: 101 additions & 0 deletions roles/ubuntu/ohmyzsh/templates/zshrc.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Path to your oh-my-zsh installation.
export ZSH=/home/{{ username }}/.oh-my-zsh

export TERM="xterm-256color"

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="half-life"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git vi-mode zsh-256color zsh-completions)

autoload -U compinit && compinit

# User configuration

source $ZSH/oh-my-zsh.sh

autoload zkbd
[[ ! -f ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$DISPLAY ]] && zkbd
source ${ZDOTDIR:-$HOME}/.zkbd/$TERM-$DISPLAY

[[ -n ${key[Backspace]} ]] && bindkey "${key[Backspace]}" backward-delete-char
[[ -n ${key[Insert]} ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[PageUp]} ]] && bindkey "${key[PageUp]}" up-line-or-history
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[PageDown]} ]] && bindkey "${key[PageDown]}" down-line-or-history
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Left]} ]] && bindkey "${key[Left]}" backward-char
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
[[ -n ${key[Right]} ]] && bindkey "${key[Right]}" forward-char

alias vim='nvim'
#
alias lsn="ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/) \
*2^(8-i));if(k)printf(\"%0o \",k);print}'"


# for people wanting to use ranger - makes the current directory stay on exit back to shell
alias ranger=". ranger"

# makes nvim the default editor
export EDITOR=/usr/bin/nvim
export VISUAL=/usr/bin/nvim

# tools
export PATH=$PATH:~/tools/bin

# tools
export PATH=$PATH:~/.local/bin

if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then
source ~/.nix-profile/etc/profile.d/nix.sh
fi

alias bashly='docker run --rm -it --user $(id -u):$(id -g) --volume "$PWD:/app" dannyben/bashly'
56 changes: 56 additions & 0 deletions roles/ubuntu/packages_base/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
- name: Install base packages
become: true
apt:
name:
- curl
- gparted
- htop
- thunderbird
- tree
- python3
- python3-pip
- python3-virtualenv
- libreoffice
- gpg
- tmux
- pre-commit
- util-linux
- openssl
state: latest

- name: Create ~/.local/bin directory if it does not exist
file:
path: "{{ home_dir }}/.local/bin"
state: directory
recurse: yes

- name: Clone markdown linter
vars:
repo_url: "https://github.com/3mdeb/hooks.git"
repo_path: "{{ home_dir }}/.config/3mdeb-hooks"
git:
repo: "{{ repo_url }}"
dest: "{{ repo_path }}"
clone: yes

- name: Create symlink for markdown.sh script
vars:
symlink_src: "{{ home_dir }}/.config/3mdeb-hooks/markdown.sh"
symlink_dest: "{{ home_dir }}/.local/bin/markdown.sh"
file:
src: "{{ symlink_src }}"
dest: "{{ symlink_dest }}"
state: link
force: yes

- name: Check the generation of GPU
become: true
shell: |
if test -d "/sys/kernel/debug/dri/1"
then
cat /sys/kernel/debug/dri/1/i915_gpu_info | grep "graphics version" | cut -d ' ' -f 3
else
cat /sys/kernel/debug/dri/0/i915_gpu_info | grep "graphics version" | cut -d ' ' -f 3
fi
register: gpu_gen

46 changes: 46 additions & 0 deletions roles/ubuntu/packages_embedded/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- name: Install embedded development packages
become: true
apt:
name:
- build-essential
- minicom
- openocd
state: latest

- name: Install kas container 3.0.2
get_url:
url: https://raw.githubusercontent.com/siemens/kas/3.0.2/kas-container
dest: "{{ home_dir }}/.local/bin/kas-container"
mode: '0755'

- name: Create the dialout group if it doesn't exist
become: true
group:
name: "dialout"
state: present

- name: Allow user to use serial device without sudo
become: true
user:
name: "{{ username }}"
groups: dialout
append: yes

- name: Check if minicom default settings exist
stat:
path: "/etc/minirc.dfl"
register: minirc_dfl_data

- name: Report if minicom default settings exist
debug:
msg: "minirc.dfl exists"
when: minirc_dfl_data.stat.exists

- name: Create minicom settings if it does not exist
become: true
copy:
dest: "/etc/minirc.dfl"
content: |
# Machine-generated file - use "minicom -s" to change parameters.
pu rtscts No
when: not minirc_dfl_data.stat.exists
12 changes: 12 additions & 0 deletions roles/ubuntu/tmux/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Install tmux
become: true
apt:
name: tmux
state: present

- name: Install ~/.tmux.conf from template
template:
src: "{{ tmux_template }}"
dest: "{{ home_dir }}/.tmux.conf"
mode: '0644'
Loading