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