From 5bbc551106548cd9b779722e00e4be16e987a6d7 Mon Sep 17 00:00:00 2001 From: warezjoe Date: Mon, 26 Jan 2026 11:54:00 +0100 Subject: [PATCH] Refactor: Organize Ansible project structure - Reorganized Ansible project structure to follow best practices. - Created dedicated directories: , , , , and . - Categorized playbooks into (host-specific) and (service-specific). - Moved all roles into the directory and standardized their naming conventions. - Relocated to for better variable management. - Renamed to to reflect its global variable scope. - Created to correctly set the to the new directory. - Moved and into the directory. - Added to providing explanations for common commands. - Cleaned up directories from all individual roles to centralize version control. --- ansible.cfg | 2 + README.md => docs/README.md | 0 command-to-run.txt => docs/command-to-run.txt | 0 docs/commands_explained.md | 28 + zeus-vars.yml => group_vars/all.yml | 0 group_vars/vault.yml | 74 ++ inventory | 1 + local-mv.yml => playbooks/hosts/local-mv.yml | 0 lxc.yml => playbooks/hosts/lxc.yml | 4 +- rpi.yml => playbooks/hosts/rpi.yml | 0 zeus.yml => playbooks/hosts/zeus.yml | 0 mariadb.yml => playbooks/services/mariadb.yml | 0 playbooks/services/mysql.yml | 37 + nfs.yaml => playbooks/services/nfs.yaml | 0 samba.yml => playbooks/services/samba.yml | 0 .../services/wireguard-cerberus.yml | 0 .../services/wireguard-client-gen.yml | 0 .../template-differ.yml | 0 template.yml => playbooks/template.yml | 0 universal.yml => playbooks/universal.yml | 0 roles/create_user/.travis.yml | 29 + roles/create_user/README.md | 38 + roles/create_user/defaults/main.yml | 8 + roles/create_user/handlers/main.yml | 2 + roles/create_user/meta/main.yml | 52 ++ roles/create_user/tasks/main.yml | 48 ++ roles/create_user/tests/inventory | 2 + roles/create_user/tests/test.yml | 5 + roles/create_user/vars/main.yml | 2 + roles/create_zfs_dataset/.travis.yml | 29 + roles/create_zfs_dataset/README.md | 38 + roles/create_zfs_dataset/defaults/main.yml | 6 + roles/create_zfs_dataset/handlers/main.yml | 2 + roles/create_zfs_dataset/meta/main.yml | 52 ++ roles/create_zfs_dataset/tasks/main.yml | 16 + roles/create_zfs_dataset/tests/inventory | 2 + roles/create_zfs_dataset/tests/test.yml | 5 + roles/create_zfs_dataset/vars/main.yml | 2 + roles/docker/.ansible-lint | 4 + roles/docker/.yamllint | 11 + roles/docker/LICENSE | 20 + roles/docker/README.md | 128 ++++ roles/docker/defaults/main.yml | 49 ++ roles/docker/handlers/main.yml | 7 + roles/docker/meta/main.yml | 41 ++ roles/docker/molecule/default/converge.yml | 24 + roles/docker/molecule/default/molecule.yml | 19 + roles/docker/tasks/docker-compose.yml | 31 + roles/docker/tasks/docker-users.yml | 10 + roles/docker/tasks/main.yml | 117 ++++ roles/docker/tasks/setup-Debian.yml | 50 ++ roles/docker/tasks/setup-RedHat.yml | 52 ++ roles/docker/vars/Alpine.yml | 2 + roles/docker/vars/Archlinux.yml | 2 + roles/docker/vars/main.yml | 2 + roles/docker_spin_up/.travis.yml | 29 + roles/docker_spin_up/README.md | 38 + roles/docker_spin_up/defaults/main.yml | 3 + roles/docker_spin_up/files/mailserver.env | 661 ++++++++++++++++++ roles/docker_spin_up/handlers/main.yml | 2 + roles/docker_spin_up/meta/main.yml | 52 ++ .../tasks/dashboard_my_public.yml | 9 + roles/docker_spin_up/tasks/email.yml | 34 + roles/docker_spin_up/tasks/gitea.yml | 24 + roles/docker_spin_up/tasks/jellyfin.yml | 34 + roles/docker_spin_up/tasks/main.yml | 17 + roles/docker_spin_up/tasks/monitoring.yml | 82 +++ roles/docker_spin_up/tasks/nextcloud.yml | 19 + roles/docker_spin_up/tasks/nginx.yml | 16 + roles/docker_spin_up/tasks/pi-hole.yml | 20 + roles/docker_spin_up/tasks/transmission.yaml | 24 + .../templates/promtail-config.yml | 60 ++ roles/docker_spin_up/tests/inventory | 2 + roles/docker_spin_up/tests/test.yml | 5 + roles/docker_spin_up/vars/main.yml | 2 + roles/linux_config_init/.travis.yml | 29 + roles/linux_config_init/defaults/main.yml | 2 + roles/linux_config_init/handlers/main.yml | 5 + roles/linux_config_init/tasks/bashrc_copy.yml | 17 + roles/linux_config_init/tasks/create_user.yml | 27 + .../linux_config_init/tasks/hostname_set.yml | 13 + roles/linux_config_init/tasks/main.yml | 18 + .../tasks/resolvconf_copy.yml | 8 + .../linux_config_init/tasks/set_perma_ip.yml | 9 + .../tasks/sudoer_no_passwd.yml | 8 + roles/linux_config_init/tasks/timezone.yml | 3 + roles/linux_config_init/templates/bashrc | 113 +++ roles/linux_config_init/templates/etc_hosts | 10 + .../templates/etc_network_interface | 16 + roles/linux_config_init/templates/resolvconf | 2 + roles/linux_config_init/vars/main.yml | 2 + roles/mariadb/.travis.yml | 29 + roles/mariadb/README.md | 38 + roles/mariadb/defaults/main.yml | 2 + roles/mariadb/handlers/main.yml | 6 + roles/mariadb/meta/main.yml | 52 ++ roles/mariadb/tasks/main.yml | 31 + roles/mariadb/templates/50-server.cnf | 118 ++++ roles/mariadb/tests/inventory | 2 + roles/mariadb/tests/test.yml | 5 + roles/mariadb/vars/main.yml | 2 + roles/nfs/.travis.yml | 29 + roles/nfs/README.md | 38 + roles/nfs/defaults/main.yml | 2 + roles/nfs/handlers/main.yml | 2 + roles/nfs/meta/main.yml | 52 ++ roles/nfs/tasks/main.yml | 22 + roles/nfs/tests/inventory | 2 + roles/nfs/tests/test.yml | 5 + roles/nfs/vars/main.yml | 2 + .../handlers/main.yml | 9 + roles/prometheus_node_exporter/tasks/main.yml | 12 + roles/samba/.travis.yml | 29 + roles/samba/README.md | 38 + roles/samba/defaults/main.yml | 2 + roles/samba/handlers/main.yml | 6 + roles/samba/meta/main.yml | 52 ++ roles/samba/tasks/main.yml | 21 + roles/samba/templates/smb.conf | 61 ++ roles/samba/tests/inventory | 2 + roles/samba/tests/test.yml | 5 + roles/samba/vars/main.yml | 2 + roles/security/LICENSE | 20 + roles/security/README.md | 126 ++++ roles/security/defaults/main.yml | 28 + roles/security/handlers/main.yml | 10 + roles/security/meta/main.yml | 30 + roles/security/molecule/default/converge.yml | 44 ++ roles/security/molecule/default/molecule.yml | 21 + roles/security/tasks/autoupdate-Debian.yml | 16 + roles/security/tasks/autoupdate-RedHat.yml | 35 + roles/security/tasks/fail2ban.yml | 29 + roles/security/tasks/main.yml | 21 + roles/security/tasks/ssh.yml | 34 + roles/security/templates/10periodic.j2 | 4 + .../templates/50unattended-upgrades.j2 | 20 + roles/security/templates/jail.local.j2 | 5 + roles/security/vars/Debian.yml | 3 + roles/security/vars/RedHat.yml | 3 + roles/template_differ/README.md | 38 + roles/template_differ/defaults/main.yml | 3 + roles/template_differ/handlers/main.yml | 10 + roles/template_differ/meta/main.yml | 35 + roles/template_differ/tasks/main.yml | 42 ++ roles/template_differ/templates/hosts | 7 + roles/template_differ/templates/interfaces | 15 + roles/template_differ/tests/inventory | 3 + roles/template_differ/tests/test.yml | 6 + roles/template_differ/vars/main.yml | 3 + roles/tools_for_command_line/.travis.yml | 29 + .../tools_for_command_line/defaults/main.yml | 2 + .../tools_for_command_line/handlers/main.yml | 2 + .../tasks/administration.yml | 39 ++ roles/tools_for_command_line/tasks/main.yml | 5 + roles/tools_for_command_line/tests/inventory | 2 + roles/tools_for_command_line/tests/test.yml | 5 + roles/tools_for_command_line/vars/main.yml | 2 + roles/wireguard_server/README.md | 38 + roles/wireguard_server/defaults/main.yml | 2 + roles/wireguard_server/handlers/main.yml | 6 + roles/wireguard_server/meta/main.yml | 52 ++ roles/wireguard_server/tasks/main.yml | 19 + .../templates/wireguardclient.conf | 14 + .../templates/wireguardserver.conf | 26 + roles/wireguard_server/tests/inventory | 2 + roles/wireguard_server/tests/test.yml | 5 + roles/wireguard_server/vars/main.yml | 2 + roles/zfs_install/.travis.yml | 29 + roles/zfs_install/README.md | 38 + roles/zfs_install/defaults/main.yml | 2 + roles/zfs_install/handlers/main.yml | 2 + roles/zfs_install/meta/main.yml | 52 ++ roles/zfs_install/tasks/main.yml | 23 + roles/zfs_install/tests/inventory | 2 + roles/zfs_install/tests/test.yml | 5 + roles/zfs_install/vars/main.yml | 2 + vault.yml | 75 -- 177 files changed, 4162 insertions(+), 77 deletions(-) create mode 100644 ansible.cfg rename README.md => docs/README.md (100%) rename command-to-run.txt => docs/command-to-run.txt (100%) create mode 100644 docs/commands_explained.md rename zeus-vars.yml => group_vars/all.yml (100%) create mode 100644 group_vars/vault.yml rename local-mv.yml => playbooks/hosts/local-mv.yml (100%) rename lxc.yml => playbooks/hosts/lxc.yml (94%) rename rpi.yml => playbooks/hosts/rpi.yml (100%) rename zeus.yml => playbooks/hosts/zeus.yml (100%) rename mariadb.yml => playbooks/services/mariadb.yml (100%) create mode 100644 playbooks/services/mysql.yml rename nfs.yaml => playbooks/services/nfs.yaml (100%) rename samba.yml => playbooks/services/samba.yml (100%) rename wireguard-cerberus.yml => playbooks/services/wireguard-cerberus.yml (100%) rename wireguard-client-gen.yml => playbooks/services/wireguard-client-gen.yml (100%) rename template-differ.yml => playbooks/template-differ.yml (100%) rename template.yml => playbooks/template.yml (100%) rename universal.yml => playbooks/universal.yml (100%) create mode 100644 roles/create_user/.travis.yml create mode 100644 roles/create_user/README.md create mode 100644 roles/create_user/defaults/main.yml create mode 100644 roles/create_user/handlers/main.yml create mode 100644 roles/create_user/meta/main.yml create mode 100644 roles/create_user/tasks/main.yml create mode 100644 roles/create_user/tests/inventory create mode 100644 roles/create_user/tests/test.yml create mode 100644 roles/create_user/vars/main.yml create mode 100644 roles/create_zfs_dataset/.travis.yml create mode 100644 roles/create_zfs_dataset/README.md create mode 100644 roles/create_zfs_dataset/defaults/main.yml create mode 100644 roles/create_zfs_dataset/handlers/main.yml create mode 100644 roles/create_zfs_dataset/meta/main.yml create mode 100644 roles/create_zfs_dataset/tasks/main.yml create mode 100644 roles/create_zfs_dataset/tests/inventory create mode 100644 roles/create_zfs_dataset/tests/test.yml create mode 100644 roles/create_zfs_dataset/vars/main.yml create mode 100644 roles/docker/.ansible-lint create mode 100644 roles/docker/.yamllint create mode 100644 roles/docker/LICENSE create mode 100644 roles/docker/README.md create mode 100644 roles/docker/defaults/main.yml create mode 100644 roles/docker/handlers/main.yml create mode 100644 roles/docker/meta/main.yml create mode 100644 roles/docker/molecule/default/converge.yml create mode 100644 roles/docker/molecule/default/molecule.yml create mode 100644 roles/docker/tasks/docker-compose.yml create mode 100644 roles/docker/tasks/docker-users.yml create mode 100644 roles/docker/tasks/main.yml create mode 100644 roles/docker/tasks/setup-Debian.yml create mode 100644 roles/docker/tasks/setup-RedHat.yml create mode 100755 roles/docker/vars/Alpine.yml create mode 100644 roles/docker/vars/Archlinux.yml create mode 100755 roles/docker/vars/main.yml create mode 100644 roles/docker_spin_up/.travis.yml create mode 100644 roles/docker_spin_up/README.md create mode 100644 roles/docker_spin_up/defaults/main.yml create mode 100644 roles/docker_spin_up/files/mailserver.env create mode 100644 roles/docker_spin_up/handlers/main.yml create mode 100644 roles/docker_spin_up/meta/main.yml create mode 100644 roles/docker_spin_up/tasks/dashboard_my_public.yml create mode 100644 roles/docker_spin_up/tasks/email.yml create mode 100644 roles/docker_spin_up/tasks/gitea.yml create mode 100644 roles/docker_spin_up/tasks/jellyfin.yml create mode 100644 roles/docker_spin_up/tasks/main.yml create mode 100644 roles/docker_spin_up/tasks/monitoring.yml create mode 100644 roles/docker_spin_up/tasks/nextcloud.yml create mode 100644 roles/docker_spin_up/tasks/nginx.yml create mode 100644 roles/docker_spin_up/tasks/pi-hole.yml create mode 100644 roles/docker_spin_up/tasks/transmission.yaml create mode 100644 roles/docker_spin_up/templates/promtail-config.yml create mode 100644 roles/docker_spin_up/tests/inventory create mode 100644 roles/docker_spin_up/tests/test.yml create mode 100644 roles/docker_spin_up/vars/main.yml create mode 100644 roles/linux_config_init/.travis.yml create mode 100644 roles/linux_config_init/defaults/main.yml create mode 100644 roles/linux_config_init/handlers/main.yml create mode 100644 roles/linux_config_init/tasks/bashrc_copy.yml create mode 100644 roles/linux_config_init/tasks/create_user.yml create mode 100644 roles/linux_config_init/tasks/hostname_set.yml create mode 100644 roles/linux_config_init/tasks/main.yml create mode 100644 roles/linux_config_init/tasks/resolvconf_copy.yml create mode 100644 roles/linux_config_init/tasks/set_perma_ip.yml create mode 100644 roles/linux_config_init/tasks/sudoer_no_passwd.yml create mode 100644 roles/linux_config_init/tasks/timezone.yml create mode 100644 roles/linux_config_init/templates/bashrc create mode 100644 roles/linux_config_init/templates/etc_hosts create mode 100644 roles/linux_config_init/templates/etc_network_interface create mode 100644 roles/linux_config_init/templates/resolvconf create mode 100644 roles/linux_config_init/vars/main.yml create mode 100644 roles/mariadb/.travis.yml create mode 100644 roles/mariadb/README.md create mode 100644 roles/mariadb/defaults/main.yml create mode 100644 roles/mariadb/handlers/main.yml create mode 100644 roles/mariadb/meta/main.yml create mode 100644 roles/mariadb/tasks/main.yml create mode 100644 roles/mariadb/templates/50-server.cnf create mode 100644 roles/mariadb/tests/inventory create mode 100644 roles/mariadb/tests/test.yml create mode 100644 roles/mariadb/vars/main.yml create mode 100644 roles/nfs/.travis.yml create mode 100644 roles/nfs/README.md create mode 100644 roles/nfs/defaults/main.yml create mode 100644 roles/nfs/handlers/main.yml create mode 100644 roles/nfs/meta/main.yml create mode 100644 roles/nfs/tasks/main.yml create mode 100644 roles/nfs/tests/inventory create mode 100644 roles/nfs/tests/test.yml create mode 100644 roles/nfs/vars/main.yml create mode 100644 roles/prometheus_node_exporter/handlers/main.yml create mode 100644 roles/prometheus_node_exporter/tasks/main.yml create mode 100644 roles/samba/.travis.yml create mode 100644 roles/samba/README.md create mode 100644 roles/samba/defaults/main.yml create mode 100644 roles/samba/handlers/main.yml create mode 100644 roles/samba/meta/main.yml create mode 100644 roles/samba/tasks/main.yml create mode 100644 roles/samba/templates/smb.conf create mode 100644 roles/samba/tests/inventory create mode 100644 roles/samba/tests/test.yml create mode 100644 roles/samba/vars/main.yml create mode 100644 roles/security/LICENSE create mode 100644 roles/security/README.md create mode 100644 roles/security/defaults/main.yml create mode 100644 roles/security/handlers/main.yml create mode 100644 roles/security/meta/main.yml create mode 100644 roles/security/molecule/default/converge.yml create mode 100644 roles/security/molecule/default/molecule.yml create mode 100644 roles/security/tasks/autoupdate-Debian.yml create mode 100644 roles/security/tasks/autoupdate-RedHat.yml create mode 100644 roles/security/tasks/fail2ban.yml create mode 100644 roles/security/tasks/main.yml create mode 100644 roles/security/tasks/ssh.yml create mode 100644 roles/security/templates/10periodic.j2 create mode 100644 roles/security/templates/50unattended-upgrades.j2 create mode 100644 roles/security/templates/jail.local.j2 create mode 100644 roles/security/vars/Debian.yml create mode 100644 roles/security/vars/RedHat.yml create mode 100644 roles/template_differ/README.md create mode 100644 roles/template_differ/defaults/main.yml create mode 100644 roles/template_differ/handlers/main.yml create mode 100644 roles/template_differ/meta/main.yml create mode 100644 roles/template_differ/tasks/main.yml create mode 100644 roles/template_differ/templates/hosts create mode 100644 roles/template_differ/templates/interfaces create mode 100644 roles/template_differ/tests/inventory create mode 100644 roles/template_differ/tests/test.yml create mode 100644 roles/template_differ/vars/main.yml create mode 100644 roles/tools_for_command_line/.travis.yml create mode 100644 roles/tools_for_command_line/defaults/main.yml create mode 100644 roles/tools_for_command_line/handlers/main.yml create mode 100644 roles/tools_for_command_line/tasks/administration.yml create mode 100644 roles/tools_for_command_line/tasks/main.yml create mode 100644 roles/tools_for_command_line/tests/inventory create mode 100644 roles/tools_for_command_line/tests/test.yml create mode 100644 roles/tools_for_command_line/vars/main.yml create mode 100644 roles/wireguard_server/README.md create mode 100644 roles/wireguard_server/defaults/main.yml create mode 100644 roles/wireguard_server/handlers/main.yml create mode 100644 roles/wireguard_server/meta/main.yml create mode 100644 roles/wireguard_server/tasks/main.yml create mode 100644 roles/wireguard_server/templates/wireguardclient.conf create mode 100644 roles/wireguard_server/templates/wireguardserver.conf create mode 100644 roles/wireguard_server/tests/inventory create mode 100644 roles/wireguard_server/tests/test.yml create mode 100644 roles/wireguard_server/vars/main.yml create mode 100644 roles/zfs_install/.travis.yml create mode 100644 roles/zfs_install/README.md create mode 100644 roles/zfs_install/defaults/main.yml create mode 100644 roles/zfs_install/handlers/main.yml create mode 100644 roles/zfs_install/meta/main.yml create mode 100644 roles/zfs_install/tasks/main.yml create mode 100644 roles/zfs_install/tests/inventory create mode 100644 roles/zfs_install/tests/test.yml create mode 100644 roles/zfs_install/vars/main.yml delete mode 100644 vault.yml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..002a50d --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +roles_path = ./roles diff --git a/README.md b/docs/README.md similarity index 100% rename from README.md rename to docs/README.md diff --git a/command-to-run.txt b/docs/command-to-run.txt similarity index 100% rename from command-to-run.txt rename to docs/command-to-run.txt diff --git a/docs/commands_explained.md b/docs/commands_explained.md new file mode 100644 index 0000000..e75a451 --- /dev/null +++ b/docs/commands_explained.md @@ -0,0 +1,28 @@ +Here is an explanation of the commands in your `command-to-run.txt` file: + +* `ansible-playbook --ask-vault-pass -i inventory playbook.yml`: This command executes an Ansible playbook. + * `ansible-playbook`: The command to run a playbook. + * `--ask-vault-pass`: Prompts for the Ansible Vault password to decrypt any encrypted files or variables. + * `-i inventory`: Specifies the inventory file to use. + * `playbook.yml`: The playbook file to execute. + +* `ansible-galaxy role init {role-to-create}`: This command initializes a new Ansible role with a directory structure. + * `ansible-galaxy`: The command for managing Ansible roles. + * `role init`: The subcommand to initialize a new role. + * `{role-to-create}`: The name of the role to create. + +* `ansible-vault edit vault.yml`: This command edits a file encrypted with Ansible Vault. + * `ansible-vault`: The command for managing Ansible Vault. + * `edit`: The subcommand to edit an encrypted file. + * `vault.yml`: The encrypted file to edit. + +* `ansible -m ping -i inventory --ask-pass {machine}`: This command checks the connectivity to a managed node. + * `ansible`: The command to run ad-hoc Ansible commands. + * `-m ping`: Specifies the `ping` module to use. + * `-i inventory`: Specifies the inventory file to use. + * `--ask-pass`: Prompts for the SSH password. + * `{machine}`: The managed node to ping. + +* `mkpasswd --method=sha-512`: This command creates a hashed password. + * `mkpasswd`: The command to create a password. + * `--method=sha-512`: Specifies the hashing algorithm to use (SHA-512). diff --git a/zeus-vars.yml b/group_vars/all.yml similarity index 100% rename from zeus-vars.yml rename to group_vars/all.yml diff --git a/group_vars/vault.yml b/group_vars/vault.yml new file mode 100644 index 0000000..34e3eb7 --- /dev/null +++ b/group_vars/vault.yml @@ -0,0 +1,74 @@ +$ANSIBLE_VAULT;1.1;AES256 +38613131316430376334633964346466393863323361666237656665373431303832323963646435 +3634613636343730643964386338663064343833643038340a643063376261393033363138313138 +64643532323830616439393134333064376636303264653830636261333031366133383563636531 +6538666365353961390a653435356162366365626463376534653861306164353336656637383833 +61393337356566356363623564343131306134393061656438333238333435613739633633636633 +39616362393139326233363962313661616537663238383932623531653164363461313736313064 +36316530623831626433643965633035616163653934313136333266326239353563356338393733 +66353935626633626530633764663432623139633634333164656133623662323061303632343036 +36653039666331326165636237333233366465653164316335636437383930663436313433363832 +38663830633839623631653032356235396531646561626165316231313331633834386164356135 +30323730373161643563326262663938346261663535646230313965653630643264653236333438 +61316631306530333239323131326534396666613132383562363864363334373331333964303431 +34306639376666306132326438336165303333376661343034363130323865376565383631616135 +64656133636262373866383637653061653866323539346561643833333832373730323939303266 +34623462666163613330383166306137653533313932626334616666366334313437653534623032 +66353533383930616132346536653937353138623566646137383863613338326332366561656133 +61656238393836396663663535646637333264666636313036343936333266333264333962636139 +66633565643465653830386263306634366562373332373630656338346138323631353365393737 +66623339366534323563383135663138316331333539346336643233616661663966333638333661 +30313636373037623661393962343536323961663039636462373762356463373536636137613938 +33353230303132323237643634623935336263656134326530636462306430626563373166343538 +31633030316331613836363037613938663636316364343731613033613865653634306361343465 +61663032356435626361616666616661346437616233653632303037346265323036386565326431 +63313963653766343262373962383161313037393032626463373839656237393461653865336561 +38613863353634306338333062356136393662653934623863343966346562316261343135376538 +65343863376664646465303436626133653834326362323763373562373137383461376561643366 +31333637373731396136376366396131363432616335366236663566363062336165643130326531 +32393364306139656338613332656335316434613632356539653562653261393837363366383531 +64626266656265336431363836643663633437626262386264616364626634396631373632303764 +66623131636137346339386638313634643364626666326236323864623666656138333338623834 +61613433646261303338656663376633376266346232303838316232623162346336333636663861 +32366535353039383738613963313061313766643361313239363438356566306666646561653963 +39633462613064643830326432313038346237326435636234663364343136336333306131646234 +35616365616134366238386137616564376164303435363635643535626438303364363065396431 +37663532613261666166616331653730376639376663656334376332656336656536363931393563 +39613164666333643835666134396464663531656639636136316662323533386438616237303638 +33613965643137626661373062616163326433356164346666613438303635653664376435353966 +34623836636537343461643966656265643236373431343635663866343964306235326561373663 +66313330633139383639336234303434613761643466386235303765366637626364316162376437 +66666630663736383231653139646334376566303631313034366439383139343561653637336264 +38636239643163613630373964343363353161356462373938376165656535313539643762623062 +61333036343039326534373064396462363765333163396434626636323362343563643965313635 +35396365333633326164336332313630313131373031633633653466333831333735373636346330 +62366561313064386664326337333064626265623132643362636630356233663635663535643433 +62643764346137663238623864396263316336336336646666376431633835613937613833633730 +35303264356437313061366264613265636133613765336137653866373632366231656638336635 +34646437376265666333643636376562373066316166313439313630313263663533306337623631 +64356335353530643531306432343762306163333935616535653231633564663437393965343061 +38386335353732353832653634313836373435383531663338386464346238656633326235623230 +63343364346137626539626337633038306335366433363933333336396639333662313437323365 +36386265333931623230616131353830653161643162363939623038646563656138653665343366 +66636463396666303265303934363465393437653666336465623362383134313837633630353733 +65343932656164346339663966393931353030636561633130356230613332613332373965386132 +64613331356137303763366438373637626361326233306561303438613231646330393935373766 +37363239356231323935626664323136313765633965323536663365616464613639653464326133 +66396464346463353834633736303634343733336431366131323432336336666664643934663238 +34356264356635656434386536656466633331373661396661626133303632626436323830373866 +64373534633039306663363937393361656164633739333532336239663532623830363831643930 +62333562323131323735313661643331333861373365623661656635613363623662633336396233 +32323762656466623861386361353932306637363035316539386365373031363961303931663566 +32656538623062373632643134336366393534373830313439623661353435656363626166623936 +33346134633366366565326465303537316138363264633635316137623436333733633638346465 +37376166366332653434623763636538623162353432656330373539323366663763613538343531 +32353234626262653834653333373831373166643263646336616362343331646138343165646132 +38643939323736313833323962356434333630623766663833656239653333323832646230383037 +39346362653835333535646234646335366134386330616539353761663461356463323961666537 +36383265326463306362393062623464616338633033306263363661306135613136343363313262 +30633138343666663763613835323366623732343664316562386431653735313832333435633763 +33373235663661383332353330613637653138616162623030373237353963663634343137363066 +61383630333133343461633461626562653064356431303162353662343939653164643662626664 +32353530303562343138386164656362646133356630626263333361346131636637343734383633 +30313666383033343966323764616530353030643334663737393035313535393466366138323839 +63356439353165326263343839306137643031643832313931316563646137666439 diff --git a/inventory b/inventory index 2915026..1eba812 100644 --- a/inventory +++ b/inventory @@ -29,6 +29,7 @@ minecraft jellyfin transmission uptimekuma +photoprism [temp] ollama diff --git a/local-mv.yml b/playbooks/hosts/local-mv.yml similarity index 100% rename from local-mv.yml rename to playbooks/hosts/local-mv.yml diff --git a/lxc.yml b/playbooks/hosts/lxc.yml similarity index 94% rename from lxc.yml rename to playbooks/hosts/lxc.yml index eea020e..ac63b23 100644 --- a/lxc.yml +++ b/playbooks/hosts/lxc.yml @@ -1,6 +1,6 @@ - name: lxc-init - hosts: n8n - #become: true + hosts: photoprism + become: true vars_files: - vault.yml - zeus-vars.yml diff --git a/rpi.yml b/playbooks/hosts/rpi.yml similarity index 100% rename from rpi.yml rename to playbooks/hosts/rpi.yml diff --git a/zeus.yml b/playbooks/hosts/zeus.yml similarity index 100% rename from zeus.yml rename to playbooks/hosts/zeus.yml diff --git a/mariadb.yml b/playbooks/services/mariadb.yml similarity index 100% rename from mariadb.yml rename to playbooks/services/mariadb.yml diff --git a/playbooks/services/mysql.yml b/playbooks/services/mysql.yml new file mode 100644 index 0000000..c751e63 --- /dev/null +++ b/playbooks/services/mysql.yml @@ -0,0 +1,37 @@ +--- +- name: Setup MySQL database and user + hosts: mariadb + vars_files: + - vault.yml + - zeus-vars.yml + become: yes + vars: + mysql_database: "{{ UPTIMEKUMA.MYSQL_DATABASE }}" # Replace with your desired database name + mysql_user: "{{ UPTIMEKUMA.MYSQL_USER }}" # Replace with your desired database user + mysql_password: "{{ UPTIMEKUMA.MYSQL_PASSWORD }}" # Replace with your desired database user password + + tasks: + - name: Create MySQL database + community.mysql.mysql_db: + name: "{{ mysql_database }}" + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + + - name: Create MySQL user + community.mysql.mysql_user: + name: "{{ mysql_user }}" + password: "{{ mysql_password }}" + priv: "{{ mysql_database }}.*:ALL" + host: "%" + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + + - name: Grant privileges to MySQL user on the database + community.mysql.mysql_user: + name: "{{ mysql_user }}" + host: "%" + password: "{{ mysql_password }}" + priv: "{{ mysql_database }}.*:ALL,GRANT" + state: present + login_unix_socket: /var/run/mysqld/mysqld.sock + append_privs: yes diff --git a/nfs.yaml b/playbooks/services/nfs.yaml similarity index 100% rename from nfs.yaml rename to playbooks/services/nfs.yaml diff --git a/samba.yml b/playbooks/services/samba.yml similarity index 100% rename from samba.yml rename to playbooks/services/samba.yml diff --git a/wireguard-cerberus.yml b/playbooks/services/wireguard-cerberus.yml similarity index 100% rename from wireguard-cerberus.yml rename to playbooks/services/wireguard-cerberus.yml diff --git a/wireguard-client-gen.yml b/playbooks/services/wireguard-client-gen.yml similarity index 100% rename from wireguard-client-gen.yml rename to playbooks/services/wireguard-client-gen.yml diff --git a/template-differ.yml b/playbooks/template-differ.yml similarity index 100% rename from template-differ.yml rename to playbooks/template-differ.yml diff --git a/template.yml b/playbooks/template.yml similarity index 100% rename from template.yml rename to playbooks/template.yml diff --git a/universal.yml b/playbooks/universal.yml similarity index 100% rename from universal.yml rename to playbooks/universal.yml diff --git a/roles/create_user/.travis.yml b/roles/create_user/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/create_user/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/create_user/README.md b/roles/create_user/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/create_user/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/create_user/defaults/main.yml b/roles/create_user/defaults/main.yml new file mode 100644 index 0000000..e1be6a2 --- /dev/null +++ b/roles/create_user/defaults/main.yml @@ -0,0 +1,8 @@ +--- +# defaults file for create_user +primary_group: "{{ user }}" +secondary_groups: '' +password: '' +shell: "/bin/bash" +home: "/home/{{ user }}" +create_home: "{{ 'false' if (home == '/nonexistent') else 'true'}}" \ No newline at end of file diff --git a/roles/create_user/handlers/main.yml b/roles/create_user/handlers/main.yml new file mode 100644 index 0000000..32e3928 --- /dev/null +++ b/roles/create_user/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for create_user diff --git a/roles/create_user/meta/main.yml b/roles/create_user/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/create_user/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/create_user/tasks/main.yml b/roles/create_user/tasks/main.yml new file mode 100644 index 0000000..ace3b43 --- /dev/null +++ b/roles/create_user/tasks/main.yml @@ -0,0 +1,48 @@ +--- +# tasks file for create_user +- name: Adding group + ansible.builtin.group: + name: "{{ primary_group }}" + gid: "{{ gid }}" + state: present + when: gid != 65534 + +- name: Adding user + ansible.builtin.user: + name: "{{ user }}" + group: "{{ primary_group }}" + uid: "{{ uid }}" + shell: "{{ shell }}" + groups: "{{ secondary_groups }}" + home: "{{ home }}" + password: "{{ password }}" + create_home: "{{ create_home }}" + +- name: Dowload ssh key + ansible.builtin.uri: + url: "{{ user_ssh_key_url }}" + method: GET + return_content: true + register: ssh_key + when: user_ssh_key_url is defined + +- name: Setting ssh key + ansible.builtin.blockinfile: + state: present + owner: "{{ user }}" + group: "{{ primary_group }}" + insertafter: EOF + path: /home/{{ user }}/.ssh/authorized_keys + mode: '0644' + create: true + block: | + {{ ssh_key.content }} + when: user_ssh_key_url is defined + +- name: Set permissions to .ssh folder + ansible.builtin.file: + path: /home/{{ user }}/.ssh + owner: "{{ user }}" + group: "{{ primary_group }}" + mode: '0711' + when: user_ssh_key_url is defined diff --git a/roles/create_user/tests/inventory b/roles/create_user/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/create_user/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/create_user/tests/test.yml b/roles/create_user/tests/test.yml new file mode 100644 index 0000000..53baf4f --- /dev/null +++ b/roles/create_user/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - create_user diff --git a/roles/create_user/vars/main.yml b/roles/create_user/vars/main.yml new file mode 100644 index 0000000..df5579e --- /dev/null +++ b/roles/create_user/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for create_user diff --git a/roles/create_zfs_dataset/.travis.yml b/roles/create_zfs_dataset/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/create_zfs_dataset/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/create_zfs_dataset/README.md b/roles/create_zfs_dataset/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/create_zfs_dataset/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/create_zfs_dataset/defaults/main.yml b/roles/create_zfs_dataset/defaults/main.yml new file mode 100644 index 0000000..fa8f2e2 --- /dev/null +++ b/roles/create_zfs_dataset/defaults/main.yml @@ -0,0 +1,6 @@ +--- +# defaults file for create_zfs_dataset +zfs_dataset_size: 10M +zfs_dataset_mountpoint: "/{{ zfs_pool_name }}/{{ zfs_dataset_name }}" +zfs_dataset_user: root +zfs_dataset_group: root diff --git a/roles/create_zfs_dataset/handlers/main.yml b/roles/create_zfs_dataset/handlers/main.yml new file mode 100644 index 0000000..2dc50ec --- /dev/null +++ b/roles/create_zfs_dataset/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for create_zfs_dataset diff --git a/roles/create_zfs_dataset/meta/main.yml b/roles/create_zfs_dataset/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/create_zfs_dataset/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/create_zfs_dataset/tasks/main.yml b/roles/create_zfs_dataset/tasks/main.yml new file mode 100644 index 0000000..2198e4f --- /dev/null +++ b/roles/create_zfs_dataset/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# tasks file for create_zfs_dataset +- name: Create zfs dataset + community.general.zfs: + name: "{{ zfs_pool_name }}/{{ zfs_dataset_name }}" + state: present + extra_zfs_properties: + quota: "{{ zfs_dataset_size }}" + mountpoint: "{{ zfs_dataset_mountpoint }}" + +- name: Dir Ownershipt to {{ user }} + ansible.builtin.file: + path: "{{ zfs_dataset_mountpoint }}" + owner: "{{ zfs_dataset_user }}" + group: "{{ zfs_dataset_group }}" + mode: '0731' diff --git a/roles/create_zfs_dataset/tests/inventory b/roles/create_zfs_dataset/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/create_zfs_dataset/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/create_zfs_dataset/tests/test.yml b/roles/create_zfs_dataset/tests/test.yml new file mode 100644 index 0000000..b4850b1 --- /dev/null +++ b/roles/create_zfs_dataset/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - create_zfs_dataset diff --git a/roles/create_zfs_dataset/vars/main.yml b/roles/create_zfs_dataset/vars/main.yml new file mode 100644 index 0000000..8b91343 --- /dev/null +++ b/roles/create_zfs_dataset/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for create_zfs_dataset diff --git a/roles/docker/.ansible-lint b/roles/docker/.ansible-lint new file mode 100644 index 0000000..2cd8c9f --- /dev/null +++ b/roles/docker/.ansible-lint @@ -0,0 +1,4 @@ +skip_list: + - 'yaml' + - 'risky-shell-pipe' + - 'role-name' diff --git a/roles/docker/.yamllint b/roles/docker/.yamllint new file mode 100644 index 0000000..e6fc538 --- /dev/null +++ b/roles/docker/.yamllint @@ -0,0 +1,11 @@ +--- +extends: default + +rules: + line-length: + max: 200 + level: warning + +ignore: | + .github/stale.yml + .travis.yml diff --git a/roles/docker/LICENSE b/roles/docker/LICENSE new file mode 100644 index 0000000..4275cf3 --- /dev/null +++ b/roles/docker/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Jeff Geerling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/docker/README.md b/roles/docker/README.md new file mode 100644 index 0000000..2f23291 --- /dev/null +++ b/roles/docker/README.md @@ -0,0 +1,128 @@ +# Ansible Role: Docker + +[![CI](https://github.com/geerlingguy/ansible-role-docker/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-docker/actions?query=workflow%3ACI) + +An Ansible Role that installs [Docker](https://www.docker.com) on Linux. + +## Requirements + +None. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + # Edition can be one of: 'ce' (Community Edition) or 'ee' (Enterprise Edition). + docker_edition: 'ce' + docker_packages: + - "docker-{{ docker_edition }}" + - "docker-{{ docker_edition }}-cli" + - "docker-{{ docker_edition }}-rootless-extras" + docker_packages_state: present + +The `docker_edition` should be either `ce` (Community Edition) or `ee` (Enterprise Edition). +You can also specify a specific version of Docker to install using the distribution-specific format: +Red Hat/CentOS: `docker-{{ docker_edition }}-` (Note: you have to add this to all packages); +Debian/Ubuntu: `docker-{{ docker_edition }}=` (Note: you have to add this to all packages). + +You can control whether the package is installed, uninstalled, or at the latest version by setting `docker_package_state` to `present`, `absent`, or `latest`, respectively. Note that the Docker daemon will be automatically restarted if the Docker package is updated. This is a side effect of flushing all handlers (running any of the handlers that have been notified by this and any other role up to this point in the play). + + docker_service_manage: true + docker_service_state: started + docker_service_enabled: true + docker_restart_handler_state: restarted + +Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set `docker_service_manage` to `false`. + + docker_install_compose_plugin: false + docker_compose_package: docker-compose-plugin + docker_compose_package_state: present + +Docker Compose Plugin installation options. These differ from the below in that docker-compose is installed as a docker plugin (and used with `docker compose`) instead of a standalone binary. + + docker_install_compose: true + docker_compose_version: "1.26.0" + docker_compose_arch: "{{ ansible_architecture }}" + docker_compose_path: /usr/local/bin/docker-compose + +Docker Compose installation options. + + docker_repo_url: https://download.docker.com/linux + +The main Docker repo URL, common between Debian and RHEL systems. + + docker_apt_release_channel: stable + docker_apt_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}" + docker_apt_repository: "deb [arch={{ docker_apt_arch }}] {{ docker_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" + docker_apt_ignore_key_error: True + docker_apt_gpg_key: "{{ docker_repo_url }}/{{ ansible_distribution | lower }}/gpg" + +(Used only for Debian/Ubuntu.) You can switch the channel to `nightly` if you want to use the Nightly release. + +You can change `docker_apt_gpg_key` to a different url if you are behind a firewall or provide a trustworthy mirror. +Usually in combination with changing `docker_apt_repository` as well. + + docker_yum_repo_url: "{{ docker_repo_url }}/{{ (ansible_distribution == 'Fedora') | ternary('fedora','centos') }}/docker-{{ docker_edition }}.repo"docker_edition }}.repo + docker_yum_repo_enable_nightly: '0' + docker_yum_repo_enable_test: '0' + docker_yum_gpg_key: "{{ docker_repo_url }}/centos/gpg" + +(Used only for RedHat/CentOS.) You can enable the Nightly or Test repo by setting the respective vars to `1`. + +You can change `docker_yum_gpg_key` to a different url if you are behind a firewall or provide a trustworthy mirror. +Usually in combination with changing `docker_yum_repository` as well. + + docker_users: + - user1 + - user2 + +A list of system users to be added to the `docker` group (so they can use Docker on the server). + + docker_daemon_options: + storage-driver: "devicemapper" + log-opts: + max-size: "100m" + +Custom `dockerd` options can be configured through this dictionary representing the json file `/etc/docker/daemon.json`. + +## Use with Ansible (and `docker` Python library) + +Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role: + +```yaml +- hosts: all + + vars: + pip_install_packages: + - name: docker + + roles: + - geerlingguy.pip + - geerlingguy.docker +``` + +## Dependencies + +None. + +## Example Playbook + +```yaml +- hosts: all + roles: + - geerlingguy.docker +``` + +## License + +MIT / BSD + +## Sponsors + +* [We Manage](https://we-manage.de): Helping start-ups and grown-ups scaling their infrastructure in a sustainable way. + +The above sponsor(s) are supporting Jeff Geerling on [GitHub Sponsors](https://github.com/sponsors/geerlingguy). You can sponsor Jeff's work too, to help him continue improving these Ansible open source projects! + +## Author Information + +This role was created in 2017 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml new file mode 100644 index 0000000..685b8de --- /dev/null +++ b/roles/docker/defaults/main.yml @@ -0,0 +1,49 @@ +--- +# Edition can be one of: 'ce' (Community Edition) or 'ee' (Enterprise Edition). +docker_edition: 'ce' +docker_packages: + - "docker-{{ docker_edition }}" + - "docker-{{ docker_edition }}-cli" + - "docker-{{ docker_edition }}-rootless-extras" + - "containerd.io" +docker_packages_state: present + +# Service options. +docker_service_manage: true +docker_service_state: started +docker_service_enabled: true +docker_restart_handler_state: restarted + +# Docker Compose Plugin options. +docker_install_compose_plugin: false +docker_compose_package: docker-compose-plugin +docker_compose_package_state: present + +# Docker Compose options. +docker_install_compose: true +docker_compose_version: "v2.11.1" +docker_compose_arch: "{{ ansible_architecture }}" +docker_compose_url: "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-linux-{{ docker_compose_arch }}" +docker_compose_path: /usr/local/bin/docker-compose + +# Docker repo URL. +docker_repo_url: https://download.docker.com/linux + +# Used only for Debian/Ubuntu. Switch 'stable' to 'nightly' if needed. +docker_apt_release_channel: stable +docker_apt_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}" +docker_apt_repository: "deb [arch={{ docker_apt_arch }}] {{ docker_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" +docker_apt_ignore_key_error: true +docker_apt_gpg_key: "{{ docker_repo_url }}/{{ ansible_distribution | lower }}/gpg" + +# Used only for RedHat/CentOS/Fedora. +docker_yum_repo_url: "{{ docker_repo_url }}/{{ (ansible_distribution == 'Fedora') | ternary('fedora','centos') }}/docker-{{ docker_edition }}.repo" +docker_yum_repo_enable_nightly: '0' +docker_yum_repo_enable_test: '0' +docker_yum_gpg_key: "{{ docker_repo_url }}/centos/gpg" + +# A list of users who will be added to the docker group. +docker_users: [] + +# Docker daemon options as a dict +docker_daemon_options: {} diff --git a/roles/docker/handlers/main.yml b/roles/docker/handlers/main.yml new file mode 100644 index 0000000..72594c8 --- /dev/null +++ b/roles/docker/handlers/main.yml @@ -0,0 +1,7 @@ +--- +- name: restart docker + service: + name: docker + state: "{{ docker_restart_handler_state }}" + ignore_errors: "{{ ansible_check_mode }}" + when: docker_service_manage | bool diff --git a/roles/docker/meta/main.yml b/roles/docker/meta/main.yml new file mode 100644 index 0000000..edc5f8e --- /dev/null +++ b/roles/docker/meta/main.yml @@ -0,0 +1,41 @@ +--- +dependencies: [] + +galaxy_info: + role_name: docker + author: geerlingguy + description: Docker for Linux. + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 2.4 + platforms: + - name: EL + versions: + - 7 + - 8 + - name: Fedora + versions: + - all + - name: Debian + versions: + - buster + - bullseye + - name: Ubuntu + versions: + - bionic + - focal + - jammy + - name: Alpine + version: + - all + - name: ArchLinux + versions: + - all + galaxy_tags: + - web + - system + - containers + - docker + - orchestration + - compose + - server diff --git a/roles/docker/molecule/default/converge.yml b/roles/docker/molecule/default/converge.yml new file mode 100644 index 0000000..629095b --- /dev/null +++ b/roles/docker/molecule/default/converge.yml @@ -0,0 +1,24 @@ +--- +- name: Converge + hosts: all + become: true + + pre_tasks: + - name: Update apt cache. + apt: update_cache=yes cache_valid_time=600 + when: ansible_os_family == 'Debian' + + - name: Wait for systemd to complete initialization. # noqa 303 + command: systemctl is-system-running + register: systemctl_status + until: > + 'running' in systemctl_status.stdout or + 'degraded' in systemctl_status.stdout + retries: 30 + delay: 5 + when: ansible_service_mgr == 'systemd' + changed_when: false + failed_when: systemctl_status.rc > 1 + + roles: + - role: geerlingguy.docker diff --git a/roles/docker/molecule/default/molecule.yml b/roles/docker/molecule/default/molecule.yml new file mode 100644 index 0000000..d291e5b --- /dev/null +++ b/roles/docker/molecule/default/molecule.yml @@ -0,0 +1,19 @@ +--- +role_name_check: 1 +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + cgroupns_mode: host + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} diff --git a/roles/docker/tasks/docker-compose.yml b/roles/docker/tasks/docker-compose.yml new file mode 100644 index 0000000..53a4482 --- /dev/null +++ b/roles/docker/tasks/docker-compose.yml @@ -0,0 +1,31 @@ +--- +- name: Check current docker-compose version. + command: "{{ docker_compose_path }} --version" + register: docker_compose_vsn + check_mode: false + changed_when: false + failed_when: false + +- set_fact: + docker_compose_current_version: "{{ docker_compose_vsn.stdout | regex_search('(\\d+(\\.\\d+)+)') }}" + when: > + docker_compose_vsn.stdout is defined + and (docker_compose_vsn.stdout | length > 0) + +- name: Delete existing docker-compose version if it's different. + file: + path: "{{ docker_compose_path }}" + state: absent + when: > + docker_compose_current_version is defined + and (docker_compose_version | regex_replace('v', '')) not in docker_compose_current_version + +- name: Install Docker Compose (if configured). + get_url: + url: "{{ docker_compose_url }}" + dest: "{{ docker_compose_path }}" + mode: 0755 + when: > + (docker_compose_current_version is not defined) + or (docker_compose_current_version | length == 0) + or (docker_compose_current_version is version((docker_compose_version | regex_replace('v', '')), '<')) diff --git a/roles/docker/tasks/docker-users.yml b/roles/docker/tasks/docker-users.yml new file mode 100644 index 0000000..6e387e6 --- /dev/null +++ b/roles/docker/tasks/docker-users.yml @@ -0,0 +1,10 @@ +--- +- name: Ensure docker users are added to the docker group. + user: + name: "{{ item }}" + groups: docker + append: true + with_items: "{{ docker_users }}" + +- name: Reset ssh connection to apply user changes. + meta: reset_connection diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml new file mode 100644 index 0000000..fe7dc43 --- /dev/null +++ b/roles/docker/tasks/main.yml @@ -0,0 +1,117 @@ +--- +- name: Load OS-specific vars. + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - '{{ansible_distribution}}.yml' + - '{{ansible_os_family}}.yml' + - main.yml + paths: + - 'vars' + +- include_tasks: setup-RedHat.yml + when: ansible_os_family == 'RedHat' + +- include_tasks: setup-Debian.yml + when: ansible_os_family == 'Debian' + +- name: Install Docker packages. + package: + name: "{{ docker_packages }}" + state: "{{ docker_packages_state }}" + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian']" + +- name: Install Docker packages (with downgrade option). + package: + name: "{{ docker_packages }}" + state: "{{ docker_packages_state }}" + allow_downgrade: true + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']" + +- name: Install docker-compose plugin. + package: + name: "{{ docker_compose_package }}" + state: "{{ docker_compose_package_state }}" + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "docker_install_compose_plugin | bool == true and (ansible_version.full is version_compare('2.12', '<') or ansible_os_family not in ['RedHat', 'Debian'])" + +- name: Install docker-compose-plugin (with downgrade option). + package: + name: "{{ docker_compose_package }}" + state: "{{ docker_compose_package_state }}" + allow_downgrade: true + notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" + when: "docker_install_compose_plugin | bool == true and ansible_version.full is version_compare('2.12', '>=') and ansible_os_family in ['RedHat', 'Debian']" + +- name: Ensure /etc/docker/ directory exists. + file: + path: /etc/docker + state: directory + mode: 0755 + when: docker_daemon_options.keys() | length > 0 + +- name: Configure Docker daemon options. + copy: + content: "{{ docker_daemon_options | to_nice_json }}" + dest: /etc/docker/daemon.json + mode: 0644 + when: docker_daemon_options.keys() | length > 0 + notify: restart docker + +- name: Ensure Docker is started and enabled at boot. + service: + name: docker + state: "{{ docker_service_state }}" + enabled: "{{ docker_service_enabled }}" + ignore_errors: "{{ ansible_check_mode }}" + when: docker_service_manage | bool + +- name: Ensure handlers are notified now to avoid firewall conflicts. + meta: flush_handlers + +- include_tasks: docker-compose.yml + when: docker_install_compose | bool + +- name: Get docker group info using getent. + getent: + database: group + key: docker + split: ':' + when: docker_users | length > 0 + +- name: Check if there are any users to add to the docker group. + set_fact: + at_least_one_user_to_modify: true + when: + - docker_users | length > 0 + - item not in ansible_facts.getent_group["docker"][2] + with_items: "{{ docker_users }}" + +- include_tasks: docker-users.yml + when: at_least_one_user_to_modify is defined + + +- name: Install docker python package + ansible.builtin.pip: + name: docker + extra_args: "--break-system-packages" + +- name: Install a promtail plugin + community.docker.docker_plugin: + plugin_name: grafana/loki-docker-driver:latest + state: present + alias: loki + +- name: Enable a promtail plugin + community.docker.docker_plugin: + plugin_name: grafana/loki-docker-driver:latest + state: enable + alias: loki + notify: restart docker \ No newline at end of file diff --git a/roles/docker/tasks/setup-Debian.yml b/roles/docker/tasks/setup-Debian.yml new file mode 100644 index 0000000..27ef57b --- /dev/null +++ b/roles/docker/tasks/setup-Debian.yml @@ -0,0 +1,50 @@ +--- +- name: Ensure old versions of Docker are not installed. + package: + name: + - docker + - docker-engine + state: absent + +- name: Ensure dependencies are installed. + apt: + name: + - apt-transport-https + - ca-certificates + state: present + +- name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems). + apt: + name: gnupg2 + state: present + when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<') + +- name: Ensure additional dependencies are installed (on Ubuntu >= 20.04). + apt: + name: gnupg + state: present + when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=') + +- name: Add Docker apt key. + ansible.builtin.get_url: + url: "{{ docker_apt_gpg_key }}" + dest: /etc/apt/trusted.gpg.d/docker.asc + mode: '0644' + force: true + register: add_repository_key + ignore_errors: "{{ docker_apt_ignore_key_error }}" + +- name: Ensure curl is present (on older systems without SNI). + package: name=curl state=present + when: add_repository_key is failed + +- name: Add Docker apt key (alternative for older systems without SNI). + shell: > + curl -sSL {{ docker_apt_gpg_key }} | apt-key add - + when: add_repository_key is failed + +- name: Add Docker repository. + apt_repository: + repo: "{{ docker_apt_repository }}" + state: present + update_cache: true diff --git a/roles/docker/tasks/setup-RedHat.yml b/roles/docker/tasks/setup-RedHat.yml new file mode 100644 index 0000000..676c9e5 --- /dev/null +++ b/roles/docker/tasks/setup-RedHat.yml @@ -0,0 +1,52 @@ +--- +- name: Ensure old versions of Docker are not installed. + package: + name: + - docker + - docker-common + - docker-engine + state: absent + +- name: Add Docker GPG key. + rpm_key: + key: "{{ docker_yum_gpg_key }}" + state: present + +- name: Add Docker repository. + get_url: + url: "{{ docker_yum_repo_url }}" + dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo' + owner: root + group: root + mode: 0644 + +- name: Configure Docker Nightly repo. + ini_file: + dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo' + section: 'docker-{{ docker_edition }}-nightly' + option: enabled + value: '{{ docker_yum_repo_enable_nightly }}' + mode: 0644 + no_extra_spaces: true + +- name: Configure Docker Test repo. + ini_file: + dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo' + section: 'docker-{{ docker_edition }}-test' + option: enabled + value: '{{ docker_yum_repo_enable_test }}' + mode: 0644 + no_extra_spaces: true + +- name: Configure containerd on RHEL 8. + block: + - name: Ensure container-selinux is installed. + package: + name: container-selinux + state: present + + - name: Ensure containerd.io is installed. + package: + name: containerd.io + state: present + when: ansible_distribution_major_version | int == 8 diff --git a/roles/docker/vars/Alpine.yml b/roles/docker/vars/Alpine.yml new file mode 100755 index 0000000..b81917a --- /dev/null +++ b/roles/docker/vars/Alpine.yml @@ -0,0 +1,2 @@ +--- +docker_packages: "docker" diff --git a/roles/docker/vars/Archlinux.yml b/roles/docker/vars/Archlinux.yml new file mode 100644 index 0000000..b81917a --- /dev/null +++ b/roles/docker/vars/Archlinux.yml @@ -0,0 +1,2 @@ +--- +docker_packages: "docker" diff --git a/roles/docker/vars/main.yml b/roles/docker/vars/main.yml new file mode 100755 index 0000000..805232b --- /dev/null +++ b/roles/docker/vars/main.yml @@ -0,0 +1,2 @@ +--- +# Empty file diff --git a/roles/docker_spin_up/.travis.yml b/roles/docker_spin_up/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/docker_spin_up/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/docker_spin_up/README.md b/roles/docker_spin_up/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/docker_spin_up/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/docker_spin_up/defaults/main.yml b/roles/docker_spin_up/defaults/main.yml new file mode 100644 index 0000000..1935337 --- /dev/null +++ b/roles/docker_spin_up/defaults/main.yml @@ -0,0 +1,3 @@ +--- +# defaults file for docker_spin_up +docker_homepath: "/{{ zfs_pool_name }}/{{ docker_name }}" diff --git a/roles/docker_spin_up/files/mailserver.env b/roles/docker_spin_up/files/mailserver.env new file mode 100644 index 0000000..4388256 --- /dev/null +++ b/roles/docker_spin_up/files/mailserver.env @@ -0,0 +1,661 @@ +# ----------------------------------------------- +# --- Mailserver Environment Variables ---------- +# ----------------------------------------------- + +# DOCUMENTATION FOR THESE VARIABLES IS FOUND UNDER +# https://docker-mailserver.github.io/docker-mailserver/latest/config/environment/ + +# ----------------------------------------------- +# --- General Section --------------------------- +# ----------------------------------------------- + +# empty => uses the `hostname` command to get the mail server's canonical hostname +# => Specify a fully-qualified domainname to serve mail for. This is used for many of the config features so if you can't set your hostname (e.g. you're in a container platform that doesn't let you) specify it in this environment variable. +OVERRIDE_HOSTNAME= + +# REMOVED in version v11.0.0! Use LOG_LEVEL instead. +DMS_DEBUG=0 + +# Set the log level for DMS. +# This is mostly relevant for container startup scripts and change detection event feedback. +# +# Valid values (in order of increasing verbosity) are: `error`, `warn`, `info`, `debug` and `trace`. +# The default log level is `info`. +LOG_LEVEL=info + +# critical => Only show critical messages +# error => Only show erroneous output +# **warn** => Show warnings +# info => Normal informational output +# debug => Also show debug messages +SUPERVISOR_LOGLEVEL= + +# Support for deployment where these defaults are not compatible (eg: some NAS appliances): +# /var/mail vmail User ID (default: 5000) +DMS_VMAIL_UID= +# /var/mail vmail Group ID (default: 5000) +DMS_VMAIL_GID= + +# **empty** => use FILE +# LDAP => use LDAP authentication +# OIDC => use OIDC authentication (not yet implemented) +# FILE => use local files (this is used as the default) +ACCOUNT_PROVISIONER= + +# empty => postmaster@domain.com +# => Specify the postmaster address +POSTMASTER_ADDRESS= + +# Check for updates on container start and then once a day +# If an update is available, a mail is sent to POSTMASTER_ADDRESS +# 0 => Update check disabled +# 1 => Update check enabled +ENABLE_UPDATE_CHECK=1 + +# Customize the update check interval. +# Number + Suffix. Suffix must be 's' for seconds, 'm' for minutes, 'h' for hours or 'd' for days. +UPDATE_CHECK_INTERVAL=1d + +# Set different options for mynetworks option (can be overwrite in postfix-main.cf) +# **WARNING**: Adding the docker network's gateway to the list of trusted hosts, e.g. using the `network` or +# `connected-networks` option, can create an open relay +# https://github.com/docker-mailserver/docker-mailserver/issues/1405#issuecomment-590106498 +# The same can happen for rootless podman. To prevent this, set the value to "none" or configure slirp4netns +# https://github.com/docker-mailserver/docker-mailserver/issues/2377 +# +# none => Explicitly force authentication +# container => Container IP address only +# host => Add docker container network (ipv4 only) +# network => Add all docker container networks (ipv4 only) +# connected-networks => Add all connected docker networks (ipv4 only) +PERMIT_DOCKER=none + +# Set the timezone. If this variable is unset, the container runtime will try to detect the time using +# `/etc/localtime`, which you can alternatively mount into the container. The value of this variable +# must follow the pattern `AREA/ZONE`, i.e. of you want to use Germany's time zone, use `Europe/Berlin`. +# You can lookup all available timezones here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List +TZ= + +# In case you network interface differs from 'eth0', e.g. when you are using HostNetworking in Kubernetes, +# you can set NETWORK_INTERFACE to whatever interface you want. This interface will then be used. +# - **empty** => eth0 +NETWORK_INTERFACE= + +# empty => modern +# modern => Enables TLSv1.2 and modern ciphers only. (default) +# intermediate => Enables TLSv1, TLSv1.1 and TLSv1.2 and broad compatibility ciphers. +TLS_LEVEL= + +# Configures the handling of creating mails with forged sender addresses. +# +# **0** => (not recommended) Mail address spoofing allowed. Any logged in user may create email messages with a forged sender address (see also https://en.wikipedia.org/wiki/Email_spoofing). +# 1 => Mail spoofing denied. Each user may only send with his own or his alias addresses. Addresses with extension delimiters(http://www.postfix.org/postconf.5.html#recipient_delimiter) are not able to send messages. +SPOOF_PROTECTION= + +# Enables the Sender Rewriting Scheme. SRS is needed if your mail server acts as forwarder. See [postsrsd](https://github.com/roehling/postsrsd/blob/master/README.md#sender-rewriting-scheme-crash-course) for further explanation. +# - **0** => Disabled +# - 1 => Enabled +ENABLE_SRS=0 + +# Enables the OpenDKIM service. +# **1** => Enabled +# 0 => Disabled +ENABLE_OPENDKIM=1 + +# Enables the OpenDMARC service. +# **1** => Enabled +# 0 => Disabled +ENABLE_OPENDMARC=1 + + +# Enabled `policyd-spf` in Postfix's configuration. You will likely want to set this +# to `0` in case you're using Rspamd (`ENABLE_RSPAMD=1`). +# +# - 0 => Disabled +# - **1** => Enabled +ENABLE_POLICYD_SPF=1 + +# Enables POP3 service +# - **0** => Disabled +# - 1 => Enabled +ENABLE_POP3= + +# Enables IMAP service +# - 0 => Disabled +# - **1** => Enabled +ENABLE_IMAP=1 + +# Enables ClamAV, and anti-virus scanner. +# 1 => Enabled +# **0** => Disabled +ENABLE_CLAMAV=0 + +# Add the value of this ENV as a prefix to the mail subject when spam is detected. +# NOTE: This subject prefix may be redundant (by default spam is delivered to a junk folder). +# It provides value when your junk mail is stored alongside legitimate mail instead of a separate location (like with `SPAMASSASSIN_SPAM_TO_INBOX=1` or `MOVE_SPAM_TO_JUNK=0` or a POP3 only setup, without IMAP). +# NOTE: When not using Docker Compose, other CRI may not support quote-wrapping the value here to preserve any trailing white-space. +SPAM_SUBJECT= + +# Enables Rspamd +# **0** => Disabled +# 1 => Enabled +ENABLE_RSPAMD=0 + +# When `ENABLE_RSPAMD=1`, an internal Redis instance is enabled implicitly. +# This setting provides an opt-out to allow using an external instance instead. +# 0 => Disabled +# 1 => Enabled +ENABLE_RSPAMD_REDIS= + +# When enabled, +# +# 1. the "[autolearning][rspamd-autolearn]" feature is turned on; +# 2. the Bayes classifier will be trained when moving mails from or to the Junk folder (with the help of Sieve scripts). +# +# **0** => disabled +# 1 => enabled +RSPAMD_LEARN=0 + +# This settings controls whether checks should be performed on emails coming +# from authenticated users (i.e. most likely outgoing emails). The default value +# is `0` in order to align better with SpamAssassin. We recommend reading +# through https://rspamd.com/doc/tutorials/scanning_outbound.html though to +# decide for yourself whether you need and want this feature. +# +# Note that DKIM signing of e-mails will still happen. +RSPAMD_CHECK_AUTHENTICATED=0 + +# Controls whether the Rspamd Greylisting module is enabled. +# This module can further assist in avoiding spam emails by greylisting +# e-mails with a certain spam score. +# +# **0** => disabled +# 1 => enabled +RSPAMD_GREYLISTING=0 + +# Can be used to enable or disable the Hfilter group module. +# +# - 0 => Disabled +# - **1** => Enabled +RSPAMD_HFILTER=1 + +# Can be used to control the score when the HFILTER_HOSTNAME_UNKNOWN symbol applies. A higher score is more punishing. Setting it to 15 is equivalent to rejecting the email when the check fails. +# +# Default: 6 +RSPAMD_HFILTER_HOSTNAME_UNKNOWN_SCORE=6 + +# Can be used to enable or disable the (still experimental) neural module. +# +# - **0** => Disabled +# - 1 => Enabled +RSPAMD_NEURAL=0 + +# Amavis content filter (used for ClamAV & SpamAssassin) +# 0 => Disabled +# 1 => Enabled +ENABLE_AMAVIS=1 + +# -1/-2/-3 => Only show errors +# **0** => Show warnings +# 1/2 => Show default informational output +# 3/4/5 => log debug information (very verbose) +AMAVIS_LOGLEVEL=0 + +# This enables DNS block lists in Postscreen. +# Note: Emails will be rejected, if they don't pass the block list checks! +# **0** => DNS block lists are disabled +# 1 => DNS block lists are enabled +ENABLE_DNSBL=0 + +# If you enable Fail2Ban, don't forget to add the following lines to your `compose.yaml`: +# cap_add: +# - NET_ADMIN +# Otherwise, `nftables` won't be able to ban IPs. +ENABLE_FAIL2BAN=0 + +# Fail2Ban blocktype +# drop => drop packet (send NO reply) +# reject => reject packet (send ICMP unreachable) +FAIL2BAN_BLOCKTYPE=drop + +# 1 => Enables Managesieve on port 4190 +# empty => disables Managesieve +ENABLE_MANAGESIEVE= + +# **enforce** => Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects. +# drop => Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects. +# ignore => Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail. +POSTSCREEN_ACTION=enforce + +# empty => all daemons start +# 1 => only launch postfix smtp +SMTP_ONLY= + +# Please read [the SSL page in the documentation](https://docker-mailserver.github.io/docker-mailserver/latest/config/security/ssl) for more information. +# +# empty => SSL disabled +# letsencrypt => Enables Let's Encrypt certificates +# custom => Enables custom certificates +# manual => Let's you manually specify locations of your SSL certificates for non-standard cases +# self-signed => Enables self-signed certificates +SSL_TYPE= + +# These are only supported with `SSL_TYPE=manual`. +# Provide the path to your cert and key files that you've mounted access to within the container. +SSL_CERT_PATH= +SSL_KEY_PATH= +# Optional: A 2nd certificate can be supported as fallback (dual cert support), eg ECDSA with an RSA fallback. +# Useful for additional compatibility with older MTA and MUA (eg pre-2015). +SSL_ALT_CERT_PATH= +SSL_ALT_KEY_PATH= + +# Set how many days a virusmail will stay on the server before being deleted +# empty => 7 days +VIRUSMAILS_DELETE_DELAY= + +# Configure Postfix `virtual_transport` to deliver mail to a different LMTP client (default is a dovecot socket). +# Provide any valid URI. Examples: +# +# empty => `lmtp:unix:/var/run/dovecot/lmtp` (default, configured in Postfix main.cf) +# `lmtp:unix:private/dovecot-lmtp` (use socket) +# `lmtps:inet::` (secure lmtp with starttls) +# `lmtp::2003` (use kopano as mailstore) +POSTFIX_DAGENT= + +# Set the mailbox size limit for all users. If set to zero, the size will be unlimited (default). Size is in bytes. +# +# empty => 0 +POSTFIX_MAILBOX_SIZE_LIMIT= + +# See https://docker-mailserver.github.io/docker-mailserver/edge/config/user-management/accounts/#notes +# 0 => Dovecot quota is disabled +# 1 => Dovecot quota is enabled +ENABLE_QUOTAS=1 + +# Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!). Size is in bytes. +# +# empty => 10240000 (~10 MB) +POSTFIX_MESSAGE_SIZE_LIMIT= + +# Mails larger than this limit won't be scanned. +# ClamAV must be enabled (ENABLE_CLAMAV=1) for this. +# +# empty => 25M (25 MB) +CLAMAV_MESSAGE_SIZE_LIMIT= + +# Enables regular pflogsumm mail reports. +# This is a new option. The old REPORT options are still supported for backwards compatibility. If this is not set and reports are enabled with the old options, logrotate will be used. +# +# not set => No report +# daily_cron => Daily report for the previous day +# logrotate => Full report based on the mail log when it is rotated +PFLOGSUMM_TRIGGER= + +# Recipient address for pflogsumm reports. +# +# not set => Use REPORT_RECIPIENT or POSTMASTER_ADDRESS +# => Specify the recipient address(es) +PFLOGSUMM_RECIPIENT= + +# Sender address (`FROM`) for pflogsumm reports if pflogsumm reports are enabled. +# +# not set => Use REPORT_SENDER +# => Specify the sender address +PFLOGSUMM_SENDER= + +# Interval for logwatch report. +# +# none => No report is generated +# daily => Send a daily report +# weekly => Send a report every week +LOGWATCH_INTERVAL= + +# Recipient address for logwatch reports if they are enabled. +# +# not set => Use REPORT_RECIPIENT or POSTMASTER_ADDRESS +# => Specify the recipient address(es) +LOGWATCH_RECIPIENT= + +# Sender address (`FROM`) for logwatch reports if logwatch reports are enabled. +# +# not set => Use REPORT_SENDER +# => Specify the sender address +LOGWATCH_SENDER= + +# Defines who receives reports if they are enabled. +# **empty** => ${POSTMASTER_ADDRESS} +# => Specify the recipient address +REPORT_RECIPIENT= + +# Defines who sends reports if they are enabled. +# **empty** => mailserver-report@${DOMAINNAME} +# => Specify the sender address +REPORT_SENDER= + +# Changes the interval in which log files are rotated +# **weekly** => Rotate log files weekly +# daily => Rotate log files daily +# monthly => Rotate log files monthly +# +# Note: This Variable actually controls logrotate inside the container +# and rotates the log files depending on this setting. The main log output is +# still available in its entirety via `docker logs mail` (Or your +# respective container name). If you want to control logrotation for +# the Docker-generated logfile see: +# https://docs.docker.com/config/containers/logging/configure/ +# +# Note: This variable can also determine the interval for Postfix's log summary reports, see [`PFLOGSUMM_TRIGGER`](#pflogsumm_trigger). +LOGROTATE_INTERVAL=weekly + +# Defines how many log files are kept by logrorate +LOGROTATE_COUNT=4 + + +# If enabled, employs `reject_unknown_client_hostname` to sender restrictions in Postfix's configuration. +# +# - **0** => Disabled +# - 1 => Enabled +POSTFIX_REJECT_UNKNOWN_CLIENT_HOSTNAME=0 + +# Choose TCP/IP protocols for postfix to use +# **all** => All possible protocols. +# ipv4 => Use only IPv4 traffic. Most likely you want this behind Docker. +# ipv6 => Use only IPv6 traffic. +# +# Note: More details at http://www.postfix.org/postconf.5.html#inet_protocols +POSTFIX_INET_PROTOCOLS=all + +# Enables MTA-STS support for outbound mail. +# More details: https://docker-mailserver.github.io/docker-mailserver/v13.3/config/best-practices/mta-sts/ +# - **0** ==> MTA-STS disabled +# - 1 => MTA-STS enabled +ENABLE_MTA_STS=0 + +# Choose TCP/IP protocols for dovecot to use +# **all** => Listen on all interfaces +# ipv4 => Listen only on IPv4 interfaces. Most likely you want this behind Docker. +# ipv6 => Listen only on IPv6 interfaces. +# +# Note: More information at https://dovecot.org/doc/dovecot-example.conf +DOVECOT_INET_PROTOCOLS=all + +# ----------------------------------------------- +# --- SpamAssassin Section ---------------------- +# ----------------------------------------------- + +ENABLE_SPAMASSASSIN=0 + +# KAM is a 3rd party SpamAssassin ruleset, provided by the McGrail Foundation. +# If SpamAssassin is enabled, KAM can be used in addition to the default ruleset. +# - **0** => KAM disabled +# - 1 => KAM enabled +# +# Note: only has an effect if `ENABLE_SPAMASSASSIN=1` +ENABLE_SPAMASSASSIN_KAM=0 + +# deliver spam messages to the inbox (tagged using SPAM_SUBJECT) +SPAMASSASSIN_SPAM_TO_INBOX=1 + +# spam messages will be moved in the Junk folder (SPAMASSASSIN_SPAM_TO_INBOX=1 required) +MOVE_SPAM_TO_JUNK=1 + +# spam messages will be marked as read +MARK_SPAM_AS_READ=0 + +# add 'spam info' headers at, or above this level +SA_TAG=2.0 + +# add 'spam detected' headers at, or above this level +SA_TAG2=6.31 + +# triggers spam evasive actions +SA_KILL=10.0 + +# ----------------------------------------------- +# --- Fetchmail Section ------------------------- +# ----------------------------------------------- + +ENABLE_FETCHMAIL=0 + +# The interval to fetch mail in seconds +FETCHMAIL_POLL=300 +# Use multiple fetchmail instances (1 per poll entry in fetchmail.cf) +# Supports multiple IMAP IDLE connections when a server is used across multiple poll entries +# https://otremba.net/wiki/Fetchmail_(Debian)#Immediate_Download_via_IMAP_IDLE +FETCHMAIL_PARALLEL=0 + +# Enable or disable `getmail`. +# +# - **0** => Disabled +# - 1 => Enabled +ENABLE_GETMAIL=0 + +# The number of minutes for the interval. Min: 1; Max: 30. +GETMAIL_POLL=5 + +# ----------------------------------------------- +# --- OAUTH2 Section ---------------------------- +# ----------------------------------------------- + +# empty => OAUTH2 authentication is disabled +# 1 => OAUTH2 authentication is enabled +ENABLE_OAUTH2= + +# Specify the user info endpoint URL of the oauth2 provider +# Example: https://oauth2.example.com/userinfo/ +OAUTH2_INTROSPECTION_URL= + +# ----------------------------------------------- +# --- LDAP Section ------------------------------ +# ----------------------------------------------- + +# A second container for the ldap service is necessary (i.e. https://hub.docker.com/r/bitnami/openldap/) + +# empty => no +# yes => LDAP over TLS enabled for Postfix +LDAP_START_TLS= + +# empty => mail.example.com +# Specify the `` / `` where the LDAP server is reachable via a URI like: `ldaps://mail.example.com`. +# Note: You must include the desired URI scheme (`ldap://`, `ldaps://`, `ldapi://`). +LDAP_SERVER_HOST= + +# empty => ou=people,dc=domain,dc=com +# => e.g. LDAP_SEARCH_BASE=dc=mydomain,dc=local +LDAP_SEARCH_BASE= + +# empty => cn=admin,dc=domain,dc=com +# => take a look at examples of SASL_LDAP_BIND_DN +LDAP_BIND_DN= + +# empty** => admin +# => Specify the password to bind against ldap +LDAP_BIND_PW= + +# e.g. `"(&(mail=%s)(mailEnabled=TRUE))"` +# => Specify how ldap should be asked for users +LDAP_QUERY_FILTER_USER= + +# e.g. `"(&(mailGroupMember=%s)(mailEnabled=TRUE))"` +# => Specify how ldap should be asked for groups +LDAP_QUERY_FILTER_GROUP= + +# e.g. `"(&(mailAlias=%s)(mailEnabled=TRUE))"` +# => Specify how ldap should be asked for aliases +LDAP_QUERY_FILTER_ALIAS= + +# e.g. `"(&(|(mail=*@%s)(mailalias=*@%s)(mailGroupMember=*@%s))(mailEnabled=TRUE))"` +# => Specify how ldap should be asked for domains +LDAP_QUERY_FILTER_DOMAIN= + +# ----------------------------------------------- +# --- Dovecot Section --------------------------- +# ----------------------------------------------- + +# empty => no +# yes => LDAP over TLS enabled for Dovecot +DOVECOT_TLS= + +# e.g. `"(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))"` +DOVECOT_USER_FILTER= + +# e.g. `"(&(objectClass=PostfixBookMailAccount)(uniqueIdentifier=%n))"` +DOVECOT_PASS_FILTER= + +# Define the mailbox format to be used +# default is maildir, supported values are: sdbox, mdbox, maildir +DOVECOT_MAILBOX_FORMAT=maildir + +# empty => no +# yes => Allow bind authentication for LDAP +# https://wiki.dovecot.org/AuthDatabase/LDAP/AuthBinds +DOVECOT_AUTH_BIND= + +# ----------------------------------------------- +# --- Postgrey Section -------------------------- +# ----------------------------------------------- + +ENABLE_POSTGREY=0 +# greylist for N seconds +POSTGREY_DELAY=300 +# delete entries older than N days since the last time that they have been seen +POSTGREY_MAX_AGE=35 +# response when a mail is greylisted +POSTGREY_TEXT="Delayed by Postgrey" +# whitelist host after N successful deliveries (N=0 to disable whitelisting) +POSTGREY_AUTO_WHITELIST_CLIENTS=5 + +# ----------------------------------------------- +# --- SASL Section ------------------------------ +# ----------------------------------------------- + +ENABLE_SASLAUTHD=0 + +# empty => pam +# `ldap` => authenticate against ldap server +# `shadow` => authenticate against local user db +# `mysql` => authenticate against mysql db +# `rimap` => authenticate against imap server +# Note: can be a list of mechanisms like pam ldap shadow +SASLAUTHD_MECHANISMS= + +# empty => None +# e.g. with SASLAUTHD_MECHANISMS rimap you need to specify the ip-address/servername of the imap server ==> xxx.xxx.xxx.xxx +SASLAUTHD_MECH_OPTIONS= + +# empty => Use value of LDAP_SERVER_HOST +# Note: You must include the desired URI scheme (`ldap://`, `ldaps://`, `ldapi://`). +SASLAUTHD_LDAP_SERVER= + +# empty => Use value of LDAP_BIND_DN +# specify an object with privileges to search the directory tree +# e.g. active directory: SASLAUTHD_LDAP_BIND_DN=cn=Administrator,cn=Users,dc=mydomain,dc=net +# e.g. openldap: SASLAUTHD_LDAP_BIND_DN=cn=admin,dc=mydomain,dc=net +SASLAUTHD_LDAP_BIND_DN= + +# empty => Use value of LDAP_BIND_PW +SASLAUTHD_LDAP_PASSWORD= + +# empty => Use value of LDAP_SEARCH_BASE +# specify the search base +SASLAUTHD_LDAP_SEARCH_BASE= + +# empty => default filter `(&(uniqueIdentifier=%u)(mailEnabled=TRUE))` +# e.g. for active directory: `(&(sAMAccountName=%U)(objectClass=person))` +# e.g. for openldap: `(&(uid=%U)(objectClass=person))` +SASLAUTHD_LDAP_FILTER= + +# empty => no +# yes => LDAP over TLS enabled for SASL +# If set to yes, the protocol in SASLAUTHD_LDAP_SERVER must be ldap:// or missing. +SASLAUTHD_LDAP_START_TLS= + +# empty => no +# yes => Require and verify server certificate +# If yes you must/could specify SASLAUTHD_LDAP_TLS_CACERT_FILE or SASLAUTHD_LDAP_TLS_CACERT_DIR. +SASLAUTHD_LDAP_TLS_CHECK_PEER= + +# File containing CA (Certificate Authority) certificate(s). +# empty => Nothing is added to the configuration +# Any value => Fills the `ldap_tls_cacert_file` option +SASLAUTHD_LDAP_TLS_CACERT_FILE= + +# Path to directory with CA (Certificate Authority) certificates. +# empty => Nothing is added to the configuration +# Any value => Fills the `ldap_tls_cacert_dir` option +SASLAUTHD_LDAP_TLS_CACERT_DIR= + +# Specify what password attribute to use for password verification. +# empty => Nothing is added to the configuration but the documentation says it is `userPassword` by default. +# Any value => Fills the `ldap_password_attr` option +SASLAUTHD_LDAP_PASSWORD_ATTR= + +# empty => `bind` will be used as a default value +# `fastbind` => The fastbind method is used +# `custom` => The custom method uses userPassword attribute to verify the password +SASLAUTHD_LDAP_AUTH_METHOD= + +# Specify the authentication mechanism for SASL bind +# empty => Nothing is added to the configuration +# Any value => Fills the `ldap_mech` option +SASLAUTHD_LDAP_MECH= + +# ----------------------------------------------- +# --- SRS Section ------------------------------- +# ----------------------------------------------- + +# envelope_sender => Rewrite only envelope sender address (default) +# header_sender => Rewrite only header sender (not recommended) +# envelope_sender,header_sender => Rewrite both senders +# An email has an "envelope" sender (indicating the sending server) and a +# "header" sender (indicating who sent it). More strict SPF policies may require +# you to replace both instead of just the envelope sender. +SRS_SENDER_CLASSES=envelope_sender + +# empty => Envelope sender will be rewritten for all domains +# provide comma separated list of domains to exclude from rewriting +SRS_EXCLUDE_DOMAINS= + +# empty => generated when the image is built +# provide a secret to use in base64 +# you may specify multiple keys, comma separated. the first one is used for +# signing and the remaining will be used for verification. this is how you +# rotate and expire keys +SRS_SECRET= + +# ----------------------------------------------- +# --- Default Relay Host Section ---------------- +# ----------------------------------------------- + +# Setup relaying all mail through a default relay host +# +# Set a default host to relay all mail through (optionally include a port) +# Example: [mail.example.com]:587 +DEFAULT_RELAY_HOST= + +# ----------------------------------------------- +# --- Multi-Domain Relay Section ---------------- +# ----------------------------------------------- + +# Setup relaying for multiple domains based on the domain name of the sender +# optionally uses usernames and passwords in postfix-sasl-password.cf and relay host mappings in postfix-relaymap.cf +# +# Set a default host to relay mail through +# Example: mail.example.com +RELAY_HOST= + +# empty => 25 +# default port to relay mail +RELAY_PORT=25 + +# ----------------------------------------------- +# --- Relay Host Credentials Section ------------ +# ----------------------------------------------- + +# Configure a relay user and password to use with RELAY_HOST / DEFAULT_RELAY_HOST + +# empty => no default +RELAY_USER= + +# empty => no default +RELAY_PASSWORD= diff --git a/roles/docker_spin_up/handlers/main.yml b/roles/docker_spin_up/handlers/main.yml new file mode 100644 index 0000000..6ffc348 --- /dev/null +++ b/roles/docker_spin_up/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for docker_spin_up diff --git a/roles/docker_spin_up/meta/main.yml b/roles/docker_spin_up/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/docker_spin_up/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/docker_spin_up/tasks/dashboard_my_public.yml b/roles/docker_spin_up/tasks/dashboard_my_public.yml new file mode 100644 index 0000000..a360631 --- /dev/null +++ b/roles/docker_spin_up/tasks/dashboard_my_public.yml @@ -0,0 +1,9 @@ +--- +- name: "{{ docker_name }}" + community.docker.docker_container: + name: "{{ docker_name }}" + image: ghcr.io/gethomepage/homepage:latest + ports: + - 3000:3000 + volumes: + - "{{ docker_homepath }}/config:/app/config" # Make sure your local config directory exists \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/email.yml b/roles/docker_spin_up/tasks/email.yml new file mode 100644 index 0000000..434fbd3 --- /dev/null +++ b/roles/docker_spin_up/tasks/email.yml @@ -0,0 +1,34 @@ +--- +- name: email + community.docker.docker_container: + image: docker.io/mailserver/docker-mailserver:latest + name: email + #container_name: mailserver + # If the FQDN for your mail-server is only two labels (eg: example.com), + # you can assign this entirely to `hostname` and remove `domainname`. + hostname: mail + domainname: katebartova.cz + env: + SSL_TYPE: letsencrypt + env_file: "{{ docker_homepath }}/mailserver.env" + # More information about the mail-server ports: + # https://docker-mailserver.github.io/docker-mailserver/edge/config/security/understanding-the-ports/ + # To avoid conflicts with yaml base-60 float, DO NOT remove the quotation marks. + ports: + - "25:25" # SMTP (explicit TLS => STARTTLS) + - "143:143" # IMAP4 (explicit TLS => STARTTLS) + - "465:465" # ESMTP (implicit TLS) + - "587:587" # ESMTP (explicit TLS => STARTTLS) + - "993:993" # IMAP4 (implicit TLS) + volumes: + - "{{ docker_homepath }}/docker-data/dms/mail-data/:/var/mail/" + - "{{ docker_homepath }}/docker-data/dms/mail-state/:/var/mail-state/" + - "{{ docker_homepath }}/docker-data/dms/mail-logs/:/var/log/mail/" + - "{{ docker_homepath }}/docker-data/dms/config/:/tmp/docker-mailserver/" + - "/bigpool/nginx/letsencrypt/:/etc/letsencrypt/:ro" + - /etc/localtime:/etc/localtime:ro + restart_policy: always + #stop_grace_period: 1m + capabilities: + - NET_ADMIN + - SYS_PTRACE \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/gitea.yml b/roles/docker_spin_up/tasks/gitea.yml new file mode 100644 index 0000000..50c930c --- /dev/null +++ b/roles/docker_spin_up/tasks/gitea.yml @@ -0,0 +1,24 @@ +--- +- name: gitea + community.docker.docker_container: + image: gitea/gitea:1.19.3 + name: gitea + env: + USER_UID: "1000" + USER_GID: "1000" + GITEA__database__DB_TYPE: "mysql" + GITEA__database__HOST: "{{ mysql_host}}:3306" + GITEA__database__NAME: "{{ GITEA__database__NAME }}" + GITEA__database__USER: "{{ GITEA__database__USER }}" + GITEA__database__PASSWD: "{{ GITEA__database__PASSWD }}" + ROOT_URL: "http://pi-vpn:8082/" + restart_policy: always + networks: + - name: http + volumes: + - "{{ docker_homepath }}/gitea:/data" + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + # - "8082:3000" + - "222:22" \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/jellyfin.yml b/roles/docker_spin_up/tasks/jellyfin.yml new file mode 100644 index 0000000..a1bcdb8 --- /dev/null +++ b/roles/docker_spin_up/tasks/jellyfin.yml @@ -0,0 +1,34 @@ +- name: Dir-jellyfin-config + ansible.builtin.file: + path: "{{ docker_homepath }}/config" + owner: "{{ user }}" + group: "{{ primary_group }}" + state: directory + mode: '0711' + +- name: Dir-jellyfin-cache + ansible.builtin.file: + path: "{{ docker_homepath }}/cache" + owner: "{{ user }}" + group: "{{ primary_group }}" + state: directory + mode: '0711' + + +- name: jellyfin + community.docker.docker_container: + name: jellyfin + image: jellyfin/jellyfin:2024042215 + user: "{{ uid }}:{{ gid }}" + env: + PUID: "1000" + PGID: "1000" + TZ: "Etc/UTC" + JELLYFIN_PublishedServerUrl: "jellyfin.lan" #optional + volumes: + - "/bigpool/tata/Music:/Music:ro" + - "{{ docker_homepath }}/config:/config" + - "{{ docker_homepath }}/cache:/cache" + restart_policy: unless-stopped + networks: + - name: http \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/main.yml b/roles/docker_spin_up/tasks/main.yml new file mode 100644 index 0000000..0c16ea8 --- /dev/null +++ b/roles/docker_spin_up/tasks/main.yml @@ -0,0 +1,17 @@ +--- +# tasks file for docker_spin_up +#- name: Copy composer +# template: +# src: "../templates/{{ docker_compose_file }}" +# dest: "/{{ docker_homepath }}/docker-compose.yml" +# owner: root +# group: root +# mode: '0644' + +- name: Create a network + community.docker.docker_network: + name: http + +- name: Spin up {{ docker_compose_file }} + ansible.builtin.include_tasks: + "{{ docker_compose_file }}" \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/monitoring.yml b/roles/docker_spin_up/tasks/monitoring.yml new file mode 100644 index 0000000..cb8bea6 --- /dev/null +++ b/roles/docker_spin_up/tasks/monitoring.yml @@ -0,0 +1,82 @@ +--- +- name: Dir-loki + ansible.builtin.file: + path: "{{ docker_homepath }}/loki-data" + owner: "{{ user }}" + group: "{{ primary_group }}" + state: directory + mode: '0711' + +- name: Dir-grafana + ansible.builtin.file: + path: "{{ docker_homepath }}/grafana-data" + owner: "{{ user }}" + group: "{{ primary_group }}" + state: directory + mode: '0711' + +- name: Dir-promtail + ansible.builtin.file: + path: "{{ docker_homepath }}/promtail-data" + owner: "{{ user }}" + group: "{{ primary_group }}" + state: directory + mode: '0711' + +- name: promtail config copy + template: + src: ../templates/promtail-config.yml + dest: "{{ docker_homepath }}/promtail-data/promtail-config.yml" + owner: "{{ user}}" + group: "{{ primary_group }}" + mode: '0644' + +- name: loki + community.docker.docker_container: + name: loki + user: "{{ uid }}:{{ gid }}" + image: 'grafana/loki:main-2c878c8' + restart_policy: unless-stopped + #ports: + # - '3100:3100' + volumes: + - "{{ docker_homepath }}/loki-data:/loki" + - "/etc/resolv.conf:/etc/resolv.conf:ro" + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" + networks: + - name: http + +- name: grafana + community.docker.docker_container: + name: grafana + image: 'grafana/grafana:10.2.6' + user: "{{ uid }}:{{ gid }}" + restart_policy: unless-stopped + #ports: + # - '3000:3000' + volumes: + - "{{ docker_homepath }}/grafana-data:/var/lib/grafana" + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" + networks: + - name: http + +- name: promtail + community.docker.docker_container: + name: promtail + image: 'grafana/promtail:main-e2952b9' + user: "0:0" + restart_policy: unless-stopped + command: -config.file=/etc/promtail/promtail-config.yml -config.expand-env=true + #ports: + # - '3000:3000' + volumes: + - "{{ docker_homepath }}/promtail-data:/etc/promtail" + - "/var/log:/var/log:ro" + - "/run/log/journal/:/run/log/journal/:ro" + - "/etc/machine-id:/etc/machine-id:ro" + - "/etc/timezone:/etc/timezone:ro" + - "/etc/localtime:/etc/localtime:ro" + networks: + - name: http \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/nextcloud.yml b/roles/docker_spin_up/tasks/nextcloud.yml new file mode 100644 index 0000000..6763b4a --- /dev/null +++ b/roles/docker_spin_up/tasks/nextcloud.yml @@ -0,0 +1,19 @@ +--- +- name: nextcloud + community.docker.docker_container: + name: nextcloud + image: nextcloud:26.0-fpm + restart_policy: always +# ports: +# - 8080:80 + volumes: + - "{{ docker_homepath }}/nextcloud_nextcloud_1/_data:/var/www/html" + env: + MYSQL_PASSWORD: "{{ NEXTCLOUD_MYSQL_PASSWORD }}" + MYSQL_DATABASE: "{{ NEXTCLOUD_MYSQL_DATABASE }}" + MYSQL_USER: "{{ NEXTCLOUD_MYSQL_USER }}" + MYSQL_HOST: "{{ mysql_host }}" + PHP_MEMORY_LIMIT: 2G + PHP_UPLOAD_LIMIT: 10G + networks: + - name: http \ No newline at end of file diff --git a/roles/docker_spin_up/tasks/nginx.yml b/roles/docker_spin_up/tasks/nginx.yml new file mode 100644 index 0000000..da15db7 --- /dev/null +++ b/roles/docker_spin_up/tasks/nginx.yml @@ -0,0 +1,16 @@ +--- +- name: nginx + community.docker.docker_container: + name: nginx + image: 'jc21/nginx-proxy-manager:latest' + restart_policy: unless-stopped + ports: + - '80:80' + #- "{{ ip_admin }}:81:81" + - '443:443' + volumes: + - "{{ docker_homepath }}/data:/data" + - "{{ docker_homepath }}/letsencrypt:/etc/letsencrypt" + - "/bigpool/nextcloud/nextcloud_nextcloud_1/_data/:/var/www/html:ro" + networks: + - name: http diff --git a/roles/docker_spin_up/tasks/pi-hole.yml b/roles/docker_spin_up/tasks/pi-hole.yml new file mode 100644 index 0000000..be5b31f --- /dev/null +++ b/roles/docker_spin_up/tasks/pi-hole.yml @@ -0,0 +1,20 @@ +- name: pi-hole + community.docker.docker_container: + name: pi-hole + image: pihole/pihole:2024.03.2 + # For DHCP it is recommended to remove these ports and instead add: network_mode: "host" + ports: + - "53:53/tcp" + - "53:53/udp" + # - "8092:80/tcp" + env: + TZ: 'Europe/Prague' + WEBPASSWORD: "{{ password }}" + # Volumes store your data between container upgrades + volumes: + - "{{ docker_homepath }}/etc-pihole:/etc/pihole" + - "{{ docker_homepath }}/etc-dnsmasq.d:/etc/dnsmasq.d" + # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities + restart_policy: unless-stopped + networks: + - name: http diff --git a/roles/docker_spin_up/tasks/transmission.yaml b/roles/docker_spin_up/tasks/transmission.yaml new file mode 100644 index 0000000..6ca1487 --- /dev/null +++ b/roles/docker_spin_up/tasks/transmission.yaml @@ -0,0 +1,24 @@ +--- +- name: transmission + community.docker.docker_container: + name: transmission + image: lscr.io/linuxserver/transmission:latest + #container_name: transmission + env: + PUID: "{{ uid }}" + PGID: "{{ uid }}" + TZ: Europe/Berlin + #TRANSMISSION_WEB_HOME=/combustion-release/ #optional + USER: "{{ user }}" #optional + PASS: "{{ password }}" #optional + volumes: + # - /path/to/data:/config + - "{{ docker_homepath }}/downloads:/downloads" + - "{{ docker_homepath }}/watch:/watch" + #ports: + # - 9091:9091 + # - 51413:51413 + # - 51413:51413/udp + restart_policy: unless-stopped + networks: + - name: http diff --git a/roles/docker_spin_up/templates/promtail-config.yml b/roles/docker_spin_up/templates/promtail-config.yml new file mode 100644 index 0000000..c70257c --- /dev/null +++ b/roles/docker_spin_up/templates/promtail-config.yml @@ -0,0 +1,60 @@ +server: + http_listen_port: 9080 + grpc_listen_port: 0 +positions: + filename: /tmp/positions.yaml +clients: + - url: http://loki:3100/loki/api/v1/push + #- url: https://loki.internal.matous.vondrejka.cz/loki/api/v1/push + +scrape_configs: + - job_name: journal + journal: + json: false + max_age: 12h + path: /var/log/journal + labels: + job: systemd-journal + relabel_configs: + - source_labels: ['__journal__systemd_unit'] + target_label: 'unit' + + + - job_name: docker + static_configs: + - targets: + - localhost + labels: + job: containerlogs + __path__: /var/lib/docker/containers/*/*log + + pipeline_stages: + - json: + expressions: + output: log + stream: stream + attrs: + - json: + expressions: + tag: + source: attrs + - regex: + expression: (?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])).(?P(?:[^|]*[^|])) + source: tag + - timestamp: + format: RFC3339Nano + source: time + - labels: + tag: + stream: + image_name: + container_name: + image_id: + container_id: + - output: + source: output/*-json.log + + +#scrape_configs: +#- job_name: journald +# journal: {} diff --git a/roles/docker_spin_up/tests/inventory b/roles/docker_spin_up/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/docker_spin_up/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/docker_spin_up/tests/test.yml b/roles/docker_spin_up/tests/test.yml new file mode 100644 index 0000000..6041d25 --- /dev/null +++ b/roles/docker_spin_up/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - docker_spin_up diff --git a/roles/docker_spin_up/vars/main.yml b/roles/docker_spin_up/vars/main.yml new file mode 100644 index 0000000..c225738 --- /dev/null +++ b/roles/docker_spin_up/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for docker_spin_up diff --git a/roles/linux_config_init/.travis.yml b/roles/linux_config_init/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/linux_config_init/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/linux_config_init/defaults/main.yml b/roles/linux_config_init/defaults/main.yml new file mode 100644 index 0000000..905ee61 --- /dev/null +++ b/roles/linux_config_init/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for linux_config_tinker diff --git a/roles/linux_config_init/handlers/main.yml b/roles/linux_config_init/handlers/main.yml new file mode 100644 index 0000000..bbf1c09 --- /dev/null +++ b/roles/linux_config_init/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: networking restart + service: + name: networking + state: restarted \ No newline at end of file diff --git a/roles/linux_config_init/tasks/bashrc_copy.yml b/roles/linux_config_init/tasks/bashrc_copy.yml new file mode 100644 index 0000000..85fa0af --- /dev/null +++ b/roles/linux_config_init/tasks/bashrc_copy.yml @@ -0,0 +1,17 @@ +--- +- name: Copy /root/.bashrc + template: + src: ../templates/bashrc + dest: /root/.bashrc + owner: root + group: root + mode: '0644' + + +- name: Copy /home/{{ user }}/.bashrc + template: + src: ../templates/bashrc + dest: /home/{{ user }}/.bashrc + owner: "{{ user }}" + group: "{{ user }}" + mode: '0644' \ No newline at end of file diff --git a/roles/linux_config_init/tasks/create_user.yml b/roles/linux_config_init/tasks/create_user.yml new file mode 100644 index 0000000..4682313 --- /dev/null +++ b/roles/linux_config_init/tasks/create_user.yml @@ -0,0 +1,27 @@ +--- +- name: Adding user + ansible.builtin.user: + name: "{{ user }}" + uid: "{{ uid }}" + shell: /bin/bash + groups: sudo + +- name: Setting ssh key + ansible.builtin.blockinfile: + state: present + owner: "{{ user }}" + group: "{{ user }}" + insertafter: EOF + path: /home/{{ user }}/.ssh/authorized_keys + mode: "0644" + create: true + block: | + {{ ssh_key }} + when: ssh_key is defined + +- name: Set permissions to .ssh folder + ansible.builtin.file: + path: /home/{{ user }}/.ssh + owner: "{{ user }}" + group: "{{ user }}" + mode: "0711" diff --git a/roles/linux_config_init/tasks/hostname_set.yml b/roles/linux_config_init/tasks/hostname_set.yml new file mode 100644 index 0000000..f5ebd7d --- /dev/null +++ b/roles/linux_config_init/tasks/hostname_set.yml @@ -0,0 +1,13 @@ +--- +- name: Copy /etc/hosts + template: + src: ../templates/etc_hosts + dest: /etc/hosts + owner: root + group: root + mode: '0664' + + +- name: Set a hostname + ansible.builtin.hostname: + name: "{{ host }}" \ No newline at end of file diff --git a/roles/linux_config_init/tasks/main.yml b/roles/linux_config_init/tasks/main.yml new file mode 100644 index 0000000..5914371 --- /dev/null +++ b/roles/linux_config_init/tasks/main.yml @@ -0,0 +1,18 @@ +--- +# tasks file for linux_config_init +- name: System settings + ansible.builtin.include_tasks: "{{ item }}" + loop: + - sudoer_no_passwd.yml + - create_user.yml + - bashrc_copy.yml + - timezone.yml + - resolvconf_copy.yml + +- name: Set Pernament IP + ansible.builtin.include_tasks: set_perma_ip.yml + when: set_ip + +- name: Set Hostname + ansible.builtin.include_tasks: hostname_set.yml + when: set_hostname \ No newline at end of file diff --git a/roles/linux_config_init/tasks/resolvconf_copy.yml b/roles/linux_config_init/tasks/resolvconf_copy.yml new file mode 100644 index 0000000..dd2379f --- /dev/null +++ b/roles/linux_config_init/tasks/resolvconf_copy.yml @@ -0,0 +1,8 @@ +--- +- name: Copy /templates/resolvconf + template: + src: ../templates/resolvconf + dest: /etc/resolv.conf + owner: root + group: root + mode: '0644' \ No newline at end of file diff --git a/roles/linux_config_init/tasks/set_perma_ip.yml b/roles/linux_config_init/tasks/set_perma_ip.yml new file mode 100644 index 0000000..c5ef132 --- /dev/null +++ b/roles/linux_config_init/tasks/set_perma_ip.yml @@ -0,0 +1,9 @@ +--- +- name: Copy /etc/network/interfaces + template: + src: ../templates/etc_network_interface + dest: /etc/network/interfaces + owner: root + group: root + mode: '0644' + notify: networking restart diff --git a/roles/linux_config_init/tasks/sudoer_no_passwd.yml b/roles/linux_config_init/tasks/sudoer_no_passwd.yml new file mode 100644 index 0000000..561a3b6 --- /dev/null +++ b/roles/linux_config_init/tasks/sudoer_no_passwd.yml @@ -0,0 +1,8 @@ +--- +- name: No password for sudo + become: true + community.general.sudoers: + nopassword: true + commands: ALL + user: "{{ user }}" + name: No password for sudo diff --git a/roles/linux_config_init/tasks/timezone.yml b/roles/linux_config_init/tasks/timezone.yml new file mode 100644 index 0000000..50f18c9 --- /dev/null +++ b/roles/linux_config_init/tasks/timezone.yml @@ -0,0 +1,3 @@ +- name: Set timezone to Europe/Prague + community.general.timezone: + name: Europe/Prague \ No newline at end of file diff --git a/roles/linux_config_init/templates/bashrc b/roles/linux_config_init/templates/bashrc new file mode 100644 index 0000000..708aafa --- /dev/null +++ b/roles/linux_config_init/templates/bashrc @@ -0,0 +1,113 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -lah' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi \ No newline at end of file diff --git a/roles/linux_config_init/templates/etc_hosts b/roles/linux_config_init/templates/etc_hosts new file mode 100644 index 0000000..a00a0dd --- /dev/null +++ b/roles/linux_config_init/templates/etc_hosts @@ -0,0 +1,10 @@ +127.0.0.1 localhost.localdomain localhost +{{ ip }} {{ host }} +# The following lines are desirable for IPv6 capable hosts + +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +ff02::3 ip6-allhosts \ No newline at end of file diff --git a/roles/linux_config_init/templates/etc_network_interface b/roles/linux_config_init/templates/etc_network_interface new file mode 100644 index 0000000..2c0f278 --- /dev/null +++ b/roles/linux_config_init/templates/etc_network_interface @@ -0,0 +1,16 @@ +auto lo +iface lo inet loopback + +auto {{ in_face }} +iface {{ in_face }} inet static +address {{ ip }}/24 + +{% if ip_admin is defined %} +iface {{ in_face }} inet static +address {{ ip_admin }}/24 +{% endif %} + +{% if gateway is defined %} +gateway {{ gateway }} +{% endif %} +source /etc/network/interfaces.d/* diff --git a/roles/linux_config_init/templates/resolvconf b/roles/linux_config_init/templates/resolvconf new file mode 100644 index 0000000..da9454f --- /dev/null +++ b/roles/linux_config_init/templates/resolvconf @@ -0,0 +1,2 @@ +nameserver 192.168.100.6 +nameserver 8.8.8.8 diff --git a/roles/linux_config_init/vars/main.yml b/roles/linux_config_init/vars/main.yml new file mode 100644 index 0000000..934b677 --- /dev/null +++ b/roles/linux_config_init/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for linux_config_tinker diff --git a/roles/mariadb/.travis.yml b/roles/mariadb/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/mariadb/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/mariadb/README.md b/roles/mariadb/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/mariadb/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/mariadb/defaults/main.yml b/roles/mariadb/defaults/main.yml new file mode 100644 index 0000000..d7a2158 --- /dev/null +++ b/roles/mariadb/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for mariaDB_install diff --git a/roles/mariadb/handlers/main.yml b/roles/mariadb/handlers/main.yml new file mode 100644 index 0000000..56b658a --- /dev/null +++ b/roles/mariadb/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for mariaDB_install +- name: mariadb restart + service: + name: mariadb + state: restarted \ No newline at end of file diff --git a/roles/mariadb/meta/main.yml b/roles/mariadb/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/mariadb/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml new file mode 100644 index 0000000..9d58e31 --- /dev/null +++ b/roles/mariadb/tasks/main.yml @@ -0,0 +1,31 @@ +--- +# tasks file for mariaDB_install +- name: Install + ansible.builtin.package: + name: + - mariadb-server + - mycli + state: present + +- name: Start and enabled + ansible.builtin.service: + name: mariadb + state: started + enabled: true + +- name: Gather the package facts + ansible.builtin.package_facts: + manager: auto + +- name: Check package version + ansible.builtin.debug: + msg: "{{ ansible_facts.packages['mariadb-server'][0].version[2:7] }}" + +- name: Copy config + template: + src: ../templates/50-server.cnf + dest: /etc/mysql/mariadb.conf.d/50-server.cnf + owner: root + group: root + mode: "0644" + notify: mariadb restart diff --git a/roles/mariadb/templates/50-server.cnf b/roles/mariadb/templates/50-server.cnf new file mode 100644 index 0000000..175b0f6 --- /dev/null +++ b/roles/mariadb/templates/50-server.cnf @@ -0,0 +1,118 @@ +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] + +# +# * Basic Settings +# + +user = mysql +pid-file = /run/mysqld/mysqld.pid +basedir = /usr +#datadir = /var/lib/mysql +datadir = {{ mariadb_location }} +tmpdir = /tmp +lc-messages-dir = /usr/share/mysql +lc-messages = en_US +skip-external-locking + +# Broken reverse DNS slows down connections considerably and name resolve is +# safe to skip if there are no "host by domain name" access grants +#skip-name-resolve + +# Instead of skip-networking the default is now to listen only on +# localhost which is more compatible and is not less secure. +bind-address = 0.0.0.0 + +# +# * Fine Tuning +# + +#key_buffer_size = 128M +#max_allowed_packet = 1G +#thread_stack = 192K +#thread_cache_size = 8 +# This replaces the startup script and checks MyISAM tables if needed +# the first time they are touched +#myisam_recover_options = BACKUP +#max_connections = 100 +#table_cache = 64 + +# +# * Logging and Replication +# + +# Both location gets rotated by the cronjob. +# Be aware that this log type is a performance killer. +# Recommend only changing this at runtime for short testing periods if needed! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 + +# When running under systemd, error logging goes via stdout/stderr to journald +# and when running legacy init error logging goes to syslog due to +# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf +# Enable this if you want to have error logging into a separate file +#log_error = /var/log/mysql/error.log +# Enable the slow query log to see queries with especially long duration +#slow_query_log_file = /var/log/mysql/mariadb-slow.log +#long_query_time = 10 +#log_slow_verbosity = query_plan,explain +#log-queries-not-using-indexes +#min_examined_row_limit = 1000 + +# The following can be used as easy to replay backup logs or for replication. +# note: if you are setting up a replication slave, see README.Debian about +# other settings you may need to change. +#server-id = 1 +#log_bin = /var/log/mysql/mysql-bin.log +expire_logs_days = 10 +#max_binlog_size = 100M + +# +# * SSL/TLS +# + +# For documentation, please read +# https://mariadb.com/kb/en/securing-connections-for-client-and-server/ +#ssl-ca = /etc/mysql/cacert.pem +#ssl-cert = /etc/mysql/server-cert.pem +#ssl-key = /etc/mysql/server-key.pem +#require-secure-transport = on + +# +# * Character sets +# + +# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full +# utf8 4-byte character set. See also client.cnf +character-set-server = utf8mb4 +collation-server = utf8mb4_general_ci + +# +# * InnoDB +# + +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! +# Most important is to give InnoDB 80 % of the system RAM for buffer use: +# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size +#innodb_buffer_pool_size = 8G + +# this is only for embedded server +[embedded] + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +# This group is only read by MariaDB-{{ ansible_facts.packages['mariadb-server'][0].version[2:7] }} servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-{{ ansible_facts.packages['mariadb-server'][0].version[2:7] }}] diff --git a/roles/mariadb/tests/inventory b/roles/mariadb/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/mariadb/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/mariadb/tests/test.yml b/roles/mariadb/tests/test.yml new file mode 100644 index 0000000..72545df --- /dev/null +++ b/roles/mariadb/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - mariaDB_install diff --git a/roles/mariadb/vars/main.yml b/roles/mariadb/vars/main.yml new file mode 100644 index 0000000..05cbbbc --- /dev/null +++ b/roles/mariadb/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for mariaDB_install diff --git a/roles/nfs/.travis.yml b/roles/nfs/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/nfs/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/nfs/README.md b/roles/nfs/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/nfs/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/nfs/defaults/main.yml b/roles/nfs/defaults/main.yml new file mode 100644 index 0000000..7916894 --- /dev/null +++ b/roles/nfs/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for nfs-share diff --git a/roles/nfs/handlers/main.yml b/roles/nfs/handlers/main.yml new file mode 100644 index 0000000..cc21551 --- /dev/null +++ b/roles/nfs/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for nfs-share diff --git a/roles/nfs/meta/main.yml b/roles/nfs/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/nfs/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/nfs/tasks/main.yml b/roles/nfs/tasks/main.yml new file mode 100644 index 0000000..51ba852 --- /dev/null +++ b/roles/nfs/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: Nfs install for Debian + become: true + ansible.builtin.package: + name: + - nfs-kernel-server + state: present + when: ansible_os_family == 'Debian' + +- name: Nfs install for RedHat + become: true + ansible.builtin.package: + name: + - nfs-utils + state: present + when: ansible_os_family == 'RedHat' + +- name: Start and enable nfs + ansible.builtin.service: + name: nfs-server + state: started + enabled: yes diff --git a/roles/nfs/tests/inventory b/roles/nfs/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/nfs/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/nfs/tests/test.yml b/roles/nfs/tests/test.yml new file mode 100644 index 0000000..cc646ad --- /dev/null +++ b/roles/nfs/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - nfs-share diff --git a/roles/nfs/vars/main.yml b/roles/nfs/vars/main.yml new file mode 100644 index 0000000..f5d95c7 --- /dev/null +++ b/roles/nfs/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for nfs-share diff --git a/roles/prometheus_node_exporter/handlers/main.yml b/roles/prometheus_node_exporter/handlers/main.yml new file mode 100644 index 0000000..5b4d612 --- /dev/null +++ b/roles/prometheus_node_exporter/handlers/main.yml @@ -0,0 +1,9 @@ +--- +- name: daemon reload + systemd: + daemon_reload: yes + +- name: start node_exporter + service: + name: node_exporter + state: started diff --git a/roles/prometheus_node_exporter/tasks/main.yml b/roles/prometheus_node_exporter/tasks/main.yml new file mode 100644 index 0000000..37ba738 --- /dev/null +++ b/roles/prometheus_node_exporter/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Install prometheus-node-exporter + apt: + name: prometheus-node-exporter + state: present + update_cache: yes + +- name: Check if prometheus-node-exporter service is running + service: + name: prometheus-node-exporter + state: started + enabled: yes diff --git a/roles/samba/.travis.yml b/roles/samba/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/samba/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/samba/README.md b/roles/samba/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/samba/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/samba/defaults/main.yml b/roles/samba/defaults/main.yml new file mode 100644 index 0000000..0bfd24f --- /dev/null +++ b/roles/samba/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for create_samba_user diff --git a/roles/samba/handlers/main.yml b/roles/samba/handlers/main.yml new file mode 100644 index 0000000..9518990 --- /dev/null +++ b/roles/samba/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for create_samba_user +- name: smb restart + service: + name: smb + state: restarted \ No newline at end of file diff --git a/roles/samba/meta/main.yml b/roles/samba/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/samba/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/samba/tasks/main.yml b/roles/samba/tasks/main.yml new file mode 100644 index 0000000..79d2ce3 --- /dev/null +++ b/roles/samba/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: Install + ansible.builtin.package: + name: + - samba + state: present + +- name: Start and enabled + ansible.builtin.service: + name: smbd + state: started + enabled: true + +- name: Copy config + template: + src: ../templates/smb.conf + dest: /etc/samba/smb.conf + owner: root + group: root + mode: "0644" + notify: smb restart diff --git a/roles/samba/templates/smb.conf b/roles/samba/templates/smb.conf new file mode 100644 index 0000000..533215b --- /dev/null +++ b/roles/samba/templates/smb.conf @@ -0,0 +1,61 @@ +[global] + ;socket options = TCP_NODELAY + ;SO_RCVBUF=524288 SO_SNDBUF=524288 + workgroup = DOMA + log file = /var/log/samba/log.%m + max log size = 1000 + logging = file + panic action = /usr/share/samba/panic-action %d + server role = standalone server + obey pam restrictions = yes + unix password sync = yes + passwd program = /usr/bin/passwd %u + passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . + pam password change = yes + map to guest = bad user +; logon path = \\%N\profiles\%U +; logon drive = H: +; logon script = logon.cmd +; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u +; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u +; add group script = /usr/sbin/addgroup --force-badname %g +; include = /home/samba/etc/smb.conf.%m +; idmap config * : backend = tdb +; idmap config * : range = 3000-7999 +; idmap config YOURDOMAINHERE : backend = tdb +; idmap config YOURDOMAINHERE : range = 100000-999999 +; template shell = /bin/bash +;[netlogon] +; comment = Network Logon Service +; path = /home/samba/netlogon +; guest ok = yes +; read only = yes +;[profiles] +; comment = Users profiles +; path = /home/samba/profiles +; guest ok = no +; browseable = no +; create mask = 0600 +; directory mask = 0700 +;[printers] +; comment = All Printers +; browseable = no +; path = /var/spool/samba +; printable = yes +; guest ok = no +; read only = yes +; create mask = 0700 +;[print$] +; comment = Printer Drivers +; path = /var/lib/samba/printers +; browseable = yes +; read only = yes +; guest ok = no +; write list = root, @lpadmin +{% for user in samba_users %} +[{{ user.name }}] + comment = {{ user.path }} + path = {{ user.path }} + read only = no + browsable = yes +{% endfor %} diff --git a/roles/samba/tests/inventory b/roles/samba/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/samba/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/samba/tests/test.yml b/roles/samba/tests/test.yml new file mode 100644 index 0000000..a94884d --- /dev/null +++ b/roles/samba/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - create_samba_user diff --git a/roles/samba/vars/main.yml b/roles/samba/vars/main.yml new file mode 100644 index 0000000..17a16b8 --- /dev/null +++ b/roles/samba/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for create_samba_user diff --git a/roles/security/LICENSE b/roles/security/LICENSE new file mode 100644 index 0000000..4275cf3 --- /dev/null +++ b/roles/security/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Jeff Geerling + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/roles/security/README.md b/roles/security/README.md new file mode 100644 index 0000000..4f6f707 --- /dev/null +++ b/roles/security/README.md @@ -0,0 +1,126 @@ +# Ansible Role: Security (Basics) + +[![CI](https://github.com/geerlingguy/ansible-role-security/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-security/actions?query=workflow%3ACI) + +**First, a major, MAJOR caveat**: the security of your servers is YOUR responsibility. If you think simply including this role and adding a firewall makes a server secure, then you're mistaken. Read up on Linux, network, and application security, and know that no matter how much you know, you can always make every part of your stack more secure. + +That being said, this role performs some basic security configuration on RedHat and Debian-based linux systems. It attempts to: + + - Install software to monitor bad SSH access (fail2ban) + - Configure SSH to be more secure (disabling root login, requiring key-based authentication, and allowing a custom SSH port to be set) + - Set up automatic updates (if configured to do so) + +There are a few other things you may or may not want to do (which are not included in this role) to make sure your servers are more secure, like: + + - Use logwatch or a centralized logging server to analyze and monitor log files + - Securely configure user accounts and SSH keys (this role assumes you're not using password authentication or logging in as root) + - Have a well-configured firewall (check out the `geerlingguy.firewall` role on Ansible Galaxy for a flexible example) + +Again: Your servers' security is *your* responsibility. + +## Requirements + +For obvious reasons, `sudo` must be installed if you want to manage the sudoers file with this role. + +On RedHat/CentOS systems, make sure you have the EPEL repository installed (you can include the `geerlingguy.repo-epel` role to get it installed). + +No special requirements for Debian/Ubuntu systems. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + security_ssh_port: 22 + +The port through which you'd like SSH to be accessible. The default is port 22, but if you're operating a server on the open internet, and have no firewall blocking access to port 22, you'll quickly find that thousands of login attempts per day are not uncommon. You can change the port to a nonstandard port (e.g. 2849) if you want to avoid these thousands of automated penetration attempts. + + security_ssh_password_authentication: "no" + security_ssh_permit_root_login: "no" + security_ssh_usedns: "no" + security_ssh_permit_empty_password: "no" + security_ssh_challenge_response_auth: "no" + security_ssh_gss_api_authentication: "no" + security_ssh_x11_forwarding: "no" + +Security settings for SSH authentication. It's best to leave these set to `"no"`, but there are times (especially during initial server configuration or when you don't have key-based authentication in place) when one or all may be safely set to `'yes'`. **NOTE: It is _very_ important that you quote the 'yes' or 'no' values. Failure to do so may lock you out of your server.** + + security_ssh_allowed_users: [] + # - alice + # - bob + # - charlie + +A list of users allowed to connect to the host over SSH. If no user is defined in the list, the task will be skipped. + + security_ssh_allowed_groups: [] + # - admins + # - devs + +A list of groups allowed to connect to the host over SSH. If no group is defined in the list, the task will be skipped. + + security_sshd_state: started + +The state of the SSH daemon. Typically this should remain `started`. + + security_ssh_restart_handler_state: restarted + +The state of the `restart ssh` handler. Typically this should remain `restarted`. + + security_sudoers_passwordless: [] + security_sudoers_passworded: [] + +A list of users who should be added to the sudoers file so they can run any command as root (via `sudo`) either without a password or requiring a password for each command, respectively. + + security_autoupdate_enabled: true + +Whether to install/enable `yum-cron` (RedHat-based systems) or `unattended-upgrades` (Debian-based systems). System restarts will not happen automatically in any case, and automatic upgrades are no excuse for sloppy patch and package management, but automatic updates can be helpful as yet another security measure. + + security_autoupdate_blacklist: [] + +(Debian/Ubuntu only) A listing of packages that should not be automatically updated. + + security_autoupdate_reboot: false + +(Debian/Ubuntu only) Whether to reboot when needed during unattended upgrades. + + security_autoupdate_reboot_time: "03:00" + +(Debian/Ubuntu only) The time to trigger a reboot, when needed, if `security_autoupdate_reboot` is set to `true`. In 24h "hh:mm" clock format. + + security_autoupdate_mail_to: "" + security_autoupdate_mail_on_error: true + +(Debian/Ubuntu only) If `security_autoupdate_mail_to` is set to an non empty value, unattended upgrades will send an e-mail to that address when some error occurs. You may either set this to a full email: `ops@example.com` or to something like `root`, which will use `/etc/aliases` to route the message. If you set `security_autoupdate_mail_on_error` to `false` you'll get an email after every package install. + + security_fail2ban_enabled: true + +Whether to install/enable `fail2ban`. You might not want to use fail2ban if you're already using some other service for login and intrusion detection (e.g. [ConfigServer](http://configserver.com/cp/csf.html)). + + security_fail2ban_custom_configuration_template: "jail.local.j2" + +The name of the template file used to generate `fail2ban`'s configuration. + +## Dependencies + +None. + +## Example Playbook + + - hosts: servers + vars_files: + - vars/main.yml + roles: + - geerlingguy.security + +*Inside `vars/main.yml`*: + + security_sudoers_passworded: + - johndoe + - deployacct + +## License + +MIT (Expat) / BSD + +## Author Information + +This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/). diff --git a/roles/security/defaults/main.yml b/roles/security/defaults/main.yml new file mode 100644 index 0000000..b1010a3 --- /dev/null +++ b/roles/security/defaults/main.yml @@ -0,0 +1,28 @@ +--- +security_ssh_port: 22 +security_ssh_password_authentication: "no" +security_ssh_permit_root_login: "no" +security_ssh_usedns: "no" +security_ssh_permit_empty_password: "no" +security_ssh_challenge_response_auth: "no" +security_ssh_gss_api_authentication: "no" +security_ssh_x11_forwarding: "no" +security_sshd_state: started +security_ssh_restart_handler_state: restarted +security_ssh_allowed_users: [] +security_ssh_allowed_groups: [] + +security_sudoers_passwordless: [] +security_sudoers_passworded: [] + +security_autoupdate_enabled: true +security_autoupdate_blacklist: [] + +# Autoupdate mail settings used on Debian/Ubuntu only. +security_autoupdate_reboot: "false" +security_autoupdate_reboot_time: "03:00" +security_autoupdate_mail_to: "" +security_autoupdate_mail_on_error: true + +security_fail2ban_enabled: true +security_fail2ban_custom_configuration_template: "jail.local.j2" diff --git a/roles/security/handlers/main.yml b/roles/security/handlers/main.yml new file mode 100644 index 0000000..beb4e62 --- /dev/null +++ b/roles/security/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: restart ssh + service: + name: "{{ security_sshd_name }}" + state: "{{ security_ssh_restart_handler_state }}" + +- name: reload fail2ban + service: + name: fail2ban + state: reloaded diff --git a/roles/security/meta/main.yml b/roles/security/meta/main.yml new file mode 100644 index 0000000..7e3ac1b --- /dev/null +++ b/roles/security/meta/main.yml @@ -0,0 +1,30 @@ +--- +dependencies: [] + +galaxy_info: + role_name: security + author: geerlingguy + description: Security software installation and configuration. + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 2.10 + platforms: + - name: Fedora + versions: + - all + - name: Debian + versions: + - all + - name: Ubuntu + versions: + - all + galaxy_tags: + - system + - security + - fail2ban + - automatic + - updates + - yum + - apt + - dnf + - hardening diff --git a/roles/security/molecule/default/converge.yml b/roles/security/molecule/default/converge.yml new file mode 100644 index 0000000..1271dcf --- /dev/null +++ b/roles/security/molecule/default/converge.yml @@ -0,0 +1,44 @@ +--- +- name: Converge + hosts: all + become: true + + pre_tasks: + - name: Update apt cache. + package: + update_cache: true + cache_valid_time: 600 + when: ansible_os_family == 'Debian' + + - name: Ensure build dependencies are installed (RedHat). + package: + name: + - openssh-server + - openssh-clients + state: present + when: ansible_os_family == 'RedHat' + + - name: Ensure build dependencies are installed (Fedora). + package: + name: procps + state: present + when: ansible_distribution == 'Fedora' + + - name: Ensure build dependencies are installed (Debian). + package: + name: + - openssh-server + - openssh-client + state: present + when: ansible_os_family == 'Debian' + + - name: Ensure auth.log file is present. + copy: + dest: /var/log/auth.log + content: "" + force: false + mode: 0644 + when: ansible_distribution == 'Debian' + + roles: + - role: geerlingguy.security diff --git a/roles/security/molecule/default/molecule.yml b/roles/security/molecule/default/molecule.yml new file mode 100644 index 0000000..147da5d --- /dev/null +++ b/roles/security/molecule/default/molecule.yml @@ -0,0 +1,21 @@ +--- +role_name_check: 1 +dependency: + name: galaxy + options: + ignore-errors: true +driver: + name: docker +platforms: + - name: instance + image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux8}-ansible:latest" + command: ${MOLECULE_DOCKER_COMMAND:-""} + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:rw + cgroupns_mode: host + privileged: true + pre_build_image: true +provisioner: + name: ansible + playbooks: + converge: ${MOLECULE_PLAYBOOK:-converge.yml} diff --git a/roles/security/tasks/autoupdate-Debian.yml b/roles/security/tasks/autoupdate-Debian.yml new file mode 100644 index 0000000..05aebb7 --- /dev/null +++ b/roles/security/tasks/autoupdate-Debian.yml @@ -0,0 +1,16 @@ +--- +- name: Install unattended upgrades package. + package: + name: unattended-upgrades + state: present + +- name: Copy unattended-upgrades configuration files in place. + template: + src: "{{ item }}.j2" + dest: "/etc/apt/apt.conf.d/{{ item }}" + owner: root + group: root + mode: 0644 + with_items: + - 10periodic + - 50unattended-upgrades diff --git a/roles/security/tasks/autoupdate-RedHat.yml b/roles/security/tasks/autoupdate-RedHat.yml new file mode 100644 index 0000000..58a058b --- /dev/null +++ b/roles/security/tasks/autoupdate-RedHat.yml @@ -0,0 +1,35 @@ +--- +- name: Set correct automatic update utility vars (RHEL >= 8). + set_fact: + update_utility: dnf-automatic + update_service: dnf-automatic-install.timer + update_conf_path: /etc/dnf/automatic.conf + when: ansible_distribution_major_version | int >= 8 + +- name: Set correct automatic update utility vars (RHEL <= 7). + set_fact: + update_utility: yum-cron + update_service: yum-cron + update_conf_path: /etc/yum/yum-cron.conf + when: ansible_distribution_major_version | int <= 7 + +- name: Install automatic update utility. + package: + name: '{{ update_utility }}' + state: present + +- name: Ensure automatic update utility is running and enabled on boot. + service: + name: '{{ update_service }}' + state: started + enabled: true + +- name: Configure autoupdates. + lineinfile: + dest: '{{ update_conf_path }}' + regexp: '^apply_updates = .+' + line: 'apply_updates = yes' + mode: 0644 + when: + - security_autoupdate_enabled + - ansible_distribution_major_version | int in [7, 8] diff --git a/roles/security/tasks/fail2ban.yml b/roles/security/tasks/fail2ban.yml new file mode 100644 index 0000000..1b7a7f8 --- /dev/null +++ b/roles/security/tasks/fail2ban.yml @@ -0,0 +1,29 @@ +--- +- name: Install fail2ban (RedHat). + package: + name: fail2ban + state: present + enablerepo: epel + when: ansible_os_family == 'RedHat' + +- name: Install fail2ban (Debian). + package: + name: fail2ban + state: present + when: ansible_os_family == 'Debian' + +- name: Copy fail2ban custom configuration file into place. + template: + src: "{{ security_fail2ban_custom_configuration_template }}" + dest: /etc/fail2ban/jail.local + owner: root + group: root + mode: 0644 + notify: + - reload fail2ban + +- name: Ensure fail2ban is running and enabled on boot. + service: + name: fail2ban + state: started + enabled: true diff --git a/roles/security/tasks/main.yml b/roles/security/tasks/main.yml new file mode 100644 index 0000000..24e5860 --- /dev/null +++ b/roles/security/tasks/main.yml @@ -0,0 +1,21 @@ +--- +- name: Include OS-specific variables. + include_vars: "{{ ansible_os_family }}.yml" + +# Fail2Ban +- include_tasks: fail2ban.yml + when: security_fail2ban_enabled | bool + +# SSH +- include_tasks: ssh.yml + +# Autoupdate +- include_tasks: autoupdate-RedHat.yml + when: + - ansible_os_family == 'RedHat' + - security_autoupdate_enabled | bool + +- include_tasks: autoupdate-Debian.yml + when: + - ansible_os_family == 'Debian' + - security_autoupdate_enabled | bool diff --git a/roles/security/tasks/ssh.yml b/roles/security/tasks/ssh.yml new file mode 100644 index 0000000..9940ecb --- /dev/null +++ b/roles/security/tasks/ssh.yml @@ -0,0 +1,34 @@ +--- +- name: Ensure SSH daemon is running. + service: + name: "{{ security_sshd_name }}" + state: "{{ security_sshd_state }}" + +- name: Update SSH configuration to be more secure. + lineinfile: + dest: "{{ security_ssh_config_path }}" + regexp: "{{ item.regexp }}" + line: "{{ item.line }}" + state: present + validate: "sshd -T -f %s" + mode: 0644 + with_items: + - regexp: "^PasswordAuthentication" + line: "PasswordAuthentication {{ security_ssh_password_authentication }}" + - regexp: "^PermitRootLogin" + line: "PermitRootLogin {{ security_ssh_permit_root_login }}" + - regexp: "^Port" + line: "Port {{ security_ssh_port }}" + - regexp: "^UseDNS" + line: "UseDNS {{ security_ssh_usedns }}" + - regexp: "^PermitEmptyPasswords" + line: "PermitEmptyPasswords {{ security_ssh_permit_empty_password }}" + - regexp: "^ChallengeResponseAuthentication" + line: "ChallengeResponseAuthentication {{ security_ssh_challenge_response_auth }}" + - regexp: "^GSSAPIAuthentication" + line: "GSSAPIAuthentication {{ security_ssh_gss_api_authentication }}" + - regexp: "^X11Forwarding" + line: "X11Forwarding {{ security_ssh_x11_forwarding }}" + #- regexp: "^ListenAddress" + # line: "ListenAddress {{ ip_admin }}" + notify: restart ssh diff --git a/roles/security/templates/10periodic.j2 b/roles/security/templates/10periodic.j2 new file mode 100644 index 0000000..5d37e9f --- /dev/null +++ b/roles/security/templates/10periodic.j2 @@ -0,0 +1,4 @@ +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Download-Upgradeable-Packages "1"; +APT::Periodic::AutocleanInterval "7"; +APT::Periodic::Unattended-Upgrade "1"; diff --git a/roles/security/templates/50unattended-upgrades.j2 b/roles/security/templates/50unattended-upgrades.j2 new file mode 100644 index 0000000..297f696 --- /dev/null +++ b/roles/security/templates/50unattended-upgrades.j2 @@ -0,0 +1,20 @@ +Unattended-Upgrade::Automatic-Reboot "{{ security_autoupdate_reboot }}"; +Unattended-Upgrade::Automatic-Reboot-Time "{{ security_autoupdate_reboot_time }}"; + +{% if security_autoupdate_mail_to %} +Unattended-Upgrade::Mail "{{ security_autoupdate_mail_to }}"; +{% if security_autoupdate_mail_on_error %} +Unattended-Upgrade::MailOnlyOnError "true"; +{% endif %} +{% endif %} + +Unattended-Upgrade::Allowed-Origins { + "${distro_id} ${distro_codename}-security"; +// "${distro_id} ${distro_codename}-updates"; +}; + +Unattended-Upgrade::Package-Blacklist{ +{% for package in security_autoupdate_blacklist %} + "{{package}}"; +{% endfor %} +} diff --git a/roles/security/templates/jail.local.j2 b/roles/security/templates/jail.local.j2 new file mode 100644 index 0000000..90ce1c0 --- /dev/null +++ b/roles/security/templates/jail.local.j2 @@ -0,0 +1,5 @@ +[sshd] +enabled = true +port = {{ security_ssh_port }} +filter = sshd +backend = systemd diff --git a/roles/security/vars/Debian.yml b/roles/security/vars/Debian.yml new file mode 100644 index 0000000..c66e186 --- /dev/null +++ b/roles/security/vars/Debian.yml @@ -0,0 +1,3 @@ +--- +security_ssh_config_path: /etc/ssh/sshd_config +security_sshd_name: ssh diff --git a/roles/security/vars/RedHat.yml b/roles/security/vars/RedHat.yml new file mode 100644 index 0000000..d7b1921 --- /dev/null +++ b/roles/security/vars/RedHat.yml @@ -0,0 +1,3 @@ +--- +security_ssh_config_path: /etc/ssh/sshd_config +security_sshd_name: sshd diff --git a/roles/template_differ/README.md b/roles/template_differ/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/template_differ/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/template_differ/defaults/main.yml b/roles/template_differ/defaults/main.yml new file mode 100644 index 0000000..6f2816a --- /dev/null +++ b/roles/template_differ/defaults/main.yml @@ -0,0 +1,3 @@ +#SPDX-License-Identifier: MIT-0 +--- +# defaults file for template-differ diff --git a/roles/template_differ/handlers/main.yml b/roles/template_differ/handlers/main.yml new file mode 100644 index 0000000..c5a5cd7 --- /dev/null +++ b/roles/template_differ/handlers/main.yml @@ -0,0 +1,10 @@ +--- +- name: networking restart + service: + name: networking + state: restarted + +- name: sshd restart + service: + name: sshd + state: restarted diff --git a/roles/template_differ/meta/main.yml b/roles/template_differ/meta/main.yml new file mode 100644 index 0000000..36b9858 --- /dev/null +++ b/roles/template_differ/meta/main.yml @@ -0,0 +1,35 @@ +#SPDX-License-Identifier: MIT-0 +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/template_differ/tasks/main.yml b/roles/template_differ/tasks/main.yml new file mode 100644 index 0000000..e6e4a5a --- /dev/null +++ b/roles/template_differ/tasks/main.yml @@ -0,0 +1,42 @@ +#SPDX-License-Identifier: MIT-0 +--- +# tasks file for template-differ + +- name: Remove old ssh host keys + ansible.builtin.file: + path: /etc/ssh/ssh_host_* + state: absent + +- name: Generate SSH host keys + shell: ssh-keygen -A + +- name: Set a hostname + ansible.builtin.hostname: + name: "{{ new_hostname }}" + + +- name: Interface IP change + template: + src: ../templates/interfaces + dest: /etc/network/interfaces + owner: root + group: root + mode: '0644' + +- name: Etc hosts change + template: + src: ../templates/hosts + dest: /etc/hosts + owner: root + group: root + mode: '0644' + +- name: sshd restart + service: + name: sshd + state: restarted + +- name: networking restart + service: + name: networking + state: restarted diff --git a/roles/template_differ/templates/hosts b/roles/template_differ/templates/hosts new file mode 100644 index 0000000..ab19451 --- /dev/null +++ b/roles/template_differ/templates/hosts @@ -0,0 +1,7 @@ +127.0.0.1 localhost +{{ ip }} {{ new_hostname }} + +# The following lines are desirable for IPv6 capable hosts +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/roles/template_differ/templates/interfaces b/roles/template_differ/templates/interfaces new file mode 100644 index 0000000..6362ca8 --- /dev/null +++ b/roles/template_differ/templates/interfaces @@ -0,0 +1,15 @@ +# This file describes the network interfaces available on your system +# and how to activate them. For more information, see interfaces(5). + +source /etc/network/interfaces.d/* + +# The loopback network interface +auto lo +iface lo inet loopback + +# The primary network interface +allow-hotplug {{ interface_name }} +iface {{ interface_name }} inet static + address {{ address_with_cird }} + gateway {{ gateway }} + dns-nameservers {{ dns }} diff --git a/roles/template_differ/tests/inventory b/roles/template_differ/tests/inventory new file mode 100644 index 0000000..03ca42f --- /dev/null +++ b/roles/template_differ/tests/inventory @@ -0,0 +1,3 @@ +#SPDX-License-Identifier: MIT-0 +localhost + diff --git a/roles/template_differ/tests/test.yml b/roles/template_differ/tests/test.yml new file mode 100644 index 0000000..8148e9c --- /dev/null +++ b/roles/template_differ/tests/test.yml @@ -0,0 +1,6 @@ +#SPDX-License-Identifier: MIT-0 +--- +- hosts: localhost + remote_user: root + roles: + - template-differ diff --git a/roles/template_differ/vars/main.yml b/roles/template_differ/vars/main.yml new file mode 100644 index 0000000..3ec5317 --- /dev/null +++ b/roles/template_differ/vars/main.yml @@ -0,0 +1,3 @@ +#SPDX-License-Identifier: MIT-0 +--- +# vars file for template-differ diff --git a/roles/tools_for_command_line/.travis.yml b/roles/tools_for_command_line/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/tools_for_command_line/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/tools_for_command_line/defaults/main.yml b/roles/tools_for_command_line/defaults/main.yml new file mode 100644 index 0000000..ec8b018 --- /dev/null +++ b/roles/tools_for_command_line/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for tools_for_command_line diff --git a/roles/tools_for_command_line/handlers/main.yml b/roles/tools_for_command_line/handlers/main.yml new file mode 100644 index 0000000..c8669c6 --- /dev/null +++ b/roles/tools_for_command_line/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for tools_for_command_line diff --git a/roles/tools_for_command_line/tasks/administration.yml b/roles/tools_for_command_line/tasks/administration.yml new file mode 100644 index 0000000..43a1362 --- /dev/null +++ b/roles/tools_for_command_line/tasks/administration.yml @@ -0,0 +1,39 @@ +--- +- name: Administration + become: true + ansible.builtin.package: + name: + - htop + - mc + - nano + - net-tools + - ncdu + - nmap + - telnet + - gpg + - openssh-server + - sudo + - rsync + - iotop + - screen + - python3 + - python3-pip + - git + - curl + state: present + +- name: Wireguard deb + become: true + ansible.builtin.package: + name: + - wireguard + state: present + when: ansible_os_family == 'Debian' + +- name: Wireguard other + become: true + ansible.builtin.package: + name: + - wireguard-tools + state: present + when: ansible_os_family != 'Debian' diff --git a/roles/tools_for_command_line/tasks/main.yml b/roles/tools_for_command_line/tasks/main.yml new file mode 100644 index 0000000..b5c023f --- /dev/null +++ b/roles/tools_for_command_line/tasks/main.yml @@ -0,0 +1,5 @@ +--- +# tasks file for tools_for_command_line +- name: Critical system + ansible.builtin.include_tasks: + administration.yml diff --git a/roles/tools_for_command_line/tests/inventory b/roles/tools_for_command_line/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/tools_for_command_line/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/tools_for_command_line/tests/test.yml b/roles/tools_for_command_line/tests/test.yml new file mode 100644 index 0000000..fbdd450 --- /dev/null +++ b/roles/tools_for_command_line/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - tools_for_command_line diff --git a/roles/tools_for_command_line/vars/main.yml b/roles/tools_for_command_line/vars/main.yml new file mode 100644 index 0000000..5f92726 --- /dev/null +++ b/roles/tools_for_command_line/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for tools_for_command_line diff --git a/roles/wireguard_server/README.md b/roles/wireguard_server/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/wireguard_server/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/wireguard_server/defaults/main.yml b/roles/wireguard_server/defaults/main.yml new file mode 100644 index 0000000..35fc79f --- /dev/null +++ b/roles/wireguard_server/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for wireguard-server diff --git a/roles/wireguard_server/handlers/main.yml b/roles/wireguard_server/handlers/main.yml new file mode 100644 index 0000000..2a68778 --- /dev/null +++ b/roles/wireguard_server/handlers/main.yml @@ -0,0 +1,6 @@ +--- +# handlers file for wireguard-server +- name: wireguard-server restart + ansible.builtin.service: + name: wg-quick@wireguardserver + state: restarted diff --git a/roles/wireguard_server/meta/main.yml b/roles/wireguard_server/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/wireguard_server/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/wireguard_server/tasks/main.yml b/roles/wireguard_server/tasks/main.yml new file mode 100644 index 0000000..95931d5 --- /dev/null +++ b/roles/wireguard_server/tasks/main.yml @@ -0,0 +1,19 @@ +--- +- name: Copy config + template: + src: ../templates/wireguardserver.conf + dest: /etc/wireguard/wireguardserver.conf + owner: root + group: root + mode: '0644' + notify: wireguard-server restart + +- name: Install iptables + ansible.builtin.package: + name: iptables + +- name: Start and enabled + ansible.builtin.service: + name: wg-quick@wireguardserver + state: started + enabled: true \ No newline at end of file diff --git a/roles/wireguard_server/templates/wireguardclient.conf b/roles/wireguard_server/templates/wireguardclient.conf new file mode 100644 index 0000000..16990ad --- /dev/null +++ b/roles/wireguard_server/templates/wireguardclient.conf @@ -0,0 +1,14 @@ +[Interface] +Address = {{ IP }}/24 +DNS = 192.168.5.5 +#PostUP = wifi-wireguard -e +#PostDOWN = wifi-wireguard -d +SaveConfig = false +ListenPort = 40041 +PrivateKey = {{ priv }} + +[Peer] +PublicKey = {{ wireguard_server_pub }} +AllowedIPs = 10.0.0.0/24, 192.168.5.0/24, 192.168.6.0/24, 192.168.100.0/24 +Endpoint = 185.61.86.153:51822 +PersistentKeepalive = 20 diff --git a/roles/wireguard_server/templates/wireguardserver.conf b/roles/wireguard_server/templates/wireguardserver.conf new file mode 100644 index 0000000..3e68e7e --- /dev/null +++ b/roles/wireguard_server/templates/wireguardserver.conf @@ -0,0 +1,26 @@ +[Interface] +PrivateKey = {{ wireguard_server_key }} +Address=10.0.0.1/24 +PostUp=iptables -A FORWARD -i wireguardserver -o ens18 -j ACCEPT; iptables -A FORWARD -i ens18 -o wireguardserver -j ACCEPT; iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE; +PostDown=iptables -D FORWARD -i wireguardserver -o ens18 -j ACCEPT; iptables -D FORWARD -i ens18 -o wireguardserver -j ACCEPT; iptables -t nat -D POSTROUTING -o ens18 -j MASQUERADE; +ListenPort=51822 + +[Peer] +PublicKey = {{ wireguard_ntb_pub }} +AllowedIPs = {{ wireguard_ntb_ip }}/32 + +[Peer] +PublicKey = {{ wireguard_kate_pub }} +AllowedIPs = {{ wireguard_kate_ip }}/32 + +[Peer] +PublicKey = {{ wireguard_tata_pub }} +AllowedIPs = {{ wireguard_tata_ip }}/32 + +[Peer] +PublicKey = {{ wireguard_pi_pub }} +AllowedIPs = {{ wireguard_pi_ip }}/32 + +[Peer] +PublicKey = {{ wireguard_desktop_pub }} +AllowedIPs = {{ wireguard_desktop_ip }}/32 diff --git a/roles/wireguard_server/tests/inventory b/roles/wireguard_server/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/wireguard_server/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/wireguard_server/tests/test.yml b/roles/wireguard_server/tests/test.yml new file mode 100644 index 0000000..f27f534 --- /dev/null +++ b/roles/wireguard_server/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - wireguard-server diff --git a/roles/wireguard_server/vars/main.yml b/roles/wireguard_server/vars/main.yml new file mode 100644 index 0000000..00259a3 --- /dev/null +++ b/roles/wireguard_server/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for wireguard-server diff --git a/roles/zfs_install/.travis.yml b/roles/zfs_install/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/roles/zfs_install/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file diff --git a/roles/zfs_install/README.md b/roles/zfs_install/README.md new file mode 100644 index 0000000..225dd44 --- /dev/null +++ b/roles/zfs_install/README.md @@ -0,0 +1,38 @@ +Role Name +========= + +A brief description of the role goes here. + +Requirements +------------ + +Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required. + +Role Variables +-------------- + +A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well. + +Dependencies +------------ + +A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles. + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: username.rolename, x: 42 } + +License +------- + +BSD + +Author Information +------------------ + +An optional section for the role authors to include contact information, or a website (HTML is not allowed). diff --git a/roles/zfs_install/defaults/main.yml b/roles/zfs_install/defaults/main.yml new file mode 100644 index 0000000..803c95e --- /dev/null +++ b/roles/zfs_install/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for zfs-install diff --git a/roles/zfs_install/handlers/main.yml b/roles/zfs_install/handlers/main.yml new file mode 100644 index 0000000..e6be0c9 --- /dev/null +++ b/roles/zfs_install/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for zfs-install diff --git a/roles/zfs_install/meta/main.yml b/roles/zfs_install/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/roles/zfs_install/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/roles/zfs_install/tasks/main.yml b/roles/zfs_install/tasks/main.yml new file mode 100644 index 0000000..bca02f9 --- /dev/null +++ b/roles/zfs_install/tasks/main.yml @@ -0,0 +1,23 @@ +--- +# tasks file for zfs-install +- name: Set on Contrib for Debian + apt_repository: + repo: deb http://deb.debian.org/debian {{ ansible_distribution_release }} contrib + state: present + filename: contrib + update_cache: true + when: ansible_os_family == "Debian" + +- name: Zfs isntall + become: true + ansible.builtin.package: + name: + - zfsutils-linux + - linux-headers-amd64 + - zfs-dkms + - zfs-zed + state: present + +- name: Add the zfs module + community.general.modprobe: + name: zfs diff --git a/roles/zfs_install/tests/inventory b/roles/zfs_install/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/roles/zfs_install/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/roles/zfs_install/tests/test.yml b/roles/zfs_install/tests/test.yml new file mode 100644 index 0000000..b2999dd --- /dev/null +++ b/roles/zfs_install/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - zfs-install diff --git a/roles/zfs_install/vars/main.yml b/roles/zfs_install/vars/main.yml new file mode 100644 index 0000000..8fc86d8 --- /dev/null +++ b/roles/zfs_install/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for zfs-install diff --git a/vault.yml b/vault.yml deleted file mode 100644 index 99d3ebc..0000000 --- a/vault.yml +++ /dev/null @@ -1,75 +0,0 @@ -$ANSIBLE_VAULT;1.1;AES256 -64663733653431333864383934646232356530373039646261356436356233353163666666643666 -3565386437656337653665393731613631393332313130390a653037363536306365643439343336 -38633362323135303962643731346139393831663133303864663035626332633763363039623836 -6563633039623230330a333239653463366165326464613161383533396361303135613635356665 -30343066366133616135343866636537353934363438366233643338666232663264626466303931 -63656438326635336137306666376663636565333234613536393563623430363561363832353965 -38313364353732613166353831643731303938663737626230396236356139663034393561396137 -33313736346235303230353834306437313730623238646562363963376533346161666431623137 -32376337636465343832613834366266633533323132306264323330343439636663356462666633 -30656336376537383839333861613866393464633963623537333835396139646237333064633463 -33316336343838376237333630633339623537353935373731306133393433373062616237663839 -33363239313033346263613066386262636139356437623834326535396334386534656161666266 -63353434393565393861633464653336663033366638633261633963333866656438326437383734 -61336636636564326366393739633639393232643430666166393138313138663136353539633331 -64326263353936636232636166393232646632313961393938653766393766363862386335373335 -39376632663866653633663437646431383261356130303765623638633337373265333466356164 -32373030363737393038376433643962636436343061653631373731656130623735383031633930 -61383938353032643833303630386562313535393730333938663331363963313231346139333636 -32636665396139353034383138653863363366386432316630616633343934373162633030386530 -38343434613532333835353939616331626233373232303962636239656539383966366132316161 -35613863373065616461336666363733663935666538373530643137393639656135373862613361 -30633632336136356431623934363063623337353465303666623239663530613430633566393463 -35613430626563396661333733353931626630666632336531363162633738393934656638323838 -64333062616362613862316463613438653433323265613136323634306361306637393938356439 -37396433393139363032623533386339323239626535633331383538323434346662303436623931 -66383035666334313332343664386135326330613937393039353634666562333166623532313938 -33383564643333363336316631383161306566326131636636323364633863666534383538366531 -33656439623763353165313031333136363233613935333739663961383438376432323239323034 -62393531383335326235656461643837363266313332643432396463366237353831313462396265 -37393763623266383063353135373565623437666463383765613461386636343963356635326566 -63343463346661656564306130633433373234653734343131666564643934303665666431313137 -66616235343833306330346433336564643539653866393538353962616331623962643063373138 -64393231343162333134326234343034343433373431653533363830633965393935396164353761 -66346637623939336564626665313863643961373332346539613333363761313765636630653565 -31653263363432656132393736666437363664343639643933316461643338366235626434313533 -34646134366631353431356133323936373962363035386331663331646236353565653562326431 -38316532663631353533343039333162313665613031316432623136666238303137303662303561 -66613732613866366433363661653537376637656239363539653861623233633535313334656636 -32336562303339326666306265313961306264616666386237363738363063363636383937623036 -33643462386230373430396266333336623331626663346435653935343363653265613236393462 -34393536626261376165313966303139653937663662623831616266343965303062363633373330 -33646630356437616531393736663263346136366235643930626333383532336537386638646535 -31643136373130356536613736336564653662333035633636393665653437316532626633333465 -39356237343238323838383737333737343037363832613466313162386563306533393338353434 -39613433323934663132633263336462613339646133353231643961666239303236656361343738 -35393033303165333233366465386337393339333032373438393134623133363633316562616233 -31396138336230343336383733356637616531663232303563306235643633613865353830663936 -33643938616362343932653764343736373639376366383136656635383065646534626361366434 -38313061643634336663643162656161336562646639643639663732366263393965316432353364 -32353961623363616166306437373766626466386133666530613930303935626665323262313534 -34666235356134336231616535666262323864623161363138316333376534623032623461343931 -62323861363130366632313963653232656530303735343764366433613739333832376665613132 -63633434623639353930326136303061343332623035613463323038666261623966343336666239 -36306136393439383739323438396130393439613064643563646664323737303135623265383837 -61306461613639373336313237316662323866313735393163636537643330613037376539613562 -38356135356166333237326264396532653061333066353364633333653334643166376362366235 -39636465373137336464623862636336643238356532323436336433333465373432393666343431 -63396561366266393834343063373733623964316337353637666236353339336139376137383933 -30646133353965393636323439313536636130336534323464646465343737656533333438383330 -39313364616661383665633761623136653638363531313437333266633964666530393334333565 -37623638376138616332373164393531333665323233373938393334383463653766633535303963 -63656265623835633762613264343538376264343833656636656338626239393236396661363230 -36613539343633666335323066346663643937306636656164643734636265383539323631616338 -31333539363032353038373537353436636130616563356636656234383661623534656137656234 -62393937653630656330393962303837623234353535386436633633373930313965313934616164 -37316337666263303361633363616638633530616536343332633234633932373133623861336134 -39633865313633623163366461643065643837356339386438303962636439656664613366343565 -63313166383139353934386563626637303532356137373034636262613135393862353536613039 -38383966626162623837373239633762313230383064376132313038313131636433326332393662 -31346437663235376230636434316139363233396162353230323634363566356638643766316636 -62616233383039383265613535386162663031303539313336363638396366343163626435616465 -64353633306465316336623638383964623436383633383762363364643837386162376466376234 -35303164633964666362666438323639636134343061656437303764313638353738633961646338 -6235643933333637336163623562616530383161653533633861