A playbook to set up my PC/board/server of different Linux distributions (mainly Manjaro and Debian-based), ready for work in one click 🍻
# select China mirrors
sudo pacman-mirrors -i -c China -m rank
# update mirrors
sudo pacman -Syy
sudo pacman -S ansible
- community.general collection needed for git_config, pacman and npm modules in the desktop role. It is very likely that you already have this collection installed if ansible is installed.
- kewlfft.aur needed to manage packages from AUR, in the desktop role.
To install them from Ansible Galaxy, run ansible-galaxy collection install -r ./requirements.yaml
, or ansible-galaxy collection install kewlfft.aur
to just install kewlfft.aur.
add line Defaults passwd_timeout=0
to end of /etc/sudoers
with sudo visudo /etc/sudoers
sudo systemctl enable --now avahi-daemon sshd
To run from localhost in China, install ShellCrash or other proxy client and start it.
sudo -i # switch to root user
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && bash /tmp/install.sh && source /etc/profile &> /dev/null
# deploy all tasks to all hosts in hosts
ansible-playbook site.yaml
# apply everything but disk mounting and general softwares installing tasks
ansible-playbook --skip-tags disk,softwares
# only apply to board group in hosts
ansible-playbook site.yaml --limit=board
# list matching hosts under current limits and do nothing else
ansible-playbook site.yaml --limit=board --list-hosts
# only apply disk mounting tasks to localhost via local connection (not ssh connection)
ansible-playbook site.yaml -l localhost --tags disk --connection=local
-
yay --answerclean None --answerdiff None --answeredit None --save
to set default answers for yay -
set proxy for onedrive. Edit systemd service of onedrive with
sudo -e /usr/lib/systemd/user/onedrive.service
and add following two lines under [Service] section:Environment="HTTP_PROXY=http://127.0.0.1:7890" Environment="HTTPS_PROXY=http://127.0.0.1:7890"
To run a single task on managed nodes as check mode to try out what exactly will happen, use this:
ansible <nodes> -m <module> -a '{"opt1": "val1", "opt2": "val2"}' -C
Here is an example and its output:
# install nvidia-settings using module community.general.pacman under check mode
ansible localhost -m community.general.pacman -a '{"pkg":"nvidia-settings", "state":"present"}' -C
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | CHANGED => {
"changed": true,
"msg": "Would have installed 5 packages",
"packages": [
"egl-wayland",
"eglexternalplatform",
"libxnvctrl",
"nvidia-settings",
"nvidia-utils"
]
}