Use simpler file structure

This commit is contained in:
Sonny Bakker 2021-01-29 21:47:47 +01:00
parent 633a61b6f2
commit af7211830d
24 changed files with 180 additions and 225 deletions

View file

@ -1,5 +0,0 @@
parseable: true
quiet: true
skip_list:
- '501'
use_default_rules: true

2
.gitignore vendored
View file

@ -12,3 +12,5 @@ node_modules/
.vaults/
vault
vaults/
roles/

View file

@ -3,40 +3,24 @@ stages:
- test
cache:
key: "$CI_COMMIT_REF_SLUG"
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
- npm install prettier --no-save
script:
- npx prettier "**/*.yml" --check
only:
refs:
- development
- merge_requests
- npx prettier '**/*.yml' --check
syntax-test:
stage: test
image: python:3.7
before_script:
- pip install ansible ansible-lint --quiet
- ansible-galaxy install -r roles/requirements.yml
- pip install ansible --quiet
- ansible-galaxy install -r requirements.yml
script:
- ansible-playbook playbook.yml --syntax-check

View file

@ -1,9 +0,0 @@
{
"singleQuote": true,
"printWidth": 90,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"parser": "yaml"
}

5
.prettierrc.yml Normal file
View file

@ -0,0 +1,5 @@
singleQuote: true
printWidth: 90
tabWidth: 2
useTabs: false
bracketSpacing: true

View file

@ -1,2 +1,5 @@
[defaults]
roles_path = ./roles
[privilege_escalation]
become_ask_pass = True

View file

@ -1,3 +1,37 @@
- hosts: localhost
pre_tasks:
- 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:
- '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 }}'
roles:
- development
- common
- npm
tasks:
- import_tasks: 'tasks/main.yml'
- include_role:
name: common
tasks_from: 'poetry.yml'
- import_tasks: 'tasks/dotfiles.yml'
- import_tasks: 'tasks/coc.yml'
vars_files:
- 'vars/main.yml'

6
roles/.gitignore vendored
View file

@ -1,6 +0,0 @@
# ignore all external roles and files in the roles dir
/*
!.gitignore
!requirements.yml
!development*/

View file

@ -1,17 +0,0 @@
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

View file

@ -1 +0,0 @@

View file

@ -1,20 +0,0 @@
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

View file

@ -1,33 +0,0 @@
- 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 }}"

View file

@ -1,53 +0,0 @@
- 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",
}

View file

@ -1,54 +0,0 @@
- 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"
- include_tasks: coc.yml

View file

@ -1,2 +0,0 @@
gitlab_domain: "git.fudiggity.nl"
gitlab_host_key: "git.fudiggity.nl ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNmvcxza79T7JZMkifmquwXH/kMUqDnKs9Oob+JrRvn"

33
tasks/coc.yml Normal file
View file

@ -0,0 +1,33 @@
- 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 }}'

52
tasks/dotfiles.yml Normal file
View file

@ -0,0 +1,52 @@
- 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 }}'
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',
}

20
tasks/main.yml Normal file
View file

@ -0,0 +1,20 @@
- name: create development dir
file:
path: '{{ ansible_env.HOME }}/development'
state: directory
mode: '0755'
- 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 }}'

View file

@ -7,5 +7,5 @@ packages:
- npm
- ctags
- kitty
- docker # TODO add tasks
- docker
- docker-compose

22
vars/main.yml Normal file
View file

@ -0,0 +1,22 @@
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
gitlab_domain: 'git.fudiggity.nl'
gitlab_host_key: 'git.fudiggity.nl ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNmvcxza79T7JZMkifmquwXH/kMUqDnKs9Oob+JrRvn'
skip_common_setup: true

View file

@ -1,5 +1,5 @@
dotfiles_repo: "https://git.fudiggity.nl/sonny/dotfiles.git"
githook_repo: "https://git.fudiggity.nl/sonny/git-hooks.git"
dotfiles_repo: 'https://git.fudiggity.nl/sonny/dotfiles.git'
githook_repo: 'https://git.fudiggity.nl/sonny/git-hooks.git'
packages:
- git