Feat: dotfiles deployement tested and works
This commit is contained in:
@@ -1,8 +1,43 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
users:
|
||||
- username: user1
|
||||
config2stow: ["nvim", "tmux", "zsh"]
|
||||
password: "$y$j9T$PR8GfM2MjGudOCd7hF9NP1$/qRGtuNuWaRVVGmB1A4rgtaT0MMB9IoB4fnaxW1kvf4" #plop
|
||||
- username: user2
|
||||
password: "$y$j9T$PR8GfM2MjGudOCd7hF9NP1$/qRGtuNuWaRVVGmB1A4rgtaT0MMB9IoB4fnaxW1kvf4" #plop
|
||||
config2stow: ["nvim", "tmux"]
|
||||
|
||||
pre_tasks:
|
||||
- name: update_cache for arch
|
||||
pacman:
|
||||
update_cache: yes
|
||||
become: yes
|
||||
when: ansible_os_family == "Archlinux"
|
||||
|
||||
- name: update_cache for debian
|
||||
apt:
|
||||
update_cache: yes
|
||||
become: yes
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Create user
|
||||
ansible.builtin.user:
|
||||
name: "{{ item.username }}"
|
||||
password: "{{ item.password }}" #plop
|
||||
state: present
|
||||
with_items: "{{ users }}"
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: "Include dotfiles"
|
||||
include_role:
|
||||
name: "dotfiles"
|
||||
become: true
|
||||
vars:
|
||||
username: "{{ user.username }}"
|
||||
config2stow: "{{ user.config2stow }}"
|
||||
loop: "{{ users }}"
|
||||
loop_control:
|
||||
loop_var: user
|
||||
|
||||
@@ -12,3 +12,5 @@ provisioner:
|
||||
name: ansible
|
||||
verifier:
|
||||
name: testinfra
|
||||
options:
|
||||
sudo: true
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
"""Role testing files using testinfra."""
|
||||
|
||||
USER1 = "user1"
|
||||
USER2 = "user2"
|
||||
|
||||
def test_stow_installed(host):
|
||||
stow = host.package("stow")
|
||||
assert stow.is_installed
|
||||
|
||||
def test_dotfile_cloned(host):
|
||||
homepath = host.run("pwd").stdout[:-1]
|
||||
dotfiles = host.file(homepath + "/.dotfiles")
|
||||
dotfiles = host.file(f"/home/{USER1}/.dotfiles")
|
||||
assert dotfiles.exists
|
||||
assert dotfiles.user == USER1
|
||||
|
||||
dotfiles = host.file(f"/home/{USER2}/.dotfiles")
|
||||
assert dotfiles.exists
|
||||
assert dotfiles.user == USER2
|
||||
|
||||
def test_dotfile_stowed(host):
|
||||
homepath = host.run("pwd").stdout[:-1]
|
||||
homepath = f"/home/{USER1}"
|
||||
nvim = host.file(homepath + "/.config/nvim/")
|
||||
assert nvim.exists
|
||||
tmux = host.file(homepath + "/.tmux/")
|
||||
@@ -21,3 +27,13 @@ def test_dotfile_stowed(host):
|
||||
zsh = host.file(homepath + "/.config/zsh/")
|
||||
assert zsh.exists
|
||||
|
||||
homepath = f"/home/{USER2}"
|
||||
nvim = host.file(homepath + "/.config/nvim/")
|
||||
assert nvim.exists
|
||||
tmux = host.file(homepath + "/.tmux/")
|
||||
assert tmux.exists
|
||||
zshenv = host.file(homepath + "/.zshenv")
|
||||
assert not zshenv.exists
|
||||
zsh = host.file(homepath + "/.config/zsh/")
|
||||
assert not zsh.exists
|
||||
|
||||
|
||||
Reference in New Issue
Block a user