chore: too much pain
parent
e889edecaa
commit
27e4b5978c
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
# set some variables
|
||||||
|
|
||||||
|
homeDir=$HOME
|
||||||
|
echo $homeDir
|
||||||
|
|
||||||
|
hostname=$HOSTNAME
|
||||||
|
echo $hostname
|
||||||
|
|
||||||
|
os=$(lsb_release -d| awk '{print $2}') # definitely works on Fedora
|
||||||
|
echo $os
|
||||||
|
|
||||||
|
# ensure some directories exist
|
||||||
|
gitDir=$homeDir"/git"
|
||||||
|
[ ! -d $gitDir ] && mkdir -p $gitDir || echo $gitDir" already exists"
|
||||||
|
|
||||||
|
sshDir=$homeDir"/.ssh"
|
||||||
|
[ ! -d $sshDir ] && mkdir -p $sshDir || echo $sshDir" already exists"
|
||||||
|
|
||||||
|
configDir=$homeDir"/.config"
|
||||||
|
[ ! -d $configDir ] && mkdir -p $configDir || echo $configDir" already exists"
|
||||||
|
|
||||||
|
|
||||||
|
# create an ssh key, for use with git/github
|
||||||
|
ssh-keygen -t ed25519 -f $sshDir"/id_ed25519_git" -N ''
|
|
@ -0,0 +1,44 @@
|
||||||
|
from pyinfra import host
|
||||||
|
from pyinfra.facts.files import File
|
||||||
|
from pyinfra.facts.server import LinuxName
|
||||||
|
from pyinfra.operations import apt, server, dnf, files
|
||||||
|
|
||||||
|
|
||||||
|
os = host.get_fact(LinuxName)
|
||||||
|
print (os)
|
||||||
|
|
||||||
|
|
||||||
|
# why does this not work????
|
||||||
|
# username = host.get_fact(User)
|
||||||
|
username = str(server.shell("whoami"))
|
||||||
|
print(username)
|
||||||
|
|
||||||
|
hostname = host.get_fact(server.Hostname)
|
||||||
|
print(hostname)
|
||||||
|
|
||||||
|
# why does this not work????
|
||||||
|
# homeDir = host.get_fact(server.Home)
|
||||||
|
|
||||||
|
homeDir = str(server.shell("echo $HOME"))
|
||||||
|
print(homeDir)
|
||||||
|
|
||||||
|
# files.directory(
|
||||||
|
# name="Ensure /home/username/git exists",
|
||||||
|
# path=str(homeDir)+"/git",
|
||||||
|
# user=username,
|
||||||
|
# group=username,
|
||||||
|
# )
|
||||||
|
|
||||||
|
# files.directory(
|
||||||
|
# name="Ensure /home/username/.config exists",
|
||||||
|
# path=str(homeDir)+"/.config",
|
||||||
|
# user=username,
|
||||||
|
# group=username,
|
||||||
|
# )
|
||||||
|
|
||||||
|
# files.directory(
|
||||||
|
# name="Ensure /home/username/.ssh exists",
|
||||||
|
# path=str(homeDir)+"/.ssh",
|
||||||
|
# user=username,
|
||||||
|
# group=username,
|
||||||
|
# )
|
|
@ -0,0 +1,21 @@
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/main.py", line 224, in cli
|
||||||
|
_main(*args, **kwargs)
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/main.py", line 355, in _main
|
||||||
|
state, config = _handle_commands(state, config, command, original_operations, operations, quiet)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/main.py", line 612, in _handle_commands
|
||||||
|
state, config, operations = _run_deploy_operations(state, config, operations, quiet)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/main.py", line 669, in _run_deploy_operations
|
||||||
|
load_deploy_file(state, filename)
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/util.py", line 247, in load_deploy_file
|
||||||
|
raise result
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/util.py", line 227, in load_file
|
||||||
|
exec_file(filename)
|
||||||
|
File "/home/ctome/.local/pipx/venvs/pyinfra/lib64/python3.11/site-packages/pyinfra_cli/util.py", line 50, in exec_file
|
||||||
|
code = compile(code, filename, "exec")
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "post-install.py", line 22
|
||||||
|
homeDir = str(server.shell(("echo $HOME"))
|
||||||
|
^
|
||||||
|
SyntaxError: '(' was never closed
|
Loading…
Reference in New Issue