belgotux.basic
Basic
Boilerplate to configure Debian/Ubuntu servers with useful tools and aliases.
Requirements
- 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.exampletobasic.aliasesto add your aliaseses
Role Variables
bmInstall bare metal tools if definedssh_key_filenameSSH key generated for root (default id_rsa)basic_list_userslist of users and ssh keys :nameusernameprimarygroupuser's default groupgroupsusers's other groupspubkeyslist of public keys, filename in thefilesfolderhomeuser home (default/home/username)shelluser's shell (default/bin/bash)create_homeif you want to create home directory (defaulttrue)appendappend or replace groups (defaulttrueto append)passwdpassword hash of the usermkpasswd --method=sha-512rresult in$6$docker run --rm -it ulikoehler/mkpasswdresult in yescript$y$for ubuntu >22.04
generate_ssh_keygenerate ssh keys pair for user (defaultfalse)
root_public_keyslist of public key files to copy fromfilesfolder to rootbash_alias_sharedenable shared alias (Installed alias in /usr/share only with root user ONLY viaremote_userorbecomein your playbook) (default no to install only forremote_userin his homepath)bash_alias_dir_share(default /usr/share)
optional
auto_upgradeConfigure inattended-upgrades (default false)basic_packages_defaultList of common packages to installedbasic_packages_extraList of others packages for specific group or hostsstaff_directorieslist of directory that can be modified by staff groupbasic_custom_scripts_commonlist of local scripts to put to /usr/local/bin (to use in groups)basic_custom_scripts_locallist of additionnal scripts to put to /usr/local/bin (to use in hosts)basic_udev_ruleslist of[name,dest,value]to put content into file in/etc/udev/rules.dbasic_custom_systemd_commonandbasic_custom_systemd_locallist of[name,type,dest,src|value]to put file into directory/etc/systemd/{{type}}
Copy cron
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.
Example Playbook
Playboot to to initiate a fresh raspberry pi init-new-host.yml :
- 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
Example in use of a large playbook with other roles
- 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
License
Author Information
Belgotux MonLinux
