Feat: testing and multiple fixes
This commit is contained in:
parent
471d39bb86
commit
f033b7e59d
@ -4,10 +4,9 @@
|
||||
become: yes
|
||||
vars:
|
||||
users:
|
||||
- username: user
|
||||
- username: gooduser
|
||||
password: "$y$j9T$PR8GfM2MjGudOCd7hF9NP1$/qRGtuNuWaRVVGmB1A4rgtaT0MMB9IoB4fnaxW1kvf4" #plop
|
||||
shell: "/bin/zsh"
|
||||
public_key:
|
||||
config:
|
||||
giturl: "https://git.opytex.org/lafrite/dotfiles.git"
|
||||
stowing: ["nvim", "tmux", "zsh"]
|
||||
|
@ -3,14 +3,19 @@ dependency:
|
||||
name: galaxy
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: virtualbox
|
||||
platforms:
|
||||
- name: archlinux
|
||||
box: "archlinux/archlinux"
|
||||
pre_build_image: true
|
||||
- name: Debian
|
||||
box: "debian/bullseye64"
|
||||
pre_build_image: true
|
||||
provisioner:
|
||||
name: ansible
|
||||
verifier:
|
||||
name: testinfra
|
||||
options:
|
||||
sudo: true
|
||||
v: 3
|
||||
|
@ -1,9 +1,9 @@
|
||||
"""Role testing files using testinfra."""
|
||||
|
||||
import pytest
|
||||
|
||||
def test_create_users(host):
|
||||
""" Validate user creation """
|
||||
user = host.user("user")
|
||||
user = host.user("gooduser")
|
||||
assert user.exists
|
||||
assert user.uid >= 1000
|
||||
assert user.shell == "/bin/zsh"
|
||||
@ -17,7 +17,7 @@ def test_create_users(host):
|
||||
assert admin.home == f"/home/{admin.name}"
|
||||
|
||||
def test_ssh_key(host):
|
||||
user = host.user("user")
|
||||
user = host.user("gooduser")
|
||||
sshdir = host.file(user.home + "/.ssh")
|
||||
assert not sshdir.exists
|
||||
|
||||
@ -28,7 +28,7 @@ def test_ssh_key(host):
|
||||
assert autho.contains("user1@fool")
|
||||
|
||||
def test_clone_dotfiles(host):
|
||||
user = host.user("user")
|
||||
user = host.user("gooduser")
|
||||
dotfiles = host.file(user.home + "/.dotfiles")
|
||||
assert dotfiles.exists
|
||||
assert dotfiles.user == user.name
|
||||
@ -39,10 +39,10 @@ def test_clone_dotfiles(host):
|
||||
assert dotfiles.user == admin.name
|
||||
|
||||
def test_stow_config(host):
|
||||
user = host.user("user")
|
||||
nvim_config = host.files(user.home + "/.config/nvim/")
|
||||
user = host.user("gooduser")
|
||||
nvim_config = host.file(user.home + "/.config/nvim/")
|
||||
assert nvim_config.exists
|
||||
|
||||
admin = host.user("admin")
|
||||
nvim_config = host.files(admin.home + "/.config/nvim/")
|
||||
nvim_config = host.file(admin.home + "/.config/nvim/")
|
||||
assert not nvim_config.exists
|
||||
|
@ -12,3 +12,10 @@
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: true
|
||||
|
||||
- name: Install acl
|
||||
apt:
|
||||
name: acl
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: true
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
- name: Install for arch
|
||||
import_tasks: arch.yml
|
||||
when: ansible_os_family == "Archlinux"
|
||||
- name: Install os-specific packages
|
||||
include_tasks: "{{ ansible_os_family | lower }}.yml"
|
||||
|
||||
- name: Install for debian
|
||||
import_tasks: debian.yml
|
||||
@ -11,11 +10,8 @@
|
||||
ansible.builtin.git:
|
||||
repo: "{{ user.config.giturl }}"
|
||||
dest: "/home/{{ user.username }}/.dotfiles"
|
||||
|
||||
- name: user owns its dotfiles
|
||||
ansible.builtin.file:
|
||||
path: "/home/{{ user.username }}/.dotfiles"
|
||||
owner: "{{ user.username }}"
|
||||
become: true
|
||||
become_user: "{{ user.username }}"
|
||||
|
||||
- name: stow configs
|
||||
ansible.builtin.command:
|
||||
|
@ -5,12 +5,12 @@
|
||||
username: "{{ user.username }}"
|
||||
|
||||
# Create user
|
||||
- name: users -- Ensure wheel group exists
|
||||
- name: Ensure wheel group exists
|
||||
group:
|
||||
name: wheel
|
||||
state: present
|
||||
|
||||
- name: "{{ username }}: create user "
|
||||
- name: "{{ username }} -- create user "
|
||||
ansible.builtin.user:
|
||||
name: "{{ user.username }}"
|
||||
update_password: on_create
|
||||
@ -23,17 +23,15 @@
|
||||
create_home: true
|
||||
|
||||
#
|
||||
- name: "{{ username }}: Add public key"
|
||||
- name: "{{ username }} -- Add public key"
|
||||
authorized_key:
|
||||
user: "{{ user.username }}"
|
||||
key: "{{ lookup('file', item.keyfile) }}"
|
||||
state: present
|
||||
with_items: "{{ user.public_key }}"
|
||||
#when: user.public_key
|
||||
when: false
|
||||
with_items: "{{ user.public_key | default([]) }}"
|
||||
|
||||
# Dotfiles
|
||||
- name: "{{ username }}: set dotfiles"
|
||||
- name: "{{ username }} -- set dotfiles"
|
||||
import_tasks: dotfiles.yml
|
||||
|
||||
- name: "{{ username }}: gtk_settings"
|
||||
@ -41,12 +39,12 @@
|
||||
key: "{{ item.key }}"
|
||||
value: "{{ item.value }}"
|
||||
state: present
|
||||
with_items: "{{ user.gtk_settings | default('') }}"
|
||||
with_items: "{{ user.gtk_settings | default([]) }}"
|
||||
become: true
|
||||
become_user: "{{ user.username }}"
|
||||
|
||||
|
||||
- name: "{{ username }}: user owns its create_home"
|
||||
- name: "{{ username }} -- user owns its create_home"
|
||||
file:
|
||||
path: "/home/{{ user.username }}/.dotfiles"
|
||||
owner: "{{ user.username }}"
|
||||
|
@ -16,9 +16,7 @@
|
||||
repo: "https://github.com/wbthomason/packer.nvim"
|
||||
dest: "/home/{{ user.username }}/.local/share/nvim/site/pack/packer/start/packer.nvim"
|
||||
depth: 1
|
||||
become: true
|
||||
become_user: "{{ user.username }}"
|
||||
|
||||
- name: user owns packer
|
||||
ansible.builtin.file:
|
||||
path: "/home/{{ user.username }}/.local/share/nvim/site/pack/packer/start/packer.nvim"
|
||||
owner: "{{ user.username }}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user