15 Commits
Author SHA1 Message Date
Alex Tavarez 1accba1566 added more documentation links 2026-07-14 16:00:29 -04:00
Alex Tavarez 101c1cc0aa added a link 2026-07-14 15:17:07 -04:00
Alex Tavarez a367b3c5e4 fixed typo in documentation 2026-07-14 15:13:39 -04:00
Alex Tavarez 673e318824 changed shell script examples to reflect added fully qualified domain name optional argument for subcommands running playbooks 2026-07-14 15:05:51 -04:00
Alex Tavarez 71261e4017 added option to script subcommand for specifying a fully qualified domain name 2026-07-14 15:04:45 -04:00
Alex Tavarez 9fb64cef30 changed script to reflect change in Python envirohnment path 2026-07-14 14:45:24 -04:00
Alex Tavarez 29d4f33a46 inserted 'fqdn' variable so use of inventory hostname as a fully qualified domain name for managed node or target host services could be overridden 2026-07-14 14:43:49 -04:00
Alex Tavarez 80fd0ebb09 edited documentation so installation section reflects changes in dependency management package use 2026-07-14 14:41:57 -04:00
Alex Tavarez a4d46ada94 changed pip freeze method of dependency management to uv based method for Python 2026-07-14 14:41:17 -04:00
Alex Tavarez e04ed6f273 excluding uv Python dependency manager from version control 2026-07-14 14:39:48 -04:00
Alex Tavarez d44c67df42 added passlib library as a requirement for auto-generation of passwords by Ansible 2026-07-14 14:18:58 -04:00
Alex Tavarez 7574b8f9b4 added installation instructions; clarified how FQDN assignment for managed nodes works and its relevant for a given use-case 2026-07-14 14:15:03 -04:00
Alex Tavarez aa590effb2 added missing step or assurance 2026-07-14 12:54:34 -04:00
Alex Tavarez 5d1e073470 added clarity to a callout/alert in the documentation 2026-07-14 09:30:38 -04:00
Alex Tavarez c7b1d2d30b added more shell script examples, this time showing how to use the shell script in this repo 2026-07-14 09:28:38 -04:00
14 changed files with 227 additions and 121 deletions
+1
View File
@@ -4,6 +4,7 @@
/hosts.yml /hosts.yml
/hosts.yaml /hosts.yaml
/hosts.json /hosts.json
uv.lock
# Ansible runtime and backups # Ansible runtime and backups
*.bak *.bak
+89 -10
View File
@@ -2,6 +2,23 @@
## Installation ## Installation
Make sure you have `git`, `venv`, and `uv` installed. On GNU/Linux Debian-based distros with pre-installed `apt` package manager, the corresponding packages are:
- `git`
- `python3-venv`
- [Follow this guide](https://docs.astral.sh/uv/getting-started/installation/) for installing `uv`
Ansible must also be installed on your system (see [this guide](https://docs.ansible.com/projects/ansible/latest/installation_guide/index.html)). Then, in your interactive bash shell session, run the following in order:
```bash
git clone https://git.sukaato.moe/admin/skato-ansible.git
cd ./skato-ansible
uv venv .venv
uv sync
source .venv/bin/activate
ansible-galaxy collections install -r ./collections/requirements.yml
```
## Essential Background ## Essential Background
### Software Management ### Software Management
@@ -72,6 +89,8 @@ Other common ones, especially for services, are `port` (which can be an integer
## Essential Usage ## Essential Usage
Before running any Ansible [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) in either development or production mode, make sure to specify the username and the home directory path of the user on the system you are currently using in `{ANSIBLE_PROJECT_ROOT}/vars/local_facts.yml`.
### Development Mode ### Development Mode
For development purposes in the container routing case, either first manually set up two Debian virtual machines, or (**recommended**) change into the `${ANSIBLE_PROJECT_ROOT}/staging0.test/` directory then `${ANSIBLE_PROJECT_ROOT}/staging1.test/` directory, running `vagrant up` for each. Running the [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) in development mode also requires supplying "dev" as an argument for the extra `mode` parameter. For development purposes in the container routing case, either first manually set up two Debian virtual machines, or (**recommended**) change into the `${ANSIBLE_PROJECT_ROOT}/staging0.test/` directory then `${ANSIBLE_PROJECT_ROOT}/staging1.test/` directory, running `vagrant up` for each. Running the [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) in development mode also requires supplying "dev" as an argument for the extra `mode` parameter.
@@ -79,15 +98,12 @@ For development purposes in the container routing case, either first manually se
> [!WARNING] > [!WARNING]
> Vagrantfiles for neither staging host has yet been tested. Proceed by your own discretion. > Vagrantfiles for neither staging host has yet been tested. Proceed by your own discretion.
If you intend to run the [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) in production, the argument for this extra parameter should be "prod". The additional extra parameter of `chosen_host` should be adjusted to reflect the name of the host enlisted in the [YAML inventory file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html) for production purposes. If you intend to run the [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) in production, the argument for this extra parameter should be "prod" (skip to the [Production Mode](#production-mode) section). The additional extra parameter of `chosen_host` should be adjusted to reflect the name of the host enlisted in the [YAML inventory file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html) for production purposes.
> [!IMPORTANT] > [!IMPORTANT]
> The names of hosts should be equivalent to their intended final domain name for services on any given host to work correctly. > The names of hosts should be equivalent to their intended final domain name for services on any given host for the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) to work correctly.
Double-check, of course, that the correct values are set for `chosen_user`. The first playbook you run for each host or IP should always have `chosen_user` as "root". Execute the below while in the `$ANSIBLE_PROJECT_ROOT` directory: Anyway, for *any* mode double-check that the correct values are set for `chosen_user`. The first playbook you run for each host or IP in each pair of `ansible-playbook` commands in the upcoming shell script should always have `chosen_user` as "root". The extra parameter `chosen_user` for the second `ansible-playbook` command of each pair of `ansible-playbook` commands shown below should take an argument whose value is the same as that of the `username` attribute of any of the items in the `admins` list in the [host variables file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#organizing-host-and-group-variables) for the given host. With that in mind, execute the below for development mode for container routing case while in the `$ANSIBLE_PROJECT_ROOT` directory:
> [!TIP]
> The extra parameter `chosen_user` for the second `ansible-playbook` command of each pair of `ansible-playbook` commands shown below should take an argument whose value is the same as that of the `username` attribute of any of the items in the `admins` list in the [host variables file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#organizing-host-and-group-variables) for the given host.
```bash ```bash
#!/bin/bash #!/bin/bash
@@ -108,11 +124,13 @@ ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=staging1.test" --ext
``` ```
> [!WARNING] > [!WARNING]
> In the container routing case, development mode may not supply an accurate test of the intended networking result if the virtual machines for staging were manually created, but the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) should run successfully. This is because apppropriate networking must be set for the virtual machine itself for VPN client containers in one virtual machine to "speak" with the VPN server in another virtual machine. Th supplied Vagrantfiles are a WIP. > In the container routing case, development mode may not supply an accurate test of the intended networking result if the virtual machines for staging were manually created, but the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) should run successfully. This is because apppropriate networking must be set for the virtual machine itself for VPN client containers in one virtual machine to "speak" with the VPN server in another virtual machine. The supplied Vagrantfiles are a WIP.
### Production Mode ### Production Mode
Its important to note that the above shell script example for development mode would have to be modified in production mode for the container routing case such that every `ansible-playbook` call instance has its extra parameter `chosen_host` share the same value throughout. This is due to the combination of how SSL/TLS and domain names are set up in the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) and the requirements of the container routing case. However, `chosen_host`'s value being the same across all `ansible-playbook` commands does not mean that value should represent the same managed node or host IP throughout. Whether it does so is of course determined by whatever is in the [YAML inventory file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html). Its important to note that the above shell script example for development mode would have to be modified in production mode for the container routing case such that every `ansible-playbook` call instance has its extra parameter `chosen_host` share the same value throughout. This is due to the combination of how SSL/TLS and domain names are set up in the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) and the requirements of the container routing case. Namely, the former treats the inventory hostname used for the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) as the [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) of that server host, while the container routing case requires that both server hosts share that [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name).
This means that `chosen_host`'s value being the same across all `ansible-playbook` commands does not mean that value should represent the same managed node or host [IP](https://en.wikipedia.org/wiki/IP_address) throughout. Whether it does so is of course determined by whatever is in the [YAML inventory file](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html), so that would need to be changed when running [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) against the second chosen host in the container routing case.
To drive all that home, in production we may instead need something like the following (again, executed while in the `$ANSIBLE_PROJECT_ROOT` directory): To drive all that home, in production we may instead need something like the following (again, executed while in the `$ANSIBLE_PROJECT_ROOT` directory):
@@ -139,12 +157,73 @@ sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${HOST_FQDN}" -
ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${HOST_FQDN}" --extra-vars "chosen_user=senpai" --extra-vars "mode=prod" administrate\@homeserver.yml ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${HOST_FQDN}" --extra-vars "chosen_user=senpai" --extra-vars "mode=prod" administrate\@homeserver.yml
``` ```
**There *is* a way to avoid reassigning the IP address of the shared inventory hostname for each host the pair of playbooks is being run against in the container routing case under production.** This involves defining `fqdn` as a playbook variable or as an extra parameter for all `ansible-playbook` commands in the shell script, resulting in a shell script that looks more similar to our [development mode shell script](#development-mode):
```bash
#!/bin/bash
set -euo pipefail
SSH_KEYS=()
sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=staging0.test" --extra-vars "chosen_user=root" --extra-vars "mode=dev" --extra-vars "fqdn=web.site" init\@vps.yml
$SSH_KEYS | xargs -I %k ssh-add %k # ADD NEEDED SSH KEY FILEPATHS
ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=staging0.test" --extra-vars "chosen_user=senpai" --extra-vars "mode=dev" --extra-vars "fqdn=web.site" administrate\@vps.yml
sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=staging1.test" --extra-vars "chosen_user=root" --extra-vars "mode=dev" --extra-vars "fqdn=web.site" init\@homeserver.yml
# UNCOMMENT BELOW TO REASSIGN ENVIRONMENT VARIABLE FOR NEW ARRAY OF SSH KEYPAIR FILEPATHS
# SSH_KEYS=()
# UNCOMMENT BELOW TO ADD UPDATED SSH KEY PAIR FILEPATHS TO SSH_AGENT
# $SSH_KEYS | xargs -I %k ssh-add %k
ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=staging1.test" --extra-vars "chosen_user=senpai" --extra-vars "mode=dev" --extra-vars "fqdn=web.site" administrate\@homeserver.yml
```
> [!TIP]
> Adding the extra parameter here to the `ansible-playbook` commands of the development mode execution for the container routing use-case may also improve the realism of its execution and final state, virtual machine network configurations notwithstanding. Consider doing so for more realistic networking tests under the container routing case.
### Custom Playbooks ### Custom Playbooks
As long as you are matching the appropriate set of [playbook variable files](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_variables.html#defining-variables-in-included-files-and-roles) or settings files with the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) according to its need of those variable definitions/declarations, mostly determined by [the intended targeted hosts' own variables](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#host-variables) together with role [handlers](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#host-variables), and as long as you have appropriately set up software installations, (see [Software Management](#software-management)) creating new/custom [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) should be relatively easy. As long as you are matching the appropriate set of [playbook variable files](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_variables.html#defining-variables-in-included-files-and-roles) or settings files with the [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) according to its need of those variable definitions/declarations, mostly determined by [the intended targeted hosts' own variables](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#host-variables) together with role [handlers](https://docs.ansible.com/projects/ansible/latest/inventory_guide/intro_inventory.html#host-variables), and as long as you have appropriately set up software installations, (see [Software Management](#software-management)) creating new/custom [playbooks](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) should be relatively easy.
Depending on what you are trying to do with a new playbook, the best approach may be to just copy/duplicate the extant playbook files and then edit them, as this allows one to mitigate errors as well as have a reliable reference point for changes. Depending on what you are trying to do with a new [playbook](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html), the best approach may be to just copy/duplicate the extant [playbook files](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_intro.html) and then edit them, as this allows one to mitigate errors as well as have a reliable reference point for changes.
### CLI Tool ### CLI Tool
As an alternative, you can use the `skato-ansible` shell script in `$ANSIBLE_PROJECT_ROOT` as an abstraction of these `ansible-playbook` commands, though it is a WIP that currently only makes sense for development mode playbook executions and that I plan to replace with a `git` submodule pulling from a CLI app project in the long-term. As an alternative, you can use the `skato-ansible` shell script in `$ANSIBLE_PROJECT_ROOT` as an abstraction of the `ansible-playbook` commands for the container routing case. I plan to replace it with a CLI app covering more intended use-cases.
When using the `skato-ansible.sh` script in development mode for the container routing use case:
```bash
#!/bin/bash
set -euo pipefail
./skato-ansible.sh init vps -v 3 -m dev -n staging0.test
./skato-ansible.sh populate-agent staging
./skato-ansible.sh bootstrap vps -s 1 -v 3 -m dev -n staging0.test
./skato-ansible.sh init homeserver -v 3 -m dev -n staging1.test
# BELOW ONLY IF $SKANSIBLE_SSH_KEY ALTERED IN THE SHELL SCRIPT
# ./skato-ansible.sh populate-agent staging
./skato-ansible.sh bootstrap vps -s 1 -v 3 -m dev -n staging1.test
```
Otherwise, in production mode:
```bash
#!/bin/bash
set -euo pipefail
INVENTORY_HOSTNAMES=(web1 web2)
FQDN=web.site
./skato-ansible.sh init vps -v 3 -n "${INVENTORY_HOSTNAMES[0]}" -d "$FQDN"
./skato-ansible.sh populate-agent staging
./skato-ansible.sh bootstrap vps -s 1 -v 3 -n "${INVENTORY_HOSTNAMES[0]}" -d "$FQDN"
./skato-ansible.sh init homeserver -v 3 -n "${INVENTORY_HOSTNAMES[1]}" -d "$FQDN"
# BELOW ONLY IF $SKANSIBLE_SSH_KEY ALTERED IN THE SHELL SCRIPT
# ./skato-ansible.sh populate-agent staging
./skato-ansible.sh bootstrap vps -s 1 -v 3 -n "${INVENTORY_HOSTNAMES[1]}" -d "$FQDN"
```
> [!IMPORTANT]
> If you have different SSH keypairs for staging, make sure to change the value of `SKANSIBLE_SSH_KEYS` environment variable in the `${ANSIBLE_PROJECT_ROOT}/skato-ansible.sh` shell script before running the above shell scripts from `$ANSIBLE_PROJECT_ROOT`.
+2 -2
View File
@@ -34,13 +34,13 @@
- name: Updating hostname - name: Updating hostname
become: true become: true
ansible.builtin.hostname: ansible.builtin.hostname:
name: "{{ inventory_hostname }}" name: "{{ fqdn | default(inventory_hostname) }}"
- name: Updating hosts file - name: Updating hosts file
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/hosts path: /etc/hosts
regexp: "^127\\.0\\.1\\.1" regexp: "^127\\.0\\.1\\.1"
line: "127.0.1.1 {{ inventory_hostname }}" line: "127.0.1.1 {{ fqdn | default(inventory_hostname) }}"
insertbefore: BOF insertbefore: BOF
state: present state: present
- name: Updating host icon name - name: Updating host icon name
+2 -2
View File
@@ -37,13 +37,13 @@
- name: Updating hostname - name: Updating hostname
become: true become: true
ansible.builtin.hostname: ansible.builtin.hostname:
name: "{{ inventory_hostname }}" name: "{{ fqdn | default(inventory_hostname) }}"
- name: Updating hosts file - name: Updating hosts file
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/hosts path: /etc/hosts
regexp: "^127\\.0\\.1\\.1" regexp: "^127\\.0\\.1\\.1"
line: "127.0.1.1 {{ inventory_hostname }}" line: "127.0.1.1 {{ fqdn | default(inventory_hostname) }}"
insertbefore: BOF insertbefore: BOF
state: present state: present
- name: Updating host icon name - name: Updating host icon name
+73
View File
@@ -0,0 +1,73 @@
[project]
name = "skato-ansible"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
"ansible==13.7.0",
"ansible-builder==3.1.1",
"ansible-compat==26.3.0",
"ansible-core==2.20.6",
"ansible-lint==26.4.0",
"ansible-navigator==26.4.0",
"ansible-runner==2.4.3",
"ansible-specdoc==0.0.20",
"appdirs==1.4.4",
"attrs==26.1.0",
"baron==0.10.1",
"bindep==2.14.0",
"black==26.5.1",
"bracex==2.6",
"certifi==2026.5.20",
"cffi==2.0.0",
"charset-normalizer==3.4.7",
"click==8.4.1",
"cryptography==48.0.0",
"deprecated==1.3.1",
"distro==1.9.0",
"enrich==1.2.7",
"filelock==3.29.0",
"idna==3.16",
"jinja2==3.1.6",
"jsonschema==4.26.0",
"jsonschema-specifications==2025.9.1",
"linode-api4==5.44.0",
"lockfile==0.12.2",
"markdown-it-py==4.2.0",
"markupsafe==3.0.3",
"mdurl==0.1.2",
"molecule==26.4.0",
"mypy-extensions==1.1.0",
"onigurumacffi==1.5.0",
"packaging==26.2",
"parsley==1.3",
"passlib==1.7.4",
"pathspec==1.0.4",
"pbr==7.0.3",
"pexpect==4.9.0",
"pip==25.1.1",
"platformdirs==4.9.6",
"pluggy==1.6.0",
"polling==0.3.2",
"ptyprocess==0.7.0",
"pycparser==3.0",
"pygments==2.20.0",
"python-daemon==3.1.2",
"pytokens==0.4.1",
"pyyaml==6.0.3",
"redbaron==0.9.2",
"referencing==0.37.0",
"requests==2.34.2",
"resolvelib==1.2.1",
"rich==15.0.0",
"rpds-py==0.30.0",
"rply==0.7.8",
"ruamel-yaml==0.19.1",
"ruamel-yaml-clib==0.2.15",
"setuptools==82.0.1",
"subprocess-tee==0.4.2",
"tzdata==2026.2",
"urllib3==2.7.0",
"wcmatch==10.1",
"wrapt==2.2.1",
"yamllint==1.38.0",
]
-65
View File
@@ -1,65 +0,0 @@
ansible==13.7.0
ansible-builder==3.1.1
ansible-compat==26.3.0
ansible-core==2.20.6
ansible-lint==26.4.0
ansible-navigator==26.4.0
ansible-runner==2.4.3
ansible-specdoc==0.0.20
appdirs==1.4.4
attrs==26.1.0
baron==0.10.1
bindep==2.14.0
black==26.5.1
bracex==2.6
certifi==2026.5.20
cffi==2.0.0
charset-normalizer==3.4.7
click==8.4.1
cryptography==48.0.0
deprecated==1.3.1
distro==1.9.0
enrich==1.2.7
filelock==3.29.0
idna==3.16
jinja2==3.1.6
jsonschema==4.26.0
jsonschema-specifications==2025.9.1
linode-api4==5.44.0
lockfile==0.12.2
markdown-it-py==4.2.0
markupsafe==3.0.3
mdurl==0.1.2
molecule==26.4.0
mypy-extensions==1.1.0
onigurumacffi==1.5.0
packaging==26.2
parsley==1.3
pathspec==1.0.4
pbr==7.0.3
pexpect==4.9.0
platformdirs==4.9.6
pluggy==1.6.0
polling==0.3.2
ptyprocess==0.7.0
pycparser==3.0
pygments==2.20.0
python-daemon==3.1.2
pytokens==0.4.1
pyyaml==6.0.3
redbaron==0.9.2
referencing==0.37.0
requests==2.34.2
resolvelib==1.2.1
rich==15.0.0
rpds-py==0.30.0
rply==0.7.8
ruamel-yaml==0.19.1
ruamel-yaml-clib==0.2.15
setuptools==82.0.1
subprocess-tee==0.4.2
tzdata==2026.2
urllib3==2.7.0
wcmatch==10.1
wrapt==2.2.1
yamllint==1.38.0
@@ -38,10 +38,10 @@
- name: Exemplifying needed ACME record - name: Exemplifying needed ACME record
ansible.builtin.set_fact: ansible.builtin.set_fact:
acme_record: | acme_record: |
{{ inventory_hostname }} IN A {{ ipify_public_ip }} {{ fqdn | default(inventory_hostname) }} IN A {{ ipify_public_ip }}
_acme-challenge.{{ inventory_hostname }} IN CNAME {{ inventory_hostname }}.acme.{{ inventory_hostname }}. _acme-challenge.{{ fqdn | default(inventory_hostname) }} IN CNAME {{ fqdn | default(inventory_hostname) }}.acme.{{ fqdn | default(inventory_hostname) }}.
acme.{{ inventory_hostname }} IN NS ns.acme.{{ inventory_hostname }}. acme.{{ fqdn | default(inventory_hostname) }} IN NS ns.acme.{{ fqdn | default(inventory_hostname) }}.
ns.acme.{{ inventory_hostname }} IN A {{ ipify_public_ip }} ns.acme.{{ fqdn | default(inventory_hostname) }} IN A {{ ipify_public_ip }}
- name: Informing user of need to set up ACME record - name: Informing user of need to set up ACME record
ansible.builtin.debug: ansible.builtin.debug:
msg: "Please set ACME record in domain name provider:\n {{ acme_record }}" msg: "Please set ACME record in domain name provider:\n {{ acme_record }}"
@@ -67,12 +67,12 @@
when: data_method.user_input == "fetch" when: data_method.user_input == "fetch"
block: block:
- name: Informing user of inventory requirements for VPN clients - name: Informing user of inventory requirements for VPN clients
when: not item.name in groups.homeserver when: ((fqdn is undefined or fqdn == None) and item.name != fqdn) or not item.name in groups.homeserver
ansible.builtin.fail: ansible.builtin.fail:
msg: The VPN client must be the name of an inventory host in a homeserver group msg: The VPN client must be the name of an inventory host in a homeserver group
loop: "{{ vpn.clients }}" loop: "{{ vpn.clients }}"
- name: Dupliciating DSNet VPN service client configuration files to control node - name: Dupliciating DSNet VPN service client configuration files to control node
when: item.name in groups.homeserver when: ((fqdn is defined and fqdn != None) and item.name == fqdn) or item.name in groups.homeserver
ansible.builtin.fetch: ansible.builtin.fetch:
src: "{{ ansible_user_home.stdout }}/.wg/authorized_clients.d/{{ item.name }}{{ (idx | string) }}.conf" src: "{{ ansible_user_home.stdout }}/.wg/authorized_clients.d/{{ item.name }}{{ (idx | string) }}.conf"
dest: "./.tmp/{{ inventory_hostname }}-dsnet/" dest: "./.tmp/{{ inventory_hostname }}-dsnet/"
@@ -181,7 +181,7 @@
- name: Copying VPN client configuration files - name: Copying VPN client configuration files
become: true become: true
become_user: "{{ current_user.stdout }}" become_user: "{{ current_user.stdout }}"
when: item.name == inventory_hostname when: ((fqdn is defined and fqdn != None) and item.name == fqdn) or item.name == inventory_hostname
ansible.builtin.copy: ansible.builtin.copy:
src: "user/wg/containerized/{{ item.name }}{{ (idx | string) }}.conf" src: "user/wg/containerized/{{ item.name }}{{ (idx | string) }}.conf"
dest: "{{ ansible_user_home.stdout }}/.wg/containerized/" dest: "{{ ansible_user_home.stdout }}/.wg/containerized/"
@@ -772,7 +772,7 @@
- name: Creating required tailnet container secret for tailnet container specified by Compose file - name: Creating required tailnet container secret for tailnet container specified by Compose file
become: true become: true
# become_user: "{{ current_user.stdout }}" # become_user: "{{ current_user.stdout }}"
when: item.name == inventory_hostname when: ((fqdn is defined and fqdn != None) and item.name == fqdn) or item.name == inventory_hostname
ansible.builtin.copy: ansible.builtin.copy:
src: "{{ item.name }}-{{ headscale.users.admin.username }}@headscale/headscale{{ (idx | string) }}.key" src: "{{ item.name }}-{{ headscale.users.admin.username }}@headscale/headscale{{ (idx | string) }}.key"
dest: "{{ ansible_user_home.stdout }}/.podsecrets/headscale.key" dest: "{{ ansible_user_home.stdout }}/.podsecrets/headscale.key"
@@ -1,6 +1,6 @@
CERTBOT_EMAIL="{{ certbot.email }}" CERTBOT_EMAIL="{{ certbot.email }}"
CERTBOT_AUTHENTICATOR={{ certbot.auth_method }} CERTBOT_AUTHENTICATOR={{ certbot.auth_method }}
SERVER_WEBROOT_PATH={{ ansible_user_home.stdout + "/srv/acme." + inventory_hostname }} SERVER_WEBROOT_PATH={{ ansible_user_home.stdout + "/srv/certbot." + (fqdn | default(inventory_hostname)) }}
{% if compose.mode == "dev" %} {% if compose.mode == "dev" %}
# @TODO find a better way to have processed the below in Ansible # @TODO find a better way to have processed the below in Ansible
CERTBOT_CHALLENGE_DOMAINS={{ certbot.domains | map("regex_replace", "\\.([^\\.]*)$", ".test") | list | join(",") }} CERTBOT_CHALLENGE_DOMAINS={{ certbot.domains | map("regex_replace", "\\.([^\\.]*)$", ".test") | list | join(",") }}
@@ -1,11 +1,27 @@
http://<< inventory_hostname >> { http://<< web_fqdn >> {
handle /.well-known/acme-challenge/* { handle /.well-known/acme-challenge/* {
reverse_proxy localhost:80 reverse_proxy localhost:80
} }
handle {
redir https://{host}{uri} 308
}
}
:80 {
root /srv/certbot.<< web_fqdn >>
browse
}
<< web_fqdn >> {
respond 503
# root /srv/<< web_fqdn >>
file_server
header /.well-known/openpgpkey/* {
Content-Type application/octet-stream
Access-Control-Allow-Origin *
} }
:80 { handle_errors {
root * /srv/<< inventory_hostname >> rewrite /error/{err.status_code}.html
file_server templates
encode gzip }
} }
+23 -21
View File
@@ -15,24 +15,24 @@ if [[ "$1" == "version" ]]; then
fi fi
if [[ "$1" == "show-defaults" ]]; then if [[ "$1" == "show-defaults" ]]; then
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
printf "Private SSH keys available throufh SSH agent: |\n%s\n" "$(ssh-add -l)" printf "Private SSH keys available throufh SSH agent: |\n%s\n" "$(ssh-add -l)"
fi fi
if [[ "$1" == "start-agent" ]]; then if [[ "$1" == "start-agent" ]]; then
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
eval "$(ssh-agent -s)" eval "$(ssh-agent -s)"
fi fi
if [[ "$1" == "list-agent" ]]; then if [[ "$1" == "list-agent" ]]; then
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
ssh-add -l ssh-add -l
fi fi
if [[ "$1" == "populate-agent" ]]; then if [[ "$1" == "populate-agent" ]]; then
shift 1 shift 1
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
if [[ "$1" == "all" ]]; then if [[ "$1" == "all" ]]; then
for SKANSIBLE_SSH_KEY in ~/.ssh/*; do for SKANSIBLE_SSH_KEY in ~/.ssh/*; do
@@ -69,7 +69,7 @@ fi
if [[ "$1" == "init" ]]; then if [[ "$1" == "init" ]]; then
shift 1 shift 1
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
if [[ "$1" == "vps" ]]; then if [[ "$1" == "vps" ]]; then
SKANSIBLE_PLAY_HOST="$1" SKANSIBLE_PLAY_HOST="$1"
@@ -82,7 +82,7 @@ if [[ "$1" == "init" ]]; then
exit 1 exit 1
fi fi
while getopts "htm:s:n:v:u:" opt; do while getopts "htd:m:s:n:v:u:" opt; do
case $opt in case $opt in
h) Help "init";; h) Help "init";;
s) SKANSIBLE_STAGE="$OPTARG";; s) SKANSIBLE_STAGE="$OPTARG";;
@@ -91,6 +91,7 @@ if [[ "$1" == "init" ]]; then
t) SKANSIBLE_UNITTEST=True;; t) SKANSIBLE_UNITTEST=True;;
u) export ANSIBLE_REMOTE_USER="$OPTARG";; u) export ANSIBLE_REMOTE_USER="$OPTARG";;
m) SKANSIBLE_MODE="$OPTARG";; m) SKANSIBLE_MODE="$OPTARG";;
d) SKANSIBLE_FQDN="$OPTARG";;
*) echo "Err: Invalid option set"; exit 1;; *) echo "Err: Invalid option set"; exit 1;;
esac esac
done done
@@ -99,23 +100,23 @@ if [[ "$1" == "init" ]]; then
# SKANSIBLE_CONN_HOST=staging${SKANSIBLE_STAGE}.test # SKANSIBLE_CONN_HOST=staging${SKANSIBLE_STAGE}.test
if [[ "$SKANSIBLE_STAGE" == 0 ]]; then if [[ "$SKANSIBLE_STAGE" == 0 ]]; then
if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then
sudo ansible-playbook -CKk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" "init@${SKANSIBLE_PLAY_HOST}.yml" sudo ansible-playbook -CKk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "init@${SKANSIBLE_PLAY_HOST}.yml"
else else
sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" "init@${SKANSIBLE_PLAY_HOST}.yml" sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "init@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
elif [[ "$SKANSIBLE_STAGE" == 1 ]]; then elif [[ "$SKANSIBLE_STAGE" == 1 ]]; then
if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then
sudo ansible-playbook -CK -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" "init@${SKANSIBLE_PLAY_HOST}.yml" sudo ansible-playbook -CK -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "init@${SKANSIBLE_PLAY_HOST}.yml"
else else
sudo ansible-playbook -K -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" "init@${SKANSIBLE_PLAY_HOST}.yml" sudo ansible-playbook -K -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "init@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
fi fi
else else
if [[ -z "$SKANSIBLE_CONN_HOST" ]]; then if [[ -z "$SKANSIBLE_CONN_HOST" ]] && [[ -z "$SKANSIBLE_FQDN" ]]; then
echo "When not doing staging, chosen or preferred host must be made explicit" echo "When not doing staging, chosen or preferred host must be made explicit as well as desired FQDN"
exit 1 exit 1
else else
sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=prod" "init@${SKANSIBLE_PLAY_HOST}.yml" sudo ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-root}" --extra-vars "mode=prod" --extra-vars "fqdn=${SKANSIBLE_FQDN}" "init@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
fi fi
@@ -125,7 +126,7 @@ fi
if [[ "$1" == "bootstrap" ]]; then if [[ "$1" == "bootstrap" ]]; then
shift 1 shift 1
source "${SKANSIBLE_SCRIPT_PATH}/.env/bin/activate" source "${SKANSIBLE_SCRIPT_PATH}/.venv/bin/activate"
if [[ "$1" == "vps" ]]; then if [[ "$1" == "vps" ]]; then
SKANSIBLE_PLAY_HOST="$1" SKANSIBLE_PLAY_HOST="$1"
@@ -138,7 +139,7 @@ if [[ "$1" == "bootstrap" ]]; then
exit 1 exit 1
fi fi
while getopts "htm:s:n:v:u:" opt; do while getopts "htd:m:s:n:v:u:" opt; do
case $opt in case $opt in
h) Help "bootstrap";; h) Help "bootstrap";;
s) SKANSIBLE_STAGE="$OPTARG";; s) SKANSIBLE_STAGE="$OPTARG";;
@@ -147,6 +148,7 @@ if [[ "$1" == "bootstrap" ]]; then
t) SKANSIBLE_UNITTEST=True;; t) SKANSIBLE_UNITTEST=True;;
u) export ANSIBLE_REMOTE_USER="$OPTARG";; u) export ANSIBLE_REMOTE_USER="$OPTARG";;
m) SKANSIBLE_MODE="$OPTARG";; m) SKANSIBLE_MODE="$OPTARG";;
d) SKANSIBLE_FQDN="$OPTARG";;
*) echo "Err: Invalid option set"; exit 1;; *) echo "Err: Invalid option set"; exit 1;;
esac esac
done done
@@ -155,23 +157,23 @@ if [[ "$1" == "bootstrap" ]]; then
# SKANSIBLE_CONN_HOST=staging${SKANSIBLE_STAGE}.test # SKANSIBLE_CONN_HOST=staging${SKANSIBLE_STAGE}.test
if [[ "$SKANSIBLE_STAGE" == 0 ]]; then if [[ "$SKANSIBLE_STAGE" == 0 ]]; then
if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then
ansible-playbook -CKk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" "administrate@${SKANSIBLE_PLAY_HOST}.yml" ansible-playbook -CKk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "administrate@${SKANSIBLE_PLAY_HOST}.yml"
else else
ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" "administrate@${SKANSIBLE_PLAY_HOST}.yml" ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "administrate@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
elif [[ "$SKANSIBLE_STAGE" == 1 ]]; then elif [[ "$SKANSIBLE_STAGE" == 1 ]]; then
if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then if [[ "$SKANSIBLE_UNITTEST" == "True" ]]; then
ansible-playbook -CK -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" "administrate@${SKANSIBLE_PLAY_HOST}.yml" ansible-playbook -CK -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "administrate@${SKANSIBLE_PLAY_HOST}.yml"
else else
ansible-playbook -K -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" "administrate@${SKANSIBLE_PLAY_HOST}.yml" ansible-playbook -K -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=${SKANSIBLE_MODE}" --extra-vars "fqdn=${SKANSIBLE_FQDN:-staging.test}" "administrate@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
fi fi
else else
if [[ -z "$SKANSIBLE_CONN_HOST" ]]; then if [[ -z "$SKANSIBLE_CONN_HOST" ]]; then
echo "When not doing staging, chosen or preferred host must be made explicit" echo "When not doing staging, chosen or preferred host must be made explicit as well as desired FQDN"
exit 1 exit 1
else else
ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=prod" "administrate@${SKANSIBLE_PLAY_HOST}.yml" ansible-playbook -Kk -i hosts.yml --extra-vars "chosen_host=${SKANSIBLE_CONN_HOST}" --extra-vars "chosen_user=${ANSIBLE_REMOTE_USER:-senpai}" --extra-vars "mode=prod" --extra-vars "fqdn=${SKANSIBLE_FQDN}" "administrate@${SKANSIBLE_PLAY_HOST}.yml"
fi fi
fi fi
+2 -2
View File
@@ -5,6 +5,6 @@ certbot:
port: ~ port: ~
email: ajt95@prole.biz email: ajt95@prole.biz
domains: domains:
- "{{ inventory_hostname }}" - "{{ fqdn | default(inventory_hostname) }}"
- "*.{{ inventory_hostname }}" - "*.{{ fqdn | default(inventory_hostname) }}"
cron: "2 6 24 1 *" cron: "2 6 24 1 *"
+2 -2
View File
@@ -5,6 +5,6 @@ certbot:
port: 53 port: 53
email: ajt95@prole.biz email: ajt95@prole.biz
domains: domains:
- "{{ inventory_hostname }}" - "{{ fqdn | default(inventory_hostname) }}"
- "*.{{ inventory_hostname }}" - "*.{{ fqdn | default(inventory_hostname) }}"
cron: ~ cron: ~