Skip to content

Commit e3a9542

Browse files
committed
(#39) xmpp2: improve the auth instruction, start implementing nginx
1 parent 183d19d commit e3a9542

File tree

8 files changed

+47
-8
lines changed

8 files changed

+47
-8
lines changed

xmpp2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
hosts.ini
66

7+
vars/secrets.yml
78
vars/vars.yml

xmpp2/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ How to Deploy
1313
-------------
1414
1. Copy `hosts.example.ini` to `hosts.ini`, fix the host connection details if needed.
1515
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`.
16+
3. Copy `vars/secrets.example.yml` to `vars/secrets.yml` and adjust it accordingly.
17+
4. `ansible-vault encrypt vars/secrets.yml`
18+
5. To **check the results** without applying, run `ansible-playbook --ask-vault-pass --ask-become-pass --check --diff default.yml`.
1719

18-
To **deploy**, run `ansible-playbook default.yml`.
20+
To **deploy**, run `ansible-playbook --ask-vault-pass --ask-become-pass default.yml`.
1921

20-
If on Windows, feel free to use scripts `ansible-playbook.ps1` as a substitute to use Ansible from WSL.
22+
If on Windows, feel free to use scripts `ansible-vault.ps1`, `ansible-playbook.ps1` as a substitute to use Ansible from WSL.
23+
24+
If running deployment for the first time, then run `ansible-playbook --ask-vault-pass auth.yml` to set up the user accounts and access properly.

xmpp2/ansible-vault.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-vault @args

xmpp2/users.yml renamed to xmpp2/auth.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
# SPDX-License-Identifier: MIT
44

55
---
6-
- name: Set up user
6+
- name: Set up the users and authentication
77
hosts: xmpp2
88
become: true
99

1010
vars_files:
11+
- secrets.yml
1112
- vars.yml
1213

1314
handlers:
@@ -28,12 +29,13 @@
2829
groups: ['sudo', 'sshuser']
2930
append: true
3031
home: '/home/{{ user.name }}'
31-
password_lock: true
32+
password_lock: false
33+
password: '{{ user_secrets.password_hash }}'
3234

3335
- name: Ensure the user can use SSH
3436
ansible.posix.authorized_key:
3537
user: '{{ user.name }}'
36-
key: '{{ user.ssh_key }}'
38+
key: '{{ user.ssh_public_key }}'
3739

3840
- name: Ensure only members of sshuser group can connect via SSH
3941
ansible.builtin.lineinfile:

xmpp2/default.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
- import_playbook: users.yml
5+
- import_playbook: auth.yml
6+
- import_playbook: nginx.yml

xmpp2/nginx.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Install and configure Nginx
3+
hosts: xmpp2
4+
become: true
5+
tasks:
6+
- name: Update apt cache
7+
apt:
8+
update_cache: yes
9+
cache_valid_time: 3600
10+
11+
- name: Install nginx package
12+
apt:
13+
name: nginx
14+
state: present
15+
16+
- name: Start and enable nginx service
17+
service:
18+
name: nginx
19+
state: started
20+
enabled: yes

xmpp2/vars/secrets.example.yml

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+
user_secrets:
6+
password_hash: '' # Use `mkpasswd --method=sha-512` to generate.

xmpp2/vars/vars.example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
user:
66
name: mario
7-
ssh_key: 'ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXX/XXX username1@hostname'
7+
ssh_public_key: 'ssh-ed25519 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXX/XXX username1@hostname'

0 commit comments

Comments
 (0)