Compare commits

...
17 Commits
Author SHA1 Message Date
jaydee b263d1c29b build 2026-10-13 02:27:22 +02:00
jaydee b5e096219d build 2026-10-13 02:20:48 +02:00
jaydee 4f679f1e41 build 2026-10-13 02:18:11 +02:00
jaydee ca8be2ac68 build 2026-10-13 01:56:02 +02:00
jaydee 94e1b73b77 build 2026-10-13 01:54:45 +02:00
jaydee 998bc0d34c build 2026-10-13 01:51:56 +02:00
jaydee 1a1551eb82 build 2026-10-13 01:46:25 +02:00
jaydee a0a8ec18fd build 2026-10-13 01:44:12 +02:00
jaydee 4fefd8fdb7 build 2026-10-13 01:27:33 +02:00
jaydee a00ddb0217 build 2026-10-13 01:21:58 +02:00
jaydee afda85e9ff build 2026-10-13 01:20:29 +02:00
jaydee c60807239a build 2026-10-13 01:14:46 +02:00
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
19 changed files with 520 additions and 117 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
+12 -16
View File
@@ -67,18 +67,6 @@ datacenter:
ansible_winrm_kerberos_delegation: true
mqtt_srv:
children:
servers1:
hosts:
rpi5-1.home.lan:
rpi5.home.lan:
omv.home.lan:
rack.home.lan:
m-server.home.lan:
amd.home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
identity_file: ssh_key.pem
nas:
hosts:
nas.home.lan:
@@ -94,8 +82,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 +97,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:
@@ -122,7 +113,6 @@ datacenter:
srv:
hosts:
rpi5.home.lan:
m-server.home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
@@ -144,6 +134,8 @@ datacenter:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
ansible_ssh_password: l4c1j4yd33Du5lo
ansible_become_password: l4c1j4yd33Du5lo
nas:
hosts:
nas.home.lan:
@@ -161,7 +153,11 @@ datacenter:
asus.home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
ansible_ssh_user: ansible
ansible_ssh_pass: l4c1j4yd33Du5lo
ansible_become_password: l4c1j4yd33Du5lo
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
37363138343662313066323164666662393363383533303231313463663930373361346537373832
3039383933613366626134663231636339626237306632640a373565623931613261376666626137
35626538623238326234303062353536623861623632363233613434323466343466396136663536
3364353038643163320a613135353638366635313066396538643965303334356135383063373061
66373339613336343231356462353433373630326233366433613964363831373837366262363965
63633235356639333631616635316236636536306630633134306630313430643035353966343762
62656232353462346234373361613437666139656162663462643938356631663438366234623266
62313831383833623937643730356430346436383261633430663663653037383533366632333664
61383963643463643738653630663761653361323630313231306433303037303434393534643833
30663063316535626534346131393161396132343436623833336533613666643832383939646631
34643337623065653636366536383631386331633334383136343731383332353863343338613136
66633034666165633335636132356666393733633136623933656161653461653865663632646136
36393766626634383365346231333830633533313936313038616566383064633366666139313636
37633062643161656266643562313035326336386333333731656161396235383038356238343737
33393033623335343663316666656531666132386561616437393432336663373537613739346234
36373133343062343938353531616366343361393066313965623664643535356434613432393730
30346165386362353766373865643234346334633936373566656665323832363363383863633661
61373938383936393034383866666461613861366639323934646637623935623066396537356363
33653339313937393233633364343030623734663062373365343435363237663164323362303038
66653661386362643239363539656266306631396230303032366335373134336536623731313238
64626137363366336236383161343962353963663136643062643338666461366364386239353030
65653239656565373739383135613163336235653435653437386134613335333939343132323030
64636533326230383936336338376537363533376237396333346431356466666166396232366133
37303161386437656135323664376263303565316163316130333866616136626163363162316133
33353839343237623839356236613665323031363835393537346263373732623635663463326430
37303938663361396162613366643664386539373965393061643066336138313062646634626234
63343334663835343563376664376330333566326436343134303232393161653861653635396461
62303561326164313636373964623165613762383261643064633039393436646637356131313865
65643362323934663235303032313335666436663365333636653733636432336630343236356230
36383839636435306664383861316635653733633834363134323639636465633061386339343737
64333264336436343965346164303634633864366231363262333564633864343537393730643735
35383536346238373135363932386464343639336134346332356430613665393539323638323433
35336266373337656531336133666631363136643364363561613932323831323163383130643137
30313137333531376430336136653538663564373737336237376162373836393530363161633436
37393233626365393264356163393366653564663937303037376631313264303639396165656431
36646131633438396631663839383936616666333266333135656339616164376630323733616334
66346365643833343731346535633836343232323137646535633336643033386361336233616261
61306661646538353534613663333662636265643361313162333263383432643839613538623630
30386661643963656634386564323133376263393332333964393534366565633062316532333536
33363937613539373635386362613137653132303466383639653136396665363632393233306637
30363136313835353530663831663665303565656130326365623764393166633334306166336236
33386665643239656362623061386631373861393139326463316133613564616462303135353665
64306435636333633436346636663962316332633136656333646164633065393262373364613632
35393530326232646166653234366433373330373138323230653639356536363864333562316463
62306230623333336331386630356533313939363838373937643836383036396534623861373065
63643232306530306530316166306565323866623263656639343561373931623563363664613462
64636539336338633832326361653063666231653233343333326163313439346362353330633337
32393463313731303835636638326134353536633135343031363464383539373465383762646132
30643961343330333066363539633066613666613262646564653931343130363133346537616637
32633162663234386436346231353135333139316536343063643938656634386662396361356464
35313963636264613336383130636334366337646532333836306463613065336334383239303130
36613239343162393464336365653333343364303962393963383935656634613963623032643165
35646530663934333930393435303239636538616563613130363937313438343631396337333233
3333323536633739326464643735383136653937316465616133
+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
+47 -19
View File
@@ -1,9 +1,13 @@
- name: Setup vault SSH keys
become: "{{ 'no' if inventory_hostname in ['sectorq.cloud', 'nas.home.lan'] else 'yes' }}"
block:
- name: Print become password
debug:
msg: "{{ ansible_become_password }}"
- name: Facts
ansible.builtin.setup:
when: ansible_facts.architecture is not defined
- name: Install dependencies
apt:
name:
@@ -11,19 +15,25 @@
- unzip
- gnupg
- python3-debian
- ca-certificates
- gpg
state: present
update_cache: yes
- name: Download HashiCorp GPG key
- name: Download HashiCorp repository signing key
ansible.builtin.get_url:
url: https://apt.releases.hashicorp.com/gpg
dest: /tmp/hashicorp.gpg
dest: /tmp/hashicorp-archive-keyring.asc
owner: root
group: root
mode: '0644'
- name: Dearmor HashiCorp GPG key
ansible.builtin.command:
cmd: gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg /tmp/hashicorp.gpg
args:
- name: Install HashiCorp repository signing key
ansible.builtin.shell:
cmd: >-
gpg --dearmor --yes
--output /usr/share/keyrings/hashicorp-archive-keyring.gpg
/tmp/hashicorp-archive-keyring.asc
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
- name: Read os-release
@@ -41,14 +51,18 @@
- name: Add HashiCorp APT repository
ansible.builtin.apt_repository:
repo: >-
deb [arch={{ ansible_architecture }} signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg]
deb [arch={{ 'arm64' if ansible_architecture == 'aarch64'
else 'amd64' if ansible_architecture == 'x86_64'
else ansible_architecture }}
signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg]
https://apt.releases.hashicorp.com {{ ubuntu_codename }} main
filename: hashicorp
state: present
update_cache: false
- name: Update apt cache
- name: Update APT cache
ansible.builtin.apt:
update_cache: yes
update_cache: true
- name: Install Vault
apt:
@@ -104,8 +118,11 @@
mode: '0644'
- name: Create vault agent config
copy:
ansible.builtin.copy:
dest: /etc/vault-agent/config.hcl
owner: root
group: root
mode: '0644'
content: |
vault {
address = "http://vault.home.lan:8205"
@@ -129,21 +146,32 @@
}
}
template {
destination = "/home/jd/.ssh/id_ed25519-cert.pub"
perms = "0644"
user = "jd"
group = "jd"
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" {{ '}}' }}
{{ '{{' }}- with secret "ssh/sign/admin" (printf "public_key=%s" (trimSpace (file "/home/jd/.ssh/id_ed25519.pub"))) "valid_principals=jd,ansible" -{{ '}}' }}
{{ '{{' }} .Data.signed_key {{ '}}' }}
{{ '{{' }} end {{ '}}' }}
{{ '{{' }}- end -{{ '}}' }}
EOH
}
owner: root
group: root
mode: '0644'
template {
destination = "/home/ansible/.ssh/id_ed25519-cert.pub"
perms = "0644"
user = "ansible"
group = "ansible"
contents = <<EOH
{{ '{{' }}- with secret "ssh/sign/admin" (printf "public_key=%s" (trimSpace (file "/home/ansible/.ssh/id_ed25519.pub"))) "valid_principals=jd,ansible" -{{ '}}' }}
{{ '{{' }} .Data.signed_key {{ '}}' }}
{{ '{{' }}- end -{{ '}}' }}
EOH
}
- name: Create secret id file
copy:
@@ -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