Boilerplate to configure Debian/Ubuntu servers with useful tools and aliases.
- Ubuntu / Debian OS / WSL
- SSH key installed on the servers (root or a user with become)
The playbooks playbook-init-server.yml
can be use first to init a new server with public keys and install sudo for Debian. Only need to execute once :
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventories/prod roles/basic/playbook-init-server.yml -e 'mykey=~/.ssh/id_ecdsa.pub myhost=node9 user=pi become_meth=su' -kK
- Copy
basic.aliases.example
tobasic.aliases
to add your aliaseses
-
bm
Install bare metal tools if defined -
ssh_key_filename
SSH key generated for root (default id_rsa) -
basic_list_users
list of users and ssh keys :name
usernameprimarygroup
user's default groupgroups
users's other groupspubkeys
list of public keys, filename in thefiles
folderhome
user home (default/home/username
)shell
user's shell (default/bin/bash
)create_home
if you want to create home directory (defaulttrue
)append
append or replace groups (defaulttrue
to append)passwd
password hash of the usermkpasswd --method=sha-512
rresult in$6$
docker run --rm -it ulikoehler/mkpasswd
result in yescript$y$
for ubuntu >22.04
generate_ssh_key
generate ssh keys pair for user (defaultfalse
)
-
root_public_keys
list of public key files to copy fromfiles
folder to root -
bash_alias_shared
enable shared alias (Installed alias in /usr/share only with root user ONLY viaremote_user
orbecome
in your playbook) (default no to install only forremote_user
in his homepath) -
bash_alias_dir_share
(default /usr/share)
auto_upgrade
Configure inattended-upgrades (default false)basic_packages_default
List of common packages to installedbasic_packages_extra
List of others packages for specific group or hostsstaff_directories
list of directory that can be modified by staff groupbasic_custom_scripts_common
list of local scripts to put to /usr/local/bin (to use in groups)basic_custom_scripts_local
list of additionnal scripts to put to /usr/local/bin (to use in hosts)basic_udev_rules
list of[name,dest,value]
to put content into file in/etc/udev/rules.d
basic_custom_systemd_common
andbasic_custom_systemd_local
list of[name,type,dest,src|value]
to put file into directory/etc/systemd/{{type}}
You can copy cron files into /etc/cron.d/ based on group name. Just put files into directory files/cron/YOUR_GROUP/
to copy them.
- hosts: all
roles:
- name: basic
vars:
basic_list_users:
- name: belgotux
groups: sudo,users,staff,adm
passwd: $6$xxxx
pubkeys:
- xxx.pub
- yyy.pub
bash_alias_shared: yes
Usage :
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i inventories/prod init-new-host.yml -u pi --limit octoprint -kK
- hosts: [homeservers,vps]
roles:
- name: basic
vars:
basic_list_users:
- name: belgotux
groups: sudo,users,staff,adm
shell: "/bin/zsh"
passwd: $6$xxxx
pubkeys:
- xxx.pub
- yyy.pub
basic_sudo_passwordless: yes
bash_alias_shared: yes
basic_users_and_path_alias_list:
- user: root
path: /root
- user: root
path: /etc/skel
- user: pi
path: /home/pi
- user: belgotux
path: /home/belgotux
tags: basic
- role: viasite-ansible.zsh
tags: zsh
become: true
- role: postfix-client
tags: postfix
Belgotux MonLinux