Compare commits

...

2 commits

6 changed files with 155 additions and 119 deletions

View file

@ -1,60 +0,0 @@
# Ansible options
ansible_user ?= ephase
ansible_roles := deps
ansible_options ?= --diff
ansible_playbook ?= playbook.yml
ansible_req ?= requirements.yml
# venv options
venv_source ?= .venv
venv_cmd := . $(venv_source)/bin/activate
#Python
python_bin ?= python
pip_req ?= requirements.txt
.PHONY: inventory
inventory:
ansible-inventory --graph -i inventory.ini
deps: $(ansible_req) $(venv_source)/dep
$(shell mkdir -p $(ansible_roles))
ifeq ($(wildcard $(ansible_req)),)
$(error there is not requirements.yml file in $(ansible_data)!)
endif
$(venv_cmd) && ansible-galaxy install \
--ignore-errors \
--roles-path="$(ansible_roles)" \
--role-file="$(ansible_req)"
.PHONY: check-syntax
check-syntax: deps
$(venv_cmd) && ansible-playbook -i inventory.ini \
--syntax-check $(ansible_playbook)
.PHONY: dry-run
dry-run: deps
$(venv_cmd) && ansible-playbook -i inventory.ini \
--check $(ansible_options) $(ansible_playbook) \
-u $(ansible_user)
.PHONY: run
run: deps
$(venv_cmd) && ansible-playbook -i inventory.ini \
$(ansible_options) $(ansible_playbook) \
-u $(ansible_user)
.PHONY: clean
clean: clean-venv
[ -d $(ansible_roles) ] && rm -rf $(ansible_roles)
# venv management
$(venv_source):
$(python_bin) -m venv $(venv_source)
$(venv_source)/dep: $(venv_source) $(pip_req)
touch $(venv_source)/dep
$(venv_cmd) && pip install -r $(pip_req)
.PHONY: clean-venv
clean-venv:
[ -d $(venv_source) ] && rm -rf $(venv_source)

41
Taskfile.dist.yaml Normal file
View file

@ -0,0 +1,41 @@
---
version: "3"
set: [errexit, pipefail, nounset]
shopt: [globstar]
env:
ANSIBLE_OPTIONS: --diff --become-method=doas -K
ANSIBLE_PLAYBOOK: playbook.yml
ANSIBLE_USER: ephase
tasks:
inventory:
cmds:
- ansible-inventory --graph -i inventory.ini
dryrun:
deps:
- install:deps
cmds:
- |
ansible-playbook -i inventory.ini \
--check {{.ANSIBLE_OPTIONS}} {{.ANSIBLE_PLAYBOOK}} \
-u {{ .ANSIBLE_USER }}
run:
deps:
- install:deps
cmds:
- |
ansible-playbook -i inventory.ini \
{{.ANSIBLE_OPTIONS}} {{.ANSIBLE_PLAYBOOK}} \
-u {{.ANSIBLE_USER}}
install:deps:
internal: true
cmds:
- |
ansible-galaxy install \
--ignore-errors \
--roles-path="deps/" \
--role-file="requirements.yml"
sources:
- requirements.yaml

60
flake.lock generated Normal file
View file

@ -0,0 +1,60 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1725103162,
"narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

32
flake.nix Normal file
View file

@ -0,0 +1,32 @@
{
description = "Devshel for Ansible";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = { nixpkgs , flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in {
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
lefthook
go-task
convco
typos
ansible
];
shellHook = ''
'';
};
};
});
}

21
lefthook.yaml Normal file
View file

@ -0,0 +1,21 @@
---
skip_output: [meta, success]
no_tty: true
commit-msg:
commands:
lint:convco:
run: cat {1} | convco check --from-stdin
lint:typos:
run: cat {1} | typos -
pre-commit:
parallel: false
commands:
lint:typos:staged_files:
run: typos {staged_files}
pre-push:
parallel: false
commands:
check:nix:
tags: check
run: nix flake check

View file

@ -36,33 +36,6 @@
mode: '0640'
directory_mode: '0750'
- name: Install packages
ansible.builtin.package:
pkg:
- zsh
- pass
- vifm
- cmus
- unzip
state: present
become: true
- name: Clone my zsh repository
ansible.builtin.git:
repo: ssh://git@git.epha.se:24422/ephase/zsh_config.git
dest: '{{ ansible_user_dir }}/.config/zsh'
- name: Symlink .zshenv to ~
ansible.builtin.file:
src: '{{ ansible_user_dir }}/.config/zsh/.zshenv'
dest: '{{ ansible_user_dir }}/.zshenv'
state: link
- name: Clone my neovim repository
ansible.builtin.git:
repo: ssh://git@git.epha.se:24422/ephase/nvim_config.git
dest: '{{ ansible_user_dir }}/.config/nvim'
- name: Launch Sway related roles
hosts: all
roles:
@ -74,28 +47,9 @@
- ansible-swayidle
- ansible-waybar
- name: Configure desktop
- name: Install some stuff
hosts: all
tasks:
- name: Install packages on Arch
ansible.builtin.package:
pkg:
- arc-solid-gtk-theme
- glib2
- pinentry
- gcr
- libnotify
- opensc
- qt5-wayland
- ttf-dejavu
- ttf-fira-code
- ttf-joypixels
- ttf-liberation
- ttf-linux-libertine
- xorg-xwayland
when: ansible_distribution == "Archlinux"
become: true
- name: Install packages on Debian
ansible.builtin.package:
pkg:
@ -114,7 +68,6 @@
- pcscd
- pcsc-tools
- pulseaudio-utils
- qtwayland5
- scdaemon
- texlive
- webext-browserpass
@ -127,27 +80,16 @@
pkg:
- papirus-icon-theme
- brightnessctl
- chafa
- firefox
- foot
- foot-terminfo
- fuzzel
- fzf
- highlight
- hugo
- imv
- khal
- khard
- npm
- mpv
- ntfs-3g
- pipewire
- pipewire-pulse
- qutebrowser
- rsync
- sshfs
- udisks2
- vdirsyncer
- wireplumber
- xdg-desktop-portal-wlr
- xdg-user-dirs