Initial commit
This commit is contained in:
commit
b393bde9e5
21 changed files with 391 additions and 0 deletions
5
.ansible-lint
Normal file
5
.ansible-lint
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
parseable: true
|
||||||
|
quiet: true
|
||||||
|
skip_list:
|
||||||
|
- '501'
|
||||||
|
use_default_rules: true
|
||||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
*.retry
|
||||||
|
*.swp
|
||||||
|
|
||||||
|
.venv
|
||||||
|
.env
|
||||||
|
env
|
||||||
|
venv
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
.vault
|
||||||
|
.vaults/
|
||||||
|
vault
|
||||||
|
vaults/
|
||||||
41
.gitlab-ci.yml
Normal file
41
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
- test
|
||||||
|
|
||||||
|
cache:
|
||||||
|
key: "$CI_COMMIT_REF_SLUG"
|
||||||
|
paths:
|
||||||
|
- .cache/pip
|
||||||
|
- node_modules/
|
||||||
|
|
||||||
|
lint:
|
||||||
|
stage: lint
|
||||||
|
image: python:3.7
|
||||||
|
before_script:
|
||||||
|
- pip install ansible ansible-lint --quiet
|
||||||
|
script:
|
||||||
|
- ansible-lint playbook.yml
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- development
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
|
pretty-lint:
|
||||||
|
stage: lint
|
||||||
|
image: node:12
|
||||||
|
before_script:
|
||||||
|
- npm install
|
||||||
|
script:
|
||||||
|
- npx prettier "**/*.yml" --check
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- development
|
||||||
|
- merge_requests
|
||||||
|
|
||||||
|
syntax-test:
|
||||||
|
stage: test
|
||||||
|
image: python:3.7
|
||||||
|
before_script:
|
||||||
|
- pip install ansible ansible-lint --quiet
|
||||||
|
script:
|
||||||
|
- ansible-playbook playbook.yml --syntax-check
|
||||||
9
.prettier.json
Normal file
9
.prettier.json
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 90,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"parser": "yaml"
|
||||||
|
}
|
||||||
|
|
||||||
2
ansible.cfg
Normal file
2
ansible.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[defaults]
|
||||||
|
roles_path = ./roles
|
||||||
3
playbook.yml
Normal file
3
playbook.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
- hosts: localhost
|
||||||
|
roles:
|
||||||
|
- development
|
||||||
6
roles/.gitignore
vendored
Normal file
6
roles/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
# ignore all external roles and files in the roles dir
|
||||||
|
/*
|
||||||
|
|
||||||
|
!.gitignore
|
||||||
|
!requirements.yml
|
||||||
|
!development*/
|
||||||
17
roles/development/defaults/main.yml
Normal file
17
roles/development/defaults/main.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
packages: []
|
||||||
|
|
||||||
|
xdg_config_dir: "{{ ansible_env.HOME }}/.config"
|
||||||
|
xdg_data_dir: "{{ ansible_env.HOME }}/.local/share"
|
||||||
|
|
||||||
|
dotfiles_repo: "git@git.fudiggity.nl:sonny/dotfiles.git"
|
||||||
|
githook_repo: "git@git.fudiggity.nl:sonny/git-hooks.git"
|
||||||
|
|
||||||
|
vim_plugins:
|
||||||
|
- { url: "https://github.com/preservim/nerdtree", name: "nerdtree" }
|
||||||
|
- { url: "https://github.com/neoclide/coc.nvim", name: "coc.nvim" }
|
||||||
|
- { url: "https://github.com/sheerun/vim-polyglot", name: "vim-polygot" }
|
||||||
|
|
||||||
|
poetry_packages:
|
||||||
|
- black
|
||||||
|
- pylint
|
||||||
|
- autoflake
|
||||||
16
roles/development/files/tmux_start
Executable file
16
roles/development/files/tmux_start
Executable file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MAIN="main"
|
||||||
|
DEVELOPMENT="development"
|
||||||
|
|
||||||
|
tmux start-server
|
||||||
|
tmux new-session -ds $MAIN
|
||||||
|
tmux new-window
|
||||||
|
tmux new-window
|
||||||
|
tmux select-window -t 0
|
||||||
|
|
||||||
|
tmux new-session -ds $DEVELOPMENT
|
||||||
|
tmux new-window
|
||||||
|
tmux new-window
|
||||||
|
tmux new-window
|
||||||
|
tmux select-window -t 0
|
||||||
7
roles/development/handlers/main.yml
Normal file
7
roles/development/handlers/main.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
- name: restart ssh-agent
|
||||||
|
systemd:
|
||||||
|
name: ssh-agent
|
||||||
|
state: restarted
|
||||||
|
enabled: yes
|
||||||
|
daemon-reload: yes
|
||||||
|
scope: user
|
||||||
20
roles/development/meta/main.yml
Normal file
20
roles/development/meta/main.yml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
dependencies:
|
||||||
|
- npm
|
||||||
|
|
||||||
|
galaxy_info:
|
||||||
|
author: sonny
|
||||||
|
description: "Sets up development environment"
|
||||||
|
license: "license GPLv3"
|
||||||
|
min_ansible_version: 2.7
|
||||||
|
issue_tracker_url: "https://git.fudiggity.nl/sonny/ansible-playbooks/-/issues"
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- buster
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- focal
|
||||||
|
- name: Archlinux
|
||||||
|
galaxy_tags:
|
||||||
|
- development
|
||||||
|
- system
|
||||||
53
roles/development/tasks/dotfiles.yml
Normal file
53
roles/development/tasks/dotfiles.yml
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
- name: clone dotfiles
|
||||||
|
git:
|
||||||
|
repo: "{{ dotfiles_repo }}"
|
||||||
|
dest: "{{ ansible_env.HOME }}/dotfiles"
|
||||||
|
version: master
|
||||||
|
update: yes
|
||||||
|
|
||||||
|
- name: create dotfile folders
|
||||||
|
file:
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- "{{ xdg_config_dir }}/nvim"
|
||||||
|
- "{{ xdg_data_dir }}/nvim/site"
|
||||||
|
- "{{ xdg_config_dir }}/kitty"
|
||||||
|
|
||||||
|
- name: setup dotfiles
|
||||||
|
file:
|
||||||
|
path: "{{ item.dest }}"
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
mode: "0755"
|
||||||
|
state: link
|
||||||
|
force: true
|
||||||
|
loop:
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/nvim/init.vim",
|
||||||
|
dest: "{{ xdg_config_dir }}/nvim/init.vim",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/.vimrc",
|
||||||
|
dest: "{{ ansible_env.HOME }}/.vimrc",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/.bashrc",
|
||||||
|
dest: "{{ ansible_env.HOME }}/.bashrc",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/.profile",
|
||||||
|
dest: "{{ ansible_env.HOME }}/.profile",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/nvim/colors",
|
||||||
|
dest: "{{ xdg_data_dir }}/nvim/site/colors",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/kitty.conf",
|
||||||
|
dest: "{{ xdg_config_dir }}/kitty/kitty.conf",
|
||||||
|
}
|
||||||
|
- {
|
||||||
|
src: "{{ ansible_env.HOME }}/dotfiles/.gitignore",
|
||||||
|
dest: "{{ ansible_env.HOME }}/.gitignore",
|
||||||
|
}
|
||||||
110
roles/development/tasks/main.yml
Normal file
110
roles/development/tasks/main.yml
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
- name: load OS specific vars
|
||||||
|
include_vars: "{{ item }}"
|
||||||
|
with_first_found:
|
||||||
|
- files:
|
||||||
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
|
||||||
|
- "{{ ansible_distribution|lower }}.yml"
|
||||||
|
- "{{ ansible_os_family|lower }}.yml"
|
||||||
|
paths:
|
||||||
|
- "{{ role_path }}/vars"
|
||||||
|
|
||||||
|
- name: add gitlab to known hosts
|
||||||
|
include_role:
|
||||||
|
name: common
|
||||||
|
tasks_from: known_hosts.yml
|
||||||
|
vars:
|
||||||
|
user: "{{ ansible_user_id }}"
|
||||||
|
items:
|
||||||
|
- { domain: "{{ gitlab_domain }}", key: "{{ gitlab_host_key }}" }
|
||||||
|
|
||||||
|
- name: install packages
|
||||||
|
become: true
|
||||||
|
package:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ packages }}"
|
||||||
|
|
||||||
|
- name: create development dir
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_env.HOME }}/development"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- include_tasks: "dotfiles.yml"
|
||||||
|
|
||||||
|
- name: clone git hooks
|
||||||
|
git:
|
||||||
|
repo: "{{ githook_repo }}"
|
||||||
|
dest: "{{ ansible_env.HOME }}/development/git-hooks"
|
||||||
|
update: true
|
||||||
|
version: master
|
||||||
|
|
||||||
|
- name: clone neovim packages
|
||||||
|
git:
|
||||||
|
repo: "{{ item.url }}"
|
||||||
|
dest: "{{ xdg_data_dir }}/nvim/site/pack/default/start/{{ item.name }}"
|
||||||
|
version: master
|
||||||
|
update: true
|
||||||
|
loop: "{{ vim_plugins }}"
|
||||||
|
|
||||||
|
- include_role:
|
||||||
|
name: common
|
||||||
|
tasks_from: "poetry"
|
||||||
|
|
||||||
|
- name: coc.nvim setup
|
||||||
|
block:
|
||||||
|
- name: install coc.nvim node packages
|
||||||
|
npm:
|
||||||
|
path: "{{ xdg_data_dir }}/nvim/site/pack/default/start/coc.nvim"
|
||||||
|
state: present
|
||||||
|
global: false
|
||||||
|
- name: create default coc.nvim venv directory
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_env.HOME }}/.local/lib/coc"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
- name: copy coc pyproject.toml
|
||||||
|
template:
|
||||||
|
src: "pyproject.j2"
|
||||||
|
dest: "{{ ansible_env.HOME }}/.local/lib/coc/pyproject.toml"
|
||||||
|
mode: "0644"
|
||||||
|
force: false
|
||||||
|
- name: set default venv python version
|
||||||
|
command: "poetry env use python3"
|
||||||
|
args:
|
||||||
|
chdir: "{{ ansible_env.HOME }}/.local/lib/coc"
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.HOME }}/.local/bin:{{ ansible_env.PATH }}"
|
||||||
|
when: ansible_distribution == "Debian"
|
||||||
|
- name: install default coc.nvim python packages # noqa 301
|
||||||
|
command: "poetry install"
|
||||||
|
args:
|
||||||
|
chdir: "{{ ansible_env.HOME }}/.local/lib/coc"
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.HOME }}/.local/bin:{{ ansible_env.PATH }}"
|
||||||
|
|
||||||
|
- name: systemd user setup
|
||||||
|
block:
|
||||||
|
- name: setup systemd user service folder
|
||||||
|
file:
|
||||||
|
path: "{{ xdg_config_dir }}/systemd/user"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
- name: add ssh-agent service
|
||||||
|
template:
|
||||||
|
src: "ssh-agent.j2"
|
||||||
|
dest: "{{ ansible_env.HOME }}/.config/systemd/user/ssh-agent.service"
|
||||||
|
mode: "0644"
|
||||||
|
notify: restart ssh-agent
|
||||||
|
- name: copy tmux service
|
||||||
|
template:
|
||||||
|
src: "tmux.j2"
|
||||||
|
dest: "{{ xdg_config_dir }}/systemd/user/tmux.service"
|
||||||
|
force: false
|
||||||
|
mode: "0644"
|
||||||
|
- name: copy tmux startup script
|
||||||
|
copy:
|
||||||
|
src: "tmux_start"
|
||||||
|
dest: "{{ ansible_env.HOME }}/.local/bin/tmux_start"
|
||||||
|
mode: "0740"
|
||||||
|
force: false
|
||||||
19
roles/development/templates/pyproject.j2
Normal file
19
roles/development/templates/pyproject.j2
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
|
||||||
|
[tool.poetry]
|
||||||
|
name = "coc"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["Sonny Bakker <sonny871@hotmail.com>"]
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.7"
|
||||||
|
black = "^19.10b0"
|
||||||
|
pylint = "^2.5.3"
|
||||||
|
autoflake = "^1.3.1"
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry>=0.12"]
|
||||||
|
build-backend = "poetry.masonry.api"
|
||||||
12
roles/development/templates/ssh-agent.j2
Normal file
12
roles/development/templates/ssh-agent.j2
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=SSH key agent
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
|
||||||
|
ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
13
roles/development/templates/tmux.j2
Normal file
13
roles/development/templates/tmux.j2
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# {{ ansible_managed }} {{ ansible_date_time.time }} {{ ansible_date_time.date }}
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Tmux startup script
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=DISPLAY=:0
|
||||||
|
ExecStart=/home/sonny/.local/bin/tmux_start
|
||||||
|
Type=forking
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
9
roles/development/vars/archlinux.yml
Normal file
9
roles/development/vars/archlinux.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
packages:
|
||||||
|
- python
|
||||||
|
- poetry
|
||||||
|
- git
|
||||||
|
- vim
|
||||||
|
- neovim
|
||||||
|
- npm
|
||||||
|
- ctags
|
||||||
|
- kitty
|
||||||
10
roles/development/vars/debian-buster.yml
Normal file
10
roles/development/vars/debian-buster.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
packages:
|
||||||
|
- git
|
||||||
|
- vim
|
||||||
|
- neovim
|
||||||
|
- python3
|
||||||
|
- python3-pip
|
||||||
|
- python3-venv
|
||||||
|
- python3-setuptools
|
||||||
|
- exuberant-ctags
|
||||||
|
- apt-transport-https
|
||||||
2
roles/development/vars/main.yml
Normal file
2
roles/development/vars/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
gitlab_domain: "git.fudiggity.nl"
|
||||||
|
gitlab_host_key: "git.fudiggity.nl ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNmvcxza79T7JZMkifmquwXH/kMUqDnKs9Oob+JrRvn"
|
||||||
15
roles/development/vars/ubuntu-focal.yml
Normal file
15
roles/development/vars/ubuntu-focal.yml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
dotfiles_repo: "https://git.fudiggity.nl/sonny/dotfiles.git"
|
||||||
|
githook_repo: "https://git.fudiggity.nl/sonny/git-hooks.git"
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- git
|
||||||
|
- vim
|
||||||
|
- neovim
|
||||||
|
- python2
|
||||||
|
- python3
|
||||||
|
- python3-pip
|
||||||
|
- python3-venv
|
||||||
|
- python3-setuptools
|
||||||
|
- exuberant-ctags
|
||||||
|
- apt-transport-https
|
||||||
|
- kitty
|
||||||
8
roles/requirements.yml
Normal file
8
roles/requirements.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
- src: git+https://git.fudiggity.nl/ansible/common.git
|
||||||
|
name: common
|
||||||
|
version: master
|
||||||
|
scm: git
|
||||||
|
- src: git+https://git.fudiggity.nl/ansible/npm.git
|
||||||
|
name: npm
|
||||||
|
version: master
|
||||||
|
scm: git
|
||||||
Loading…
Add table
Add a link
Reference in a new issue