Skip to content

Commit 40f412a

Browse files
committed
xmpp2: set up the users via Ansible
1 parent 652bede commit 40f412a

File tree

9 files changed

+86
-5
lines changed

9 files changed

+86
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The license indication in the project's sources is compliant with the [REUSE spe
4141
[codingteam.org.ru]: https://codingteam.org.ru
4242
[devops]: https://ru.wikipedia.org/wiki/DevOps
4343
[docs.license]: LICENSES/MIT.txt
44-
[host.xmpp2]: xmpp2/HOST.md
44+
[host.xmpp2]: xmpp2/README.md
4545
[hosts/cthulhu-3]: cthulhu-3/Host.md
4646
[hosts/ctor]: ctor/Host.md
4747
[hosts/omnissiah]: omnissiah/Host.md

xmpp2/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
hosts.ini
6+
7+
vars/vars.yml

xmpp2/HOST.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

xmpp2/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
3+
4+
SPDX-License-Identifier: MIT
5+
-->
6+
7+
xmpp2 host
8+
==========
9+
- **Provider:** Digital Ocean
10+
- **OS**: Ubuntu 24.04
11+
12+
How to Deploy
13+
-------------
14+
1. Copy `hosts.example.ini` to `hosts.ini`, fix the host connection details if needed.
15+
2. Copy `vars/vars.example.yml` to `vars/vars.yml` and adjust it accordingly.
16+
3. To **check the results** without applying, run `ansible-playbook --check --diff default.yml`.
17+
18+
To **deploy**, run `ansible-playbook default.yml`.
19+
20+
If on Windows, feel free to use scripts `ansible-playbook.ps1` as a substitute to use Ansible from WSL.

xmpp2/ansible-playbook.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
wsl --distribution Ubuntu ansible-playbook --inventory hosts.ini @args -e 'ansible_ssh_pipelining=True'

xmpp2/default.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
- import_playbook: users.yml

xmpp2/hosts.example.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; SPDX-FileCopyrightText: 2025 Friedrich von Never <[email protected]>
2+
;
3+
; SPDX-License-Identifier: MIT
4+
5+
[xmpp2]
6+
xmpp2 ansible_user=mario ansible_ssh_private_key_file=/home/mario/.ssh/xmpp2

xmpp2/users.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
- name: Set up user
3+
hosts: xmpp2
4+
become: true
5+
6+
vars_files:
7+
- vars.yml
8+
9+
handlers:
10+
- name: Reload sshd
11+
ansible.builtin.service:
12+
name: ssh
13+
state: reloaded
14+
15+
tasks:
16+
- name: Ensure a group exists for those who can connect with SSH
17+
ansible.builtin.group:
18+
name: sshuser
19+
20+
- name: Ensure a user exists and can SSH into the machine
21+
ansible.builtin.user:
22+
name: '{{ user.name }}'
23+
shell: /bin/sh
24+
groups: [ 'sudo', 'sshuser' ]
25+
append: true
26+
home: '/home/{{ user.name }}'
27+
password_lock: true
28+
29+
- name: Ensure the user can use SSH
30+
ansible.posix.authorized_key:
31+
user: '{{ user.name }}'
32+
key: '{{ user.ssh_key }}'
33+
34+
- name: Ensure only members of sshuser group can connect via SSH
35+
ansible.builtin.lineinfile:
36+
path: /etc/ssh/sshd_config
37+
line: 'AllowGroups sshuser'
38+
validate: 'sshd -f %s -t'
39+
notify: Reload sshd

xmpp2/vars/vars.example.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
user:
2+
name: mario
3+
ssh_key: 'ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXX/XXX username1@hostname'

0 commit comments

Comments
 (0)