Compare commits
No commits in common. "docs" and "main" have entirely different histories.
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# ---> Ansible
|
||||||
|
*.retry
|
||||||
|
plugins
|
||||||
|
library
|
||||||
|
|
||||||
|
# ---> Python
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
7
.markdownlint.yml
Normal file
7
.markdownlint.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
default: True
|
||||||
|
MD013: False
|
||||||
|
MD041: False
|
||||||
|
MD024: False
|
||||||
|
MD004:
|
||||||
|
style: dash
|
1
.prettierignore
Normal file
1
.prettierignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
LICENSE
|
47
.woodpecker/docs.yaml
Normal file
47
.woodpecker/docs.yaml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: generate
|
||||||
|
image: quay.io/thegeeklab/ansible-doctor
|
||||||
|
environment:
|
||||||
|
ANSIBLE_DOCTOR_EXCLUDE_FILES: "['molecule/']"
|
||||||
|
ANSIBLE_DOCTOR_RENDERER__FORCE_OVERWRITE: "true"
|
||||||
|
ANSIBLE_DOCTOR_LOGGING__LEVEL: info
|
||||||
|
ANSIBLE_DOCTOR_ROLE__NAME: ${CI_REPO_NAME}
|
||||||
|
ANSIBLE_DOCTOR_TEMPLATE__NAME: readme
|
||||||
|
|
||||||
|
- name: format
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- prettier -w README.md
|
||||||
|
|
||||||
|
- name: diff
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- git diff --color=always README.md
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: quay.io/thegeeklab/wp-git-action
|
||||||
|
settings:
|
||||||
|
action:
|
||||||
|
- commit
|
||||||
|
- push
|
||||||
|
author_email: ci-bot@rknet.org
|
||||||
|
author_name: ci-bot
|
||||||
|
branch: main
|
||||||
|
message: "[skip ci] automated docs update"
|
||||||
|
netrc_machine: gitea.rknet.org
|
||||||
|
netrc_password:
|
||||||
|
from_secret: gitea_token
|
||||||
|
when:
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- test
|
30
.woodpecker/lint.yaml
Normal file
30
.woodpecker/lint.yaml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: ansible-lint
|
||||||
|
image: quay.io/thegeeklab/ansible-dev-tools:1
|
||||||
|
commands:
|
||||||
|
- ansible-lint
|
||||||
|
environment:
|
||||||
|
FORCE_COLOR: "1"
|
||||||
|
|
||||||
|
- name: python-format
|
||||||
|
image: docker.io/python:3.12
|
||||||
|
commands:
|
||||||
|
- pip install -qq ruff
|
||||||
|
- ruff format --check --diff .
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
||||||
|
|
||||||
|
- name: python-lint
|
||||||
|
image: docker.io/python:3.12
|
||||||
|
commands:
|
||||||
|
- pip install -qq ruff
|
||||||
|
- ruff check .
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
26
.woodpecker/notify.yml
Normal file
26
.woodpecker/notify.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
runs_on: [success, failure]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: matrix
|
||||||
|
image: quay.io/thegeeklab/wp-matrix
|
||||||
|
settings:
|
||||||
|
homeserver:
|
||||||
|
from_secret: matrix_homeserver
|
||||||
|
room_id:
|
||||||
|
from_secret: matrix_room_id
|
||||||
|
user_id:
|
||||||
|
from_secret: matrix_user_id
|
||||||
|
access_token:
|
||||||
|
from_secret: matrix_access_token
|
||||||
|
when:
|
||||||
|
- status: [failure]
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- docs
|
24
.woodpecker/test.yaml
Normal file
24
.woodpecker/test.yaml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- &molecule_base
|
||||||
|
image: quay.io/thegeeklab/ansible-dev-tools:1
|
||||||
|
group: molecule
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
||||||
|
HCLOUD_TOKEN:
|
||||||
|
from_secret: molecule_hcloud_token
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: molecule-default
|
||||||
|
<<: *molecule_base
|
||||||
|
commands:
|
||||||
|
- molecule test -s default
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- lint
|
20
.yamllint
Normal file
20
.yamllint
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
rules:
|
||||||
|
truthy:
|
||||||
|
allowed-values: ["True", "False"]
|
||||||
|
comments:
|
||||||
|
min-spaces-from-content: 1
|
||||||
|
comments-indentation: False
|
||||||
|
line-length: disable
|
||||||
|
braces:
|
||||||
|
min-spaces-inside: 0
|
||||||
|
max-spaces-inside: 1
|
||||||
|
brackets:
|
||||||
|
min-spaces-inside: 0
|
||||||
|
max-spaces-inside: 0
|
||||||
|
indentation: enable
|
||||||
|
octal-values:
|
||||||
|
forbid-implicit-octal: True
|
||||||
|
forbid-explicit-octal: True
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||||
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||||
|
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,15 +1,11 @@
|
||||||
---
|
# xoxys.users
|
||||||
title: users
|
|
||||||
type: docs
|
|
||||||
---
|
|
||||||
|
|
||||||
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.users)
|
[![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.users/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.users)
|
||||||
[![Build Status](https://img.shields.io/drone/build/ansible/xoxys.users?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.users)
|
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.users/src/branch/main/LICENSE)
|
||||||
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.users/src/branch/main/LICENSE)
|
|
||||||
|
|
||||||
Manage users and default bash environment.
|
Manage users and default bash environment.
|
||||||
|
|
||||||
<!--more-->
|
## Table of content
|
||||||
|
|
||||||
- [Requirements](#requirements)
|
- [Requirements](#requirements)
|
||||||
- [Default Variables](#default-variables)
|
- [Default Variables](#default-variables)
|
||||||
|
@ -24,12 +20,14 @@ Manage users and default bash environment.
|
||||||
- [users_password_pam_minlen](#users_password_pam_minlen)
|
- [users_password_pam_minlen](#users_password_pam_minlen)
|
||||||
- [users_password_pam_retry](#users_password_pam_retry)
|
- [users_password_pam_retry](#users_password_pam_retry)
|
||||||
- [Dependencies](#dependencies)
|
- [Dependencies](#dependencies)
|
||||||
|
- [License](#license)
|
||||||
|
- [Author](#author)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Minimum Ansible version: `2.1`
|
- Minimum Ansible version: `2.10`
|
||||||
|
|
||||||
## Default Variables
|
## Default Variables
|
||||||
|
|
||||||
|
@ -138,8 +136,14 @@ users_password_pam_minlen: 14
|
||||||
users_password_pam_retry: 3
|
users_password_pam_retry: 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
||||||
|
|
||||||
|
## Author
|
||||||
|
|
||||||
|
[Robert Kaussow](https://gitea.rknet.org/xoxys)
|
35
defaults/main.yml
Normal file
35
defaults/main.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
users_default_users: []
|
||||||
|
# @var users_default_users:example: >
|
||||||
|
# users_default_users:
|
||||||
|
# - name: admin
|
||||||
|
# groups:
|
||||||
|
# - wheel
|
||||||
|
# password: "secure"
|
||||||
|
# sshkeys: |
|
||||||
|
# "ssh-ed25519 AAAA..."
|
||||||
|
# shell: /bin/bash
|
||||||
|
# @end
|
||||||
|
|
||||||
|
users_default_groups: []
|
||||||
|
|
||||||
|
users_global_umask: "022"
|
||||||
|
users_pass_min_day: 1
|
||||||
|
users_default_inactive: -1
|
||||||
|
|
||||||
|
users_password_pam_retry: 3
|
||||||
|
users_password_pam_minlen: 14
|
||||||
|
users_password_pam_minclass: 4
|
||||||
|
|
||||||
|
users_global_bash_aliases:
|
||||||
|
- alias: "ll"
|
||||||
|
command: "ls -lh"
|
||||||
|
- alias: "la"
|
||||||
|
command: "ls -lha"
|
||||||
|
|
||||||
|
users_bash_bashrc_overrides: []
|
||||||
|
# @var users_bash_bashrc_overrides:example: >
|
||||||
|
# users_bash_bashrc_overrides:
|
||||||
|
# - /etc/skel/.bashrc
|
||||||
|
# - /root/.bashrc
|
||||||
|
# @end
|
138
index.md
138
index.md
|
@ -1,138 +0,0 @@
|
||||||
---
|
|
||||||
title: users
|
|
||||||
type: docs
|
|
||||||
---
|
|
||||||
|
|
||||||
[![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.users) [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.users?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.users) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.users/src/branch/main/LICENSE)
|
|
||||||
|
|
||||||
Manage users and default bash environment.
|
|
||||||
|
|
||||||
<!--more-->
|
|
||||||
|
|
||||||
- [Default Variables](#default-variables)
|
|
||||||
- [users_bash_bashrc_overrides](#users_bash_bashrc_overrides)
|
|
||||||
- [users_default_groups](#users_default_groups)
|
|
||||||
- [users_default_inactive](#users_default_inactive)
|
|
||||||
- [users_default_users](#users_default_users)
|
|
||||||
- [users_global_bash_aliases](#users_global_bash_aliases)
|
|
||||||
- [users_global_umask](#users_global_umask)
|
|
||||||
- [users_pass_min_day](#users_pass_min_day)
|
|
||||||
- [users_password_pam_minclass](#users_password_pam_minclass)
|
|
||||||
- [users_password_pam_minlen](#users_password_pam_minlen)
|
|
||||||
- [users_password_pam_retry](#users_password_pam_retry)
|
|
||||||
- [Dependencies](#dependencies)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Default Variables
|
|
||||||
|
|
||||||
### users_bash_bashrc_overrides
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_bash_bashrc_overrides: []
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example usage
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_bash_bashrc_overrides:
|
|
||||||
- /etc/skel/.bashrc
|
|
||||||
- /root/.bashrc
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_default_groups
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_default_groups: []
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_default_inactive
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_default_inactive: -1
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_default_users
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_default_users: []
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Example usage
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_default_users:
|
|
||||||
- name: admin
|
|
||||||
groups:
|
|
||||||
- wheel
|
|
||||||
password: "secure"
|
|
||||||
sshkeys: |
|
|
||||||
"ssh-ed25519 AAAA..."
|
|
||||||
shell: /bin/bash
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_global_bash_aliases
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_global_bash_aliases:
|
|
||||||
- alias: ll
|
|
||||||
command: ls -lh
|
|
||||||
- alias: la
|
|
||||||
command: ls -lha
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_global_umask
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_global_umask: '022'
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_pass_min_day
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_pass_min_day: 1
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_password_pam_minclass
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_password_pam_minclass: 4
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_password_pam_minlen
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_password_pam_minlen: 14
|
|
||||||
```
|
|
||||||
|
|
||||||
### users_password_pam_retry
|
|
||||||
|
|
||||||
#### Default value
|
|
||||||
|
|
||||||
```YAML
|
|
||||||
users_password_pam_retry: 3
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
|
||||||
|
|
||||||
None.
|
|
22
meta/main.yml
Normal file
22
meta/main.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
# @meta author:value: [Robert Kaussow](https://gitea.rknet.org/xoxys)
|
||||||
|
author: Robert Kaussow <mail@thegeeklab.de>
|
||||||
|
namespace: xoxys
|
||||||
|
role_name: users
|
||||||
|
# @meta description: >
|
||||||
|
# [![Build Status](https://ci.rknet.org/api/badges/ansible/xoxys.users/status.svg)](https://ci.rknet.org/repos/ansible/xoxys.users)
|
||||||
|
# [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?label=license)](https://gitea.rknet.org/ansible/xoxys.users/src/branch/main/LICENSE)
|
||||||
|
#
|
||||||
|
# Manage users and default bash environment.
|
||||||
|
# @end
|
||||||
|
description: Manage users and default bash environment
|
||||||
|
license: MIT
|
||||||
|
min_ansible_version: "2.10"
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- "9"
|
||||||
|
galaxy_tags:
|
||||||
|
- user
|
||||||
|
dependencies: []
|
14
molecule/default/converge.yml
Normal file
14
molecule/default/converge.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
vars:
|
||||||
|
users_global_umask: "027"
|
||||||
|
users_default_users:
|
||||||
|
- name: demouser
|
||||||
|
groups:
|
||||||
|
- wheel
|
||||||
|
shell: /bin/sh
|
||||||
|
users_default_groups:
|
||||||
|
- demogroup
|
||||||
|
roles:
|
||||||
|
- role: xoxys.users
|
17
molecule/default/molecule.yml
Normal file
17
molecule/default/molecule.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: molecule_hetznercloud
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
options:
|
||||||
|
role-file: requirements.yml
|
||||||
|
requirements-file: requirements.yml
|
||||||
|
platforms:
|
||||||
|
- name: "rocky9-users"
|
||||||
|
server_type: "cx22"
|
||||||
|
image: "rocky-9"
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
log: False
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
11
molecule/default/prepare.yml
Normal file
11
molecule/default/prepare.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: False
|
||||||
|
tasks:
|
||||||
|
- name: Bootstrap Python for Ansible
|
||||||
|
ansible.builtin.raw: |
|
||||||
|
command -v python3 python ||
|
||||||
|
((test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
|
||||||
|
echo "Warning: Python not boostrapped due to unknown platform.")
|
||||||
|
changed_when: False
|
19
molecule/default/tests/test_default.py
Normal file
19
molecule/default/tests/test_default.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||||
|
).get_hosts("all")
|
||||||
|
|
||||||
|
|
||||||
|
def test_users_create_user(host):
|
||||||
|
user = host.user("demouser")
|
||||||
|
|
||||||
|
assert user.name == "demouser"
|
||||||
|
assert user.shell == "/bin/sh"
|
||||||
|
assert "wheel" in user.groups
|
||||||
|
|
||||||
|
|
||||||
|
def test_users_create_group(host):
|
||||||
|
assert host.group("demogroup").exists
|
17
pyproject.toml
Normal file
17
pyproject.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[tool.ruff]
|
||||||
|
exclude = [".git", "__pycache__"]
|
||||||
|
|
||||||
|
line-length = 99
|
||||||
|
indent-width = 4
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
ignore = ["W191", "E111", "E114", "E117", "S101", "S105"]
|
||||||
|
select = ["F", "E", "I", "W", "S"]
|
||||||
|
|
||||||
|
[tool.ruff.format]
|
||||||
|
quote-style = "double"
|
||||||
|
indent-style = "space"
|
||||||
|
line-ending = "lf"
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
filterwarnings = ["ignore::FutureWarning", "ignore::DeprecationWarning"]
|
6
requirements.yml
Normal file
6
requirements.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: community.general
|
||||||
|
- name: ansible.posix
|
||||||
|
|
||||||
|
roles: []
|
17
tasks/bash.yml
Normal file
17
tasks/bash.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
- name: Override default .bashrc
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: etc/bashrc.j2
|
||||||
|
dest: "{{ item }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
loop: "{{ users_bash_bashrc_overrides }}"
|
||||||
|
|
||||||
|
- name: Setup custom bash profile
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: etc/profile.d/custom.sh.j2
|
||||||
|
dest: /etc/profile.d/custom.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
36
tasks/main.yml
Normal file
36
tasks/main.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
- name: Include OS specific vars
|
||||||
|
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
|
||||||
|
vars:
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_lsb.id | default('') | lower }}.yml"
|
||||||
|
- "{{ ansible_os_family | lower }}.yml"
|
||||||
|
paths:
|
||||||
|
- "vars"
|
||||||
|
errors: "ignore"
|
||||||
|
- name: Ensure secure defaults
|
||||||
|
ansible.builtin.include_tasks: security.yml
|
||||||
|
- name: Configure bash
|
||||||
|
ansible.builtin.include_tasks: bash.yml
|
||||||
|
- name: Configure users
|
||||||
|
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
|
||||||
|
vars:
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "users_{{ ansible_lsb.id | default('') | lower }}.yml"
|
||||||
|
- "users_{{ ansible_os_family | lower }}.yml"
|
||||||
|
- "users_default.yml"
|
||||||
|
paths:
|
||||||
|
- "tasks"
|
||||||
|
|
||||||
|
- name: Set authorized_key for ssh users
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: "{{ item.name }}"
|
||||||
|
key: "{{ item.sshkeys }}"
|
||||||
|
exclusive: True
|
||||||
|
state: present
|
||||||
|
loop: "{{ users_default_users }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
||||||
|
when: item.sshkeys is defined
|
54
tasks/security.yml
Normal file
54
tasks/security.yml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
- name: Stat umask files
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- /etc/bashrc
|
||||||
|
- /etc/csh.cshrc
|
||||||
|
- /etc/profile
|
||||||
|
register: __users_umask_files
|
||||||
|
|
||||||
|
- name: Stat pwquality files
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/etc/security/pwquality.conf"
|
||||||
|
register: __users_pwquality_file
|
||||||
|
|
||||||
|
- name: Set global umask
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: "{{ item }}"
|
||||||
|
regexp: '(?i)^(?P<umask>\s+UMASK\s+).+'
|
||||||
|
replace: \g<umask>{{ users_global_umask }}
|
||||||
|
loop: "{{ __users_umask_files | json_query('results[?stat.exists].item') }}"
|
||||||
|
|
||||||
|
- name: Set umask in /etc/login.defs
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/login.defs
|
||||||
|
regexp: '^(?P<umask>UMASK\s+).+'
|
||||||
|
line: \g<umask>{{ users_global_umask }}
|
||||||
|
backrefs: True
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Enforce minimum password lifetime
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/login.defs
|
||||||
|
regexp: '^(?P<passmin>PASS_MIN_DAYS\s+).+'
|
||||||
|
line: \g<passmin>{{ users_pass_min_day }}
|
||||||
|
backrefs: True
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Set default account expiration after inactivity
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/default/useradd
|
||||||
|
regexp: "^(?P<inactive>INACTIVE=).+"
|
||||||
|
line: \g<inactive>{{ users_default_inactive }}
|
||||||
|
backrefs: True
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Set pwquality if available
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: etc/security/pwquality.conf.j2
|
||||||
|
dest: /etc/security/pwquality.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when: __users_pwquality_file.stat.exists | bool
|
18
tasks/users_default.yml
Normal file
18
tasks/users_default.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
- name: Create groups
|
||||||
|
ansible.builtin.group:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
loop: "{{ users_default_groups }}"
|
||||||
|
|
||||||
|
- name: Create users
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
groups: "{{ item.groups | default([]) | join(',') or omit }}"
|
||||||
|
append: "{{ True if (item.groups | default([]) | length > 0) else False }}"
|
||||||
|
password: "{{ item.password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) if item.password is defined else '*' }}"
|
||||||
|
password_expire_min: "{{ item.password_expire_min | default(users_pass_min_day) }}"
|
||||||
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||||
|
loop: "{{ users_default_users }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
22
tasks/users_univention.yml
Normal file
22
tasks/users_univention.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
# use system users and groups to prevent duplicate ids
|
||||||
|
# this is a workaround because udm_user not working
|
||||||
|
- name: Create groups
|
||||||
|
ansible.builtin.group:
|
||||||
|
name: "{{ item }}"
|
||||||
|
system: "yes"
|
||||||
|
state: present
|
||||||
|
loop: "{{ users_default_groups }}"
|
||||||
|
|
||||||
|
- name: Create users
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
groups: "{{ item.groups | default([]) | join(',') or omit }}"
|
||||||
|
append: "{{ True if (item.groups | default([]) | length > 0) else False }}"
|
||||||
|
password: "{{ item.password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) if item.password is defined else '*' }}"
|
||||||
|
password_expire_min: "{{ item.password_expire_min | default(users_pass_min_day) }}"
|
||||||
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||||
|
system: "yes"
|
||||||
|
loop: "{{ users_default_users }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.name }}"
|
17
templates/etc/bashrc.j2
Normal file
17
templates/etc/bashrc.j2
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#jinja2: lstrip_blocks: True
|
||||||
|
{{ ansible_managed | comment }}
|
||||||
|
# Source global definitions
|
||||||
|
if [ -f {{ __users_bash_system_bashrc }} ]; then
|
||||||
|
. {{ __users_bash_system_bashrc }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
{% if ansible_os_family | lower == "debian" %}
|
||||||
|
if [ -f /etc/profile ]; then
|
||||||
|
. /etc/profile
|
||||||
|
fi
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
# Uncomment the following line if you don't like systemctl's auto-paging feature:
|
||||||
|
# export SYSTEMD_PAGER=
|
||||||
|
|
||||||
|
# User specific aliases and functions
|
14
templates/etc/profile.d/custom.sh.j2
Normal file
14
templates/etc/profile.d/custom.sh.j2
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#jinja2:lstrip_blocks: True
|
||||||
|
{{ ansible_managed | comment }}
|
||||||
|
# are we an interactive shell?
|
||||||
|
if [ "$PS1" ]; then
|
||||||
|
if [[ ${EUID} == 0 ]] ; then
|
||||||
|
PS1='\[$(tput bold)\]\[\033[38;5;9m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h [\w] \$ \[$(tput sgr0)\]'
|
||||||
|
else
|
||||||
|
PS1='\[$(tput bold)\]\[\033[38;5;12m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\]@\h [\w] \$ \[$(tput sgr0)\]'
|
||||||
|
fi
|
||||||
|
|
||||||
|
{% for item in users_global_bash_aliases %}
|
||||||
|
alias {{ item.alias }}='{{ item.command }}'
|
||||||
|
{% endfor %}
|
||||||
|
fi
|
5
templates/etc/security/pwquality.conf.j2
Normal file
5
templates/etc/security/pwquality.conf.j2
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#jinja2:lstrip_blocks: True
|
||||||
|
{{ ansible_managed | comment }}
|
||||||
|
retry = {{ users_password_pam_retry }}
|
||||||
|
minlen = {{ users_password_pam_minlen }}
|
||||||
|
minclass = {{ users_password_pam_minclass }}
|
2
vars/debian.yml
Normal file
2
vars/debian.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
__users_bash_system_bashrc: /etc/bash.bashrc
|
2
vars/redhat.yml
Normal file
2
vars/redhat.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
__users_bash_system_bashrc: /etc/bashrc
|
Loading…
Reference in New Issue
Block a user