Compare commits

..
5 Commits
Author SHA1 Message Date
jaydee 6450791767 build 2026-09-17 00:56:26 +02:00
jaydee 0e0e39e131 build 2026-09-17 00:40:10 +02:00
jaydee a5092a1fdd build 2026-09-17 00:39:22 +02:00
jaydee 6e5b63a3ad build 2026-09-17 00:36:31 +02:00
jaydee 8efcc9eac6 build 2026-09-17 00:35:04 +02:00
18 changed files with 471 additions and 85 deletions

No files matched your search

+7 -1
View File
@@ -126,4 +126,10 @@
tags: vault_ssh_keys
- name: test
role: test
tags: test
tags: test
- name: fix_router
role: fix_router
tags: fix_router
- name: disable-wakers
role: disable-wakers
tags: disable-wakers
+10 -3
View File
@@ -94,8 +94,11 @@ datacenter:
hosts:
morefine.home.lan:
vars:
ansible_ssh_user: jd
ansible_ssh_user: ansible
ansible_ssh_pass: q
ansible_become_user: root
ansible_become_password: q
ansible_user: ansible
proxmox:
children:
docker_workers:
@@ -106,9 +109,9 @@ datacenter:
vars:
ansible_ssh_user: jd
ansible_become_user: root
ansible_become_password: q
# ansible_ssh_password: q
ansible_ssh_password: q
containers:
children:
docker_servers:
@@ -161,7 +164,11 @@ datacenter:
asus.home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
ansible_ssh_user: ansible
ansible_ssh_pass: q
ansible_become_password: q
ansible_become_user: root
ansible_user: ansible
vms:
children:
debian13:
+54 -49
View File
@@ -1,50 +1,55 @@
$ANSIBLE_VAULT;1.1;AES256
65316436333931393863333238383631633937653735643635326439396239336166363034623666
6230643630336630356134353062376161303334663334650a616564326135663538663964366461
66376238616466663734616433646630633661626139653936383863363765613463333730366236
6139383162633038320a316161373335356231616238613331376163343134656339666630326365
64386164653362623234353937373036623533633334313833336536363661633330643731303861
65643739353938343465356361333661393431656561373930343230626633326238666533306138
62373761373938306633393830376561363363306466396238643737613863373266313832643535
32313362363433373461653037383164653265313536616230363032373836383637363639333264
39653832316237343833636533646532316637323937353462303332343137313339613635623530
64366637346335663732306437336231353963623737613364666138396633616362376130333965
35656636366234303664623436633339306165343539323434623231393338626565353534666366
38643533396535356265343161336530303532616565623539333265306334663339386335366630
61666164363863323361623836313339393366303032383335346636363833313864336233626435
35663734393965336135323531383130303032306533333932663263653237396664613037316632
36393035643437333531656461353733386436666663346431353039616135376334623866346530
63366234326535646662373566336332376262633963653134633865303431663133396164383031
30626333363265333836306566373362313966346165326165636162393133336235343036366561
64376564323264366466303832626162663937336232666436343730356233653138363761643464
66653361653161663461653836373837623063323262316163333738613335316631663130373665
39373133326630663566643564653337666266623831343336396262333236643836663333316239
35313039646639393231663433623334363266306130333638386664313463353137363665343137
35353635616238336234353031663839666563316364613636353534303665376339613639383639
65633961353565346561616665666430383663626331303233346161626563323839323265363138
65626236323937623561653466333937326334353464613265366632656562346339366231353837
34346262356565373062306530353339323331333036666134323065633830636131623261353161
65656562363334616231386238373964666563316236653561633939396663653034643063303030
36326633653064323033623431386432666466363966653561383962303766333366313666656361
32336163653532353565313836623366636565663036663834623464636138336138653032393530
65393035313937653235616334643365376534626230666565633037643130333962346635613866
39643438613733393037653237653538653934393437373465626366623966613362313165623537
64633736663864646361653665313266363666323566616133653032633663373934643466656362
66353631663964333637643661306638653265303364356530326133633166626166386261306336
35613331313432333263306334333331333430376564663364313337633636336336313039356234
38333064333361353430386136383562316664376131396435656635313131616265343232623739
32323765656239386238666561666364616364346361393637313434633630303939366332323166
63343362383266373665373365616165623662613639656235616332656232383933383432386663
35653364336437353236613038363233393362353433313763333539306433383166626164373338
35613965303932623164626234343265343465363962373561613166373131323037316234653130
38343932353237326363663063373931663439353536303664303161306532396666646539336639
35356131646233373735653937646462623335363336313431623438613462346631633566633035
66313437646431333265653363366337383963363135366530393438383733633739633966616436
31343761353166396636313262313233633564616363333536323834633266326464383630373935
31633138363138393865376139346336316364616134636134373366616334363365366535656631
32623638366135343162613936353562313363393530633735343665333430306630623535366235
33393461373461643332613930333235313430633564616535623338303764303834373131633538
64303661303361373831313863383563303035313231383365376162323536346430626561646165
63613762643864636131613165343935376135323935666664333761383363613161393436336139
34383230333530363261396366386635643866386361303731616132313435663663353737363038
34333230643039366463353363383861363133626233613933336434396536383536
36343061373466366264313064303364653234633565386666333861643137376430623931666135
6137316563613135353437376136626136646230326532320a313435396536363261613837643032
64313231336432656237613130613163383062653431383336383365353039313031383136386461
3562313663313138350a626331383662653963396434666365653561396537653037383531653630
61333932353635373365643438646562626339323065333837363139623861653236343764373236
38663335336233396661366263383333646532366565313563303737376263633161333161356339
33626434626230346637323433386462623165646634333965663061323865646239353261373161
39353536323432346233333035326361333066653961313064663062353833663963303366303339
34656165643935633033313237373833393065653064306264393131333562633530616663313034
61316335626165303833383061656338306237396534303332626665626336393333623037633039
65326439333037366635366637346632643864616136626163376237626232386531646134313033
34326134303366336362373136653237613538653738636532393633613531646238363266653962
31333430636230653437646664316438303936656236343162366666623964653863663634383230
37393034326166343238626265666136663964623835393132323132383939343434323434353136
36346265373164313336396635343839646564636533646662396536303739636330323765376130
62373034373564323038303933366665356633333761326166313762613832313135343133343564
36303562323865373435626663363031303430353833343338626133363038393762373934663330
32343635386166656362323933323839326638393562386462313134393339333261326233396131
38653535343265346233653839363664636537386263363133396233376635313330613632393236
33373635376631376233356334656264326165306137383636326535626535363334303234663564
63396261326330663561663534376131626139393665633739326435323336396234343262313134
39373064346361623431383964306665636466313338323333646162333866656235333861653564
35633132323262303630636334653139336636316333346263616630646463643066386562323462
66643366356333633465333662336434393130643362323638663532646564326635346233623735
61636535313532353831383530343164623435653235366565386339333438323333666232366135
39616364323665353738633533326436656362626130353662303462356632303961393632373663
32336130316334633662653939633566393563663238326330336330386130373333373537333231
61613933393631393036363862343835613635393932636531393061326130323034333334303637
33643936336632393836353065366332313162653265633139613330633239653534663131396662
61336162666632653864396533393033346435336434316161623335373733643965363861323033
30363637646562373935343965666633306336626131393766656237336431363765366663623537
36356564613336653039623333353363363338626334366435396234653664373066346264626565
37343837343031633830353131333335656463353533386361653064643130316333316465383565
34333263633731376365303234623135663034633035353661366533373634643665353531376536
31363535626239633666326364383035353631393930643332636537663031313536343630396661
64323432663333356366356136666466333163613535343565306361336331303532613734323962
61646364613430643761653534363137643333356563623365616163313830373137336461363061
33393133373539613839353563643135356435353831663962303961663263666566383664333961
33666162313939623235343563643863646537333930356565616130333239323464613030633933
32366131626561313839363438636366363038366133396635613336343961613234626563376135
35356665303931333465653832343731363230396664303235333339636162626336376365663133
36636661363334633766663633383335316336656139376263306566316565396365653462303363
61656433306264646536333333633366656264313536636464633139653762643132316539633539
36616662613239373331623737313063333235663238616465316363363038343964336232316637
65303733366535323362626236623539346265666363393735313064383535663762656530313666
66626333656639333233326164303435336239373935326231653632383534316530343639363463
65363034616636303834613039363461323138313531626264346663313862656663393362313964
63356563303931373337646633356234623339393764636539356362623861626438663462323838
35323866633233326134656364363037323535633438336238313737323033323439363039353033
66646565653733313038653564346530646666313133336666643761326361313463616464323931
33373734373133336435383162373064366665636165633063616464316630316334383464663533
32353063356265356363666538653032623735323036366565383663373033303664633631666263
32386265626337373064663336613663306434666162363232306630663234373734613563316633
3138343765363165316635346132313961326535366265326263
+38
View File
@@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+3
View File
@@ -0,0 +1,3 @@
#SPDX-License-Identifier: MIT-0
---
# defaults file for roles/disable-wakers
+9
View File
@@ -0,0 +1,9 @@
---
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: Restart ACPI wakeup service
ansible.builtin.systemd:
name: "{{ acpi_wakeup_service_name }}"
state: restarted
+35
View File
@@ -0,0 +1,35 @@
#SPDX-License-Identifier: MIT-0
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.2
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
+26
View File
@@ -0,0 +1,26 @@
---
- name: Install ACPI wakeup shutdown script
ansible.builtin.template:
src: disable-acpi-wakeup.sh.j2
dest: "{{ acpi_wakeup_script_path }}"
owner: root
group: root
mode: "0755"
- name: Install ACPI wakeup systemd service
ansible.builtin.template:
src: disable-acpi-wakeup.service.j2
dest: "/etc/systemd/system/{{ acpi_wakeup_service_name }}"
owner: root
group: root
mode: "0644"
notify:
- Reload systemd
- Restart ACPI wakeup service
- name: Enable ACPI wakeup shutdown service
ansible.builtin.systemd:
name: "{{ acpi_wakeup_service_name }}"
enabled: true
state: started
daemon_reload: true
@@ -0,0 +1,15 @@
[Unit]
Description=Disable ACPI wakeup devices on shutdown
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target poweroff.target
Conflicts=shutdown.target reboot.target halt.target poweroff.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop={{ acpi_wakeup_script_path }}
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,8 @@
#!/bin/bash
set -u
for device in $(awk '$3 == "enabled" {print $1}' /proc/acpi/wakeup); do
echo "$device"
echo "$device" > /proc/acpi/wakeup
done
+3
View File
@@ -0,0 +1,3 @@
#SPDX-License-Identifier: MIT-0
localhost
+6
View File
@@ -0,0 +1,6 @@
#SPDX-License-Identifier: MIT-0
---
- hosts: localhost
remote_user: root
roles:
- roles/disable-wakers
+3
View File
@@ -0,0 +1,3 @@
#SPDX-License-Identifier: MIT-0
---
# vars file for roles/disable-wakers
+9 -3
View File
@@ -1,3 +1,9 @@
#SPDX-License-Identifier: MIT-0
---
# defaults file for roles/fix_router
vault_version: "2.1.0"
vault_install_dir: "/usr/local/bin"
vault_download_dir: "/tmp"
vault_archive: "vault_{{ vault_version }}_linux_arm64.zip"
vault_binary: "{{ vault_install_dir }}/vault"
vault_url: >-
https://releases.hashicorp.com/vault/{{ vault_version }}/{{ vault_archive }}
vault_checksums_url: >-
https://releases.hashicorp.com/vault/{{ vault_version }}/vault_{{ vault_version }}_SHA256SUMS
+71 -29
View File
@@ -8,40 +8,51 @@
- gpg
- wget
- haproxy
- ca-certificates
- unzip
state: present
update_cache: true
- name: Download HashiCorp GPG key
- name: Download Vault {{ vault_version }} ARM64
ansible.builtin.get_url:
url: https://apt.releases.hashicorp.com/gpg
dest: /tmp/hashicorp.asc
mode: '0644'
url: "{{ vault_url }}"
dest: "{{ vault_download_dir }}/{{ vault_archive }}"
mode: "0644"
- name: Convert HashiCorp GPG key to keyring format
- name: Create Vault extraction directory
ansible.builtin.file:
path: "{{ vault_download_dir }}/vault-{{ vault_version }}"
state: directory
mode: "0755"
- name: Extract Vault
ansible.builtin.unarchive:
src: "{{ vault_download_dir }}/{{ vault_archive }}"
dest: "{{ vault_download_dir }}/vault-{{ vault_version }}"
remote_src: true
creates: "{{ vault_download_dir }}/vault-{{ vault_version }}/vault"
- name: Install Vault binary
ansible.builtin.copy:
src: "{{ vault_download_dir }}/vault-{{ vault_version }}/vault"
dest: "{{ vault_binary }}"
remote_src: true
owner: root
group: root
mode: "0755"
- name: Verify Vault installation
ansible.builtin.command:
cmd: >
gpg --dearmor
-o /usr/share/keyrings/hashicorp-archive-keyring.gpg
/tmp/hashicorp.asc
args:
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
cmd: "{{ vault_binary }} version"
register: vault_version_output
changed_when: false
- name: Display installed Vault version
ansible.builtin.debug:
var: vault_version_output.stdout
- name: Add HashiCorp APT repository
ansible.builtin.apt_repository:
repo: >
deb [arch={{ ansible_architecture == 'x86_64' | ternary('amd64', ansible_architecture) }}
signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg]
https://apt.releases.hashicorp.com
{{ ansible_distribution_release }}
main
filename: hashicorp
state: present
- name: Install Vault
ansible.builtin.apt:
name: vault
state: present
update_cache: true
- name: Create service for vault agent
ansible.builtin.copy:
@@ -80,7 +91,7 @@
dest: /opt/vault/scripts/unseal.sh
content: |
#!/usr/bin/env bash
export VAULT_ADDR="http://127.0.0.1:8200"
export VAULT_ADDR="http://192.168.77.1:8200"
SEALED=$(vault status -format=json | jq -r .sealed)
if [ "$SEALED" = "true" ]; then
@@ -97,6 +108,36 @@
group: vault
mode: '0700'
- name: Install Vault systemd service
ansible.builtin.copy:
dest: /etc/systemd/system/vault.service
owner: root
group: root
mode: "0644"
content: |
[Unit]
Description=HashiCorp Vault
Documentation=https://developer.hashicorp.com/vault/docs
Requires=network-online.target
After=network-online.target
[Service]
User=vault
Group=vault
ExecStart=/usr/local/bin/vault server -config=/etc/vault.d/vault.hcl
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
- name: Create service
ansible.builtin.copy:
dest: /etc/systemd/system/vault-unseal.service
@@ -126,10 +167,11 @@
mode: '0644'
- name: Enable and start services
ansible.builtin.systemd:
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: yes
enabled: true
state: started
daemon_reload: true
loop:
- vault
- vault-unseal
+153
View File
@@ -0,0 +1,153 @@
- name: Setup vault SSH keys
become: "{{ 'no' if inventory_hostname in ['sectorq.cloud', 'nas.home.lan'] else 'yes' }}"
block:
- name: Include vault
ansible.builtin.include_vars:
file: init.yml
- name: Install required dependencies
ansible.builtin.dnf:
name:
- dnf-plugins-core
- curl
state: present
- name: Add HashiCorp repository
ansible.builtin.get_url:
url: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
dest: /etc/yum.repos.d/hashicorp.repo
mode: "0644"
- name: Clean DNF cache
ansible.builtin.command: dnf clean all
changed_when: false
- name: Install Vault
ansible.builtin.dnf:
name: vault
state: present
update_cache: yes
- name: Set vault address
copy:
dest: /etc/profile.d/vault.sh
content: "export VAULT_ADDR=http://vault.home.lan:8205\n"
owner: root
group: root
mode: '0644'
- name: Read SSH CA public key from Vault
ansible.builtin.command:
cmd: vault read -field=public_key ssh/config/ca
register: vault_ca
changed_when: false
environment:
VAULT_ADDR: "{{ vault_addr }}"
VAULT_TOKEN: "{{ vault_token }}"
- name: Install trusted SSH user CA
ansible.builtin.copy:
content: "{{ vault_ca.stdout }}\n"
dest: /etc/ssh/trusted-user-ca-keys.pem
owner: root
group: root
mode: '0644'
- name: Enable Trusted User CA
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: "^TrustedUserCAKeys"
line: "TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem"
state: present
- name: Enable PubkeyAuthentication
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: "^PubkeyAuthentication.*"
line: "PubkeyAuthentication yes"
state: present
- name: Create vault agent dir
file:
path: /etc/vault-agent
state: directory
owner: root
group: root
mode: '0644'
- name: Create vault agent config
copy:
dest: /etc/vault-agent/config.hcl
content: |
vault {
address = "http://vault.home.lan:8205"
}
auto_auth {
method "token_file" {
config = {
token_file_path = "/etc/vault-agent/token"
}
}
sink "file" {
config = {
path = "/tmp/vault-token"
}
}
}
template {
destination = "/home/jd/.ssh/id_ed25519-cert.pub"
perms = "0644"
user = "jd"
group = "jd"
contents = <<EOH
{{ '{{' }} with secret "ssh/sign/admin" (printf "public_key=%s" (trimSpace (file "/home/jd/.ssh/id_ed25519.pub"))) "valid_principals=jd" {{ '}}' }}
{{ '{{' }} .Data.signed_key {{ '}}' }}
{{ '{{' }} end {{ '}}' }}
EOH
}
owner: root
group: root
mode: '0644'
- name: Create file with token for vault agent
copy:
dest: /etc/vault-agent/token
content: "{{ vault_sshcert_token }}"
owner: root
group: root
mode: '0600'
- name: Create service for vault agent
copy:
dest: /etc/systemd/system/vault-agent.service
content: |
[Unit]
Description=Vault Agent
After=network-online.target
[Service]
ExecStart=/usr/bin/vault agent -config=/etc/vault-agent/config.hcl
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
owner: root
group: root
mode: '0644'
- name: Enable and start vault agent service
systemd:
name: vault-agent
enabled: yes
state: started
- name: Restart sshd
ansible.builtin.service:
name: sshd
state: restarted
@@ -0,0 +1,13 @@
[Unit]
Description=Run command before shutdown
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target
[Service]
Type=oneshot
ExecStart=/bin/true
ExecStop=/usr/local/bin/pre-shutdown.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
echo "System is shutting down at $(date)" >> /var/log/pre-shutdown.log
for i in `cat /proc/acpi/wakeup|grep enabled|awk '{ print $1 }'`
do
echo $i
echo $i > /proc/acpi/wakeup
done