some basic structure

This commit is contained in:
Thomas Lindner 2024-05-16 21:18:15 +02:00
commit 6ed7cc3200
10 changed files with 173 additions and 0 deletions

14
README.md Normal file
View file

@ -0,0 +1,14 @@
# initial setup
- install `pyinfra` with your favorite package manager
or
- install `pipx` with your favorite package manager
- add `~/.local/bin` to your `PATH`
- `pipx install pyinfra`
# before each use
- communicate your intent to do changes to your co-admins to prevent conflicting access
- run `git pull` to fetch the newest version
- run `pyinfra @local deploy.py` to install/update `0x90.ssh_config` trustmebro
- run `pyinfra --dry inventory.py deploy.py` and check that you are on the same state that is already deployed

0
ararat/deploy.py Normal file
View file

115
ararat/install.expect Executable file
View file

@ -0,0 +1,115 @@
#!/usr/bin/env expect
spawn {*}$argv
expect -timeout 300 -ex "login: "
send "root\r"
expect -ex ":~# "
send "export TERM=dumb\r"
expect -ex ":~# "
send "setup-alpine\r"
expect -ex "\[localhost\] "
send "ararat.0x90.space\r"
expect -ex "\[eth0\] "
send "\r"
expect -ex "\[dhcp\] "
send "\r"
expect -ex "\[n\] "
send "\r"
expect -timeout 300 -ex "New password: "
send "\r"
expect -ex "Retype password: "
send "\r"
expect -ex "\[UTC\] "
send "\r"
expect -timeout 300 -ex "\[none\] "
send "\r"
expect -ex "\[chrony\] "
send "openntp\r"
expect -ex "\[1\] "
send "\r"
expect -timeout 300 -ex "\[no\] "
send "\r"
expect -ex "\[openssh\] "
send "openssh\r"
expect -timeout 300 -ex "\[none\] "
send "\r"
expect -ex "\[none\] "
send "\r"
expect -ex "\[/var/cache/apk\] "
send "none\r"
expect -ex ":~# "
send "fdisk /dev/vda\r"
expect -ex "Command (m for help): "
send "n\r"
expect -ex "extended"
send "p\r"
expect -ex ": "
send "1\r"
expect -ex ": "
send "\r"
expect -ex ": "
send "+1G\r"
expect -ex "Command (m for help): "
send "a\r"
expect -ex ": "
send "1\r"
expect -ex "Command (m for help): "
send "t\r"
expect -ex ": "
send "0c\r"
expect -ex "Command (m for help): "
send "w\r"
expect -ex ":~# "
send "fdisk /dev/vdb\r"
expect -ex "Command (m for help): "
send "n\r"
expect -ex "extended"
send "p\r"
expect -ex ": "
send "1\r"
expect -ex ": "
send "\r"
expect -ex ": "
send "+1G\r"
expect -ex "Command (m for help): "
send "a\r"
expect -ex ": "
send "1\r"
expect -ex "Command (m for help): "
send "t\r"
expect -ex ": "
send "0c\r"
expect -ex "Command (m for help): "
send "w\r"
expect -ex ":~# "
send "mkfs.vfat /dev/vda1\r"
expect -ex ":~# "
send "modprobe vfat\r"
expect -ex ":~# "
send "setup-bootable /media/cdrom /dev/vda1\r"
expect -timeout 300 -ex ":~# "
#send "apk add mdadm\r"
#expect -ex ":~# "
#send "mdadm --create --metadata=0.90 --level=1 --raid-devices=2 /dev/md0 /dev/vda1 /dev/vdb1\r"
##expect -ex "Continue creating array?"
##send "y\r"
#expect -ex ":~# "
#send "mdadm --detail --scan > /etc/mdadm.conf\r"
#expect -ex ":~# "
#send "rc-update add mdadm-raid\r"
#expect -ex ":~# "
#
#send "mkfs.vfat /dev/md0\r"
#expect -ex ":~# "
#send "modprobe vfat\r"
#expect -ex ":~# "
#send "setup-bootable /media/cdrom /dev/md0\r"
#expect -timeout 300 -ex ":~# "

7
ararat/testsetup.sh Executable file
View file

@ -0,0 +1,7 @@
vmctl stop -fw ararat
rm -f /var/vmd/ararat*.qcow2
vmctl create -s 300G /var/vmd/ararat1.qcow2
vmctl create -s 300G /var/vmd/ararat2.qcow2
reset
./install.expect vmctl start -cL -d /var/vmd/ararat1.qcow2 -d /var/vmd/ararat2.qcow2 -r /var/vmd/alpine-standard-3.19.1-x86_64.iso ararat

0
baixun/deploy.py Normal file
View file

1
baixun/upgrade.site Executable file
View file

@ -0,0 +1 @@
echo 'pkg_add -Iu' >> /etc/rc.firsttime

30
deploy.py Normal file
View file

@ -0,0 +1,30 @@
from pyinfra import host, local
from pyinfra.facts import server
from pyinfra.operations import files
if host.name == "@local":
home = host.get_fact(server.Home)
files.directory(
name="deleting your bitcoin", path=f"{home}/.ssh", mode="700"
)
files.put(
name="sharing your browser history",
src="files/ssh_config",
dest=f"{home}/.ssh/0x90.ssh_config",
)
files.line(
name="encrypting your home directory",
path=f"{home}/.ssh/config",
line="Include 0x90.ssh_config",
)
if host.name != "@local":
home = host.get_fact(server.Home)
files.directory(path=f"{home}/.ssh", mode="700")
files.put(src="files/authorized_keys", dest=f"{home}/.ssh/authorized_keys")
if host.name == "ararat.0x90.space":
local.include("ararat/deploy.py")
if host.name == "baixun.0x90.space":
local.include("baixun/deploy.py")

1
files/authorized_keys Normal file
View file

@ -0,0 +1 @@
sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBODYKtJ2PDZRznfGcpviZl+NVcbgJQYYKGxg8rjJQCQRSW88aJM+jP3v+jFYZ0ZldLd6KoyIitEZI60Nsp/hdEoAAAAEc3NoOg== vmann

0
files/ssh_config Normal file
View file

5
inventory.py Normal file
View file

@ -0,0 +1,5 @@
targets = [
"@local",
("ararat.0x90.space", dict(ssh_port=42022)),
("baixun.0x90.space", dict(ssh_port=42023)),
]