Initial commit

main
Nils Gerstner 2 years ago
commit 69e55a3fcb

@ -0,0 +1,25 @@
#!/usr/bin/bash
SUDO="sudo"
WORKDIR="/tmp/ansible"
if [ "$(whoami)" == "root" ]; then
SUDO=""
fi
fail() {
>&2 echo "ERROR: ${1}"
>&2 echo "EXIT 1"
exit 1
}
if ! which ansible-playbook; then
${SUDO} apt update
${SUDO} apt install -y ansible || fail "Failed to install ansible!"
fi
cd ${WORKDIR} || fail "Could not change to work directory!"
ansible-playbook local.yml || fail "Failed to execute ansible playbook"
# ansible-playbook all.yml || fail "Failed to execute ansible playbook"
echo "ALL DONE"
exit 0

@ -0,0 +1,39 @@
- hosts: localhost
vars:
source_key: "./.ssh/id_rsa"
dest_key: "{{ lookup('env', 'HOME') }}/.ssh/id_rsa"
personal: "{{ lookup('env', 'HOME') }}/personal"
pre_tasks:
- name: Update Apt
become: true
apt:
force_apt_get: true
update_cache: true
state: present
tags:
- install
- neovim
- core
- golang
- dotfiles
tasks:
# - include: tasks/ssh.yml
# - include: tasks/git-setup.yml
- include: tasks/cli-tools.yml
- include: tasks/core-setup.yml
# - include: tasks/node-setup.yml
# - include: tasks/npm-packages.yml
# - include: tasks/zsh-setup.yml
# - include: tasks/slack-setup.yml
# - include: tasks/personal-projects.yml
- include: tasks/workspace-setup.yml
- include: tasks/dotfiles.yml
- include: tasks/meilisearch.yml
- include: tasks/nvim-setup.yml
# - include: tasks/brave.yml
# - include: tasks/debugger.yml
# - include: tasks/dotfiles.yml
# - include: tasks/productivity-tools.yml
# - include: tasks/lsp.yml
- include: tasks/golang-setup.yml
- include: tasks/java-setup.yml

@ -0,0 +1,7 @@
- name: Install packages (tmux, netcat, fzf, xclip, tldr, wget, curl, jq, libxml2-utils, xxd, git)
become: true
apt:
name: [ "tmux", "netcat", "fzf", "xclip", "tldr", "wget", "curl", "jq", "libxml2-utils", "xxd", "git" ]
tags:
- install
- productivity

@ -0,0 +1,34 @@
- name: Install System Packages 1 (build-essential, cmake, pkg-config, pthread)
become: true
apt:
name: ["build-essential", "cmake", "pkg-config", "libpthread-stubs0-dev"]
tags:
- install
- neovim
- core
- name: Install System Packages 2 (lua, unzip, libtool, libtool-bin, gettext)
become: true
apt:
name: [ "lua5.1", "unzip", "libtool", "libtool-bin", "gettext"]
tags:
- install
- neovim
- core
- name: Install System Packages 3 (ccache, python3-pip, dconf-editor, moreutils)
become: true
apt:
name: [ "ccache", "python3-pip", "dconf-editor", "moreutils"]
tags:
- install
- core
- name: Install Clang
become: true
apt:
name: ["clang", "clang-11", "clang-12", "clang-15", "clangd", "clangd-11", "clangd-12", "clangd-15"]
tags:
- install
- neovim
- core

@ -0,0 +1,77 @@
# tasks/dotfiles.yaml
- name: Install stow
become: true
apt:
name: [ "stow" ]
tags:
- git
- install
- dotfiles
- productivity
- name: Check if already stowed
stat:
path: ~/.stowed
register: st
tags:
- git
- install
- dotfiles
- productivity
- name: Remove existing .bashrc from home
file:
path: ~/.bashrc
state: absent
when: st.stat.islnk is not defined
tags:
- git
- install
- dotfiles
- productivity
# - name: Clone the dotfiles repository
# git:
# repo: https://gitlab.com/bhavin192/dotfiles.git
# dest: ~/dotfiles
# when: st.stat.islnk is not defined
# tags:
# - install
# - dotfiles
# - productivity
- name: Move dotfiles to dest folder
ansible.builtin.copy:
src: /tmp/ansible/dotfiles
dest: ~/
remote_src: yes
owner: root
group: root
# mode: u+rw,g-wx,o-rwx
# validate: /usr/sbin/visudo -csf %s
tags:
- git
- install
- dotfiles
- productivity
- name: Stow the dotfiles
shell: |
stow --verbose 2 --dir "${HOME}/dotfiles" --target "${HOME}" .
when: st.stat.islnk is not defined
tags:
- git
- install
- dotfiles
- productivity
- name: Set the right prompt
ansible.builtin.lineinfile:
path: ~/.bashrc
regexp: '^ENVIRONMENT=.*$'
line: ENVIRONMENT=PROD
tags:
- git
- install
- dotfiles
- productivity

@ -0,0 +1,50 @@
- name: Git personal setup email
git_config:
name: user.email
scope: global
value: "nils.gerstner@replyto.se"
tags:
- install
- productivity
- git-personal
- name: Git personal setup name
git_config:
name: user.name
scope: global
value: "ThePrimeagen"
tags:
- install
- productivity
- git-personal
- name: Git Rustin
git_config:
name: user.email
scope: global
value: "rustin.deeznuts@gmail.com"
tags:
- install
- productivity
- git-rustin
- name: Git personal setup name
git_config:
name: user.name
scope: global
value: "RustLover69"
tags:
- install
- productivity
- git-rustin
- name: Netflix
git_config:
name: user.email
scope: global
value: "mpaulson@netflix.com"
tags:
- git-netflix
- name: Git personal setup name
git_config:
name: user.name
scope: global
value: "mpaulson"
tags:
- git-netflix

@ -0,0 +1,7 @@
- name: Install golang
become: true
apt:
name: [ "golang" ]
tags:
- install
- golang

@ -0,0 +1,48 @@
- name: Install OpenJDK 17
become: true
apt:
name: [ "openjdk-17-jdk", "openjdk-17-jre" ]
tags:
- install
- productivity
- java
- name: Get Java java alternative
shell: "update-alternatives --list java |grep -m1 '^/.*/java-17-openjdk.*/java$'"
register: javaversion
tags:
- install
- productivity
- java
- name: Set java version
shell: "update-alternatives --set java {{javaversion.stdout }}"
tags:
- install
- productivity
- java
when: javaversion is defined
- name: Get JAVA_HOME for current version
shell: 'dirname $(dirname $(readlink -f $(which javac)))'
register: javahome
tags:
- install
- productivity
- java
- name: Set JAVA_HOME
ansible.builtin.lineinfile:
path: ~/.bashrc
regexp: '^\s*export *JAVA_HOME=.*$'
line: export JAVA_HOME={{ javahome.stdout }}
tags:
- install
- productivity
- java
when: javahome is defined
# JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

@ -0,0 +1,20 @@
- name: Download meilisearch
ansible.builtin.get_url:
url: https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-{{ansible_architecture}}
# url: https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-aarch64
dest: /usr/local/bin/meilisearch
mode: '777'
tags:
- install
- notes
- name: Meilisearch version
shell: /usr/local/bin/meilisearch --version
tags:
- install
- notes
- name: Start meilisearch
shell: "/usr/local/bin/meilisearch --http-addr 0.0.0.0:7700 >/dev/null 2>&1 &"
tags:
- notes

@ -0,0 +1,64 @@
# - name: Neovim folder exists
# stat:
# path: ~/neovim
# register: nvim_folder
# tags:
# - install
# - neovim
# - name: Remove neovim
# shell: rm -rf ~/neovim
# tags:
# - install
# - neovim
- name: Clone Neovim
ansible.builtin.git:
repo: 'https://github.com/neovim/neovim.git'
dest: "{{ lookup('env', 'HOME') }}/neovim"
update: true
force: true
tags:
- install
- neovim
# when: nvim_folder.stat.exists
#
# - name: Clone Neovim
# ansible.builtin.git:
# repo: 'https://github.com/neovim/neovim.git'
# dest: "{{ lookup('env', 'HOME') }}/neovim"
# tags:
# - install
# - neovim
# when: nvim_folder.stat.exists
- name: Build neovim
shell: "cd {{ lookup('env', 'HOME') }}/neovim && make -j 20"
tags:
- install
- neovim
- name: Install neovim
become: true
shell: "cd {{ lookup('env', 'HOME') }}/neovim && make install"
tags:
- install
- neovim
- name: Neovim Plugin Development 1
become: true
apt: name=luarocks
tags:
- install
- neovim
- name: Neovim Lazy update
shell: "nvim --headless '+Lazy sync' +q"
tags:
- install
- neovim
- name: Neovim TSUpdate
shell: "nvim --headless '+TSUpdateSync clean' +q"
tags:
- install
- neovim
# - name: Neovim Plugin Development 2 luacheck
# become: true
# shell: luarocks install luacheck
# tags:
# - install
# - neovim

@ -0,0 +1,17 @@
- name: Create Main Code folder
file:
path: "{{ item }}"
state: directory
loop:
- ~/Documents
- ~/Documents/Code
- ~/Documents/Code/BOLIDEN
- ~/Documents/Code/GERSTNER
- ~/Documents/Code/REPLYTO
- ~/Documents/Code/RISE
- ~/Documents/Code/VOLVOCARS
- ~/Documents/Code/VOLVOFINANS
tags:
- git
- productivity
- dotfiles
Loading…
Cancel
Save