diff --git a/bittorrent.yml b/bittorrent.yml index 7bb54ce..b951f45 100644 --- a/bittorrent.yml +++ b/bittorrent.yml @@ -1,6 +1,7 @@ --- -- hosts: transmission +- name: Transmission + hosts: transmission diff: true roles: - bittorrent diff --git a/borgbackup.yml b/borgbackup.yml index d724049..07882ab 100644 --- a/borgbackup.yml +++ b/borgbackup.yml @@ -1,14 +1,17 @@ --- -- hosts: borgbackup +- name: Borgbackup + hosts: borgbackup diff: true roles: - borgbackup -- hosts: borg_client +- name: Borg clients + hosts: borg_client diff: true roles: - borg_client -- hosts: borg_server +- name: Borg server + hosts: borg_server diff: true roles: - borg_server diff --git a/docker.yml b/docker.yml index befa528..ffa35c4 100644 --- a/docker.yml +++ b/docker.yml @@ -1,6 +1,7 @@ --- -- hosts: dockerservers +- name: Docker + hosts: dockerservers diff: true roles: - docker diff --git a/firewall.yml b/firewall.yml index 727006f..e659f8f 100644 --- a/firewall.yml +++ b/firewall.yml @@ -1,11 +1,14 @@ --- -- hosts: all:!baybay-ponay.mateu.be:!machinbox.mateu.be:!muse-HP-EliteBook-820-G2.home.arpa +- name: Retrieve network info + hosts: all:!baybay-ponay.mateu.be:!machinbox.mateu.be:!muse-HP-EliteBook-820-G2.home.arpa gather_facts: true gather_subset: - network tasks: [] -- hosts: router + +- name: Router + hosts: router diff: true roles: - firewall diff --git a/ftp.yml b/ftp.yml index 5bb4011..90eb8a5 100644 --- a/ftp.yml +++ b/ftp.yml @@ -1,6 +1,7 @@ --- -- hosts: ftpservers +- name: FTP + hosts: ftpservers diff: true roles: - ftp diff --git a/garage.yml b/garage.yml index 5d2973a..7452525 100644 --- a/garage.yml +++ b/garage.yml @@ -1,6 +1,7 @@ --- -- hosts: garageservers +- name: Garage + hosts: garageservers diff: true roles: - garage diff --git a/icecast2.yml b/icecast2.yml index d2a6e69..bdc57cf 100644 --- a/icecast2.yml +++ b/icecast2.yml @@ -1,6 +1,7 @@ --- -- hosts: icecastservers +- name: Icecast + hosts: icecastservers diff: true roles: - icecast2 diff --git a/loadbalancinghttp.yml b/loadbalancinghttp.yml index 0188f73..0336e65 100644 --- a/loadbalancinghttp.yml +++ b/loadbalancinghttp.yml @@ -1,6 +1,7 @@ --- -- hosts: loadbalancers +- name: Load balancers + hosts: loadbalancers diff: true roles: - haproxy diff --git a/mail.yml b/mail.yml index 8159bd0..696a695 100644 --- a/mail.yml +++ b/mail.yml @@ -1,6 +1,7 @@ --- -- hosts: mailservers +- name: Mail + hosts: mailservers diff: true roles: - postfix diff --git a/mariadb.yml b/mariadb.yml index 84db7f7..140972b 100644 --- a/mariadb.yml +++ b/mariadb.yml @@ -1,6 +1,7 @@ --- -- hosts: mariadbservers +- name: MariaDB + hosts: mariadbservers diff: true roles: - mariadb diff --git a/mastodon.yml b/mastodon.yml index 4d1d266..cb39f80 100644 --- a/mastodon.yml +++ b/mastodon.yml @@ -1,6 +1,7 @@ --- -- hosts: mastodonservers +- name: Mastodon + hosts: mastodonservers diff: true roles: - mastodon diff --git a/mumble.yml b/mumble.yml index f9393a8..e772ade 100644 --- a/mumble.yml +++ b/mumble.yml @@ -1,6 +1,7 @@ --- -- hosts: mumbleservers +- name: Mumble + hosts: mumbleservers diff: true roles: - mumble diff --git a/munin.yml b/munin.yml index 85184c7..31f6609 100644 --- a/munin.yml +++ b/munin.yml @@ -1,11 +1,13 @@ --- -- hosts: all:!disabled_munin +- name: Munin clients + hosts: all:!disabled_munin diff: true roles: - munin_client -- hosts: muninservers +- name: Munin servers + hosts: muninservers diff: true roles: - munin_server diff --git a/nut.yml b/nut.yml index 69429a2..e26bb53 100644 --- a/nut.yml +++ b/nut.yml @@ -1,10 +1,12 @@ --- -- hosts: nut_server +- name: NUT server + hosts: nut_server diff: true roles: - nut_server -- hosts: nut_client +- name: NUT clients + hosts: nut_client diff: true roles: - nut_client diff --git a/pgsql.yml b/pgsql.yml index d98a30a..9a9591e 100644 --- a/pgsql.yml +++ b/pgsql.yml @@ -1,6 +1,7 @@ --- -- hosts: pgsqlservers +- name: PostgreSQL + hosts: pgsqlservers diff: true roles: - postgres diff --git a/php.yml b/php.yml index b2072b0..b71edcd 100644 --- a/php.yml +++ b/php.yml @@ -1,6 +1,7 @@ --- -- hosts: phpservers +- name: PHP + hosts: phpservers diff: true roles: - php diff --git a/restic.yml b/restic.yml index 02ca41a..813aa04 100644 --- a/restic.yml +++ b/restic.yml @@ -1,6 +1,7 @@ --- -- hosts: resticservers +- name: Restic + hosts: resticservers diff: true roles: - restic diff --git a/roles/bittorrent/handlers/main.yml b/roles/bittorrent/handlers/main.yml index a0fb688..d1d69a3 100644 --- a/roles/bittorrent/handlers/main.yml +++ b/roles/bittorrent/handlers/main.yml @@ -1,14 +1,16 @@ --- -- name: reload transmission - service: +- name: Reload transmission + ansible.builtin.service: name: transmission-daemon state: reloaded -- name: restart sonarr - service: +- name: Restart sonarr + ansible.builtin.service: name: sonarr state: restarted -- name: export nfs - command: exportfs -a +- name: Export nfs + ansible.builtin.command: + cmd: exportfs -a + changed_when: true diff --git a/roles/bittorrent/tasks/configdir.yml b/roles/bittorrent/tasks/configdir.yml index e02d19c..ed1ef5d 100644 --- a/roles/bittorrent/tasks/configdir.yml +++ b/roles/bittorrent/tasks/configdir.yml @@ -1,14 +1,14 @@ --- -- name: create Series folder - file: +- name: Create Series folder + ansible.builtin.file: path: /var/lib/transmission-daemon/downloads/Series recurse: true owner: debian-transmission group: debian-transmission -- name: create Movies folder - file: +- name: Create Movies folder + ansible.builtin.file: path: /var/lib/transmission-daemon/downloads/Movies recurse: true owner: debian-transmission diff --git a/roles/bittorrent/tasks/main.yml b/roles/bittorrent/tasks/main.yml index be66e9a..a33bae2 100644 --- a/roles/bittorrent/tasks/main.yml +++ b/roles/bittorrent/tasks/main.yml @@ -1,7 +1,12 @@ --- -- include_tasks: transmission.yml -- include_tasks: sonarr.yml -- include_tasks: subliminal.yml -- include_tasks: configdir.yml -- include_tasks: nfsserver.yml +- name: Include transmission + ansible.builtin.include_tasks: transmission.yml +- name: Include sonarr + ansible.builtin.include_tasks: sonarr.yml +- name: Include subliminal + ansible.builtin.include_tasks: subliminal.yml +- name: Include configdir + ansible.builtin.include_tasks: configdir.yml +- name: Include nfsserver + ansible.builtin.include_tasks: nfsserver.yml diff --git a/roles/bittorrent/tasks/nfsserver.yml b/roles/bittorrent/tasks/nfsserver.yml index 6e98162..0d1192a 100644 --- a/roles/bittorrent/tasks/nfsserver.yml +++ b/roles/bittorrent/tasks/nfsserver.yml @@ -1,17 +1,19 @@ --- -- getent: +- name: Get debian-transmission id + ansible.builtin.getent: database: passwd key: debian-transmission -- name: install nfs server - package: +- name: Install nfs server + ansible.builtin.package: name: nfs-kernel-server state: present -- name: copy exports file - template: +- name: Copy exports file + ansible.builtin.template: src: exports.j2 dest: /etc/exports + mode: 0644 notify: - - export nfs + - Export nfs diff --git a/roles/bittorrent/tasks/sonarr.yml b/roles/bittorrent/tasks/sonarr.yml index 556460f..8ee1d74 100644 --- a/roles/bittorrent/tasks/sonarr.yml +++ b/roles/bittorrent/tasks/sonarr.yml @@ -1,29 +1,29 @@ --- -- name: install sonarr repokey - apt_key: +- name: Install sonarr repokey + ansible.builtin.apt_key: keyserver: keyserver.ubuntu.com id: "0xa236c58f409091a18aca53cbebff6b99d9b78493" -- name: install sonarr repo - apt_repository: +- name: Install sonarr repo + ansible.builtin.apt_repository: repo: deb http://apt.sonarr.tv/debian buster-develop main state: present -- name: create sonarr conf dir - file: +- name: Create sonarr conf dir + ansible.builtin.file: path: /var/lib/transmission-daemon/.config/NzbDrone recurse: true owner: debian-transmission group: debian-transmission mode: "a-rwx,u+rwX,g+rX" -- name: install sonarr - package: +- name: Install sonarr + ansible.builtin.package: name: sonarr state: present -- name: enable sonarr service - service: +- name: Enable sonarr service + ansible.builtin.service: name: sonarr enabled: true diff --git a/roles/bittorrent/tasks/subliminal.yml b/roles/bittorrent/tasks/subliminal.yml index 89d2a61..0c22a65 100644 --- a/roles/bittorrent/tasks/subliminal.yml +++ b/roles/bittorrent/tasks/subliminal.yml @@ -1,17 +1,17 @@ --- -- name: install pip3 - package: +- name: Install pip3 + ansible.builtin.package: name: python3-pip state: present -- name: install subliminal - pip: +- name: Install subliminal + ansible.builtin.pip: name: subliminal state: present -- name: install subliminal crontab - cron: +- name: Install subliminal crontab + ansible.builtin.cron: name: "Sub DL" user: "debian-transmission" minute: "15" diff --git a/roles/bittorrent/tasks/transmission.yml b/roles/bittorrent/tasks/transmission.yml index bf29e81..2e2cc74 100644 --- a/roles/bittorrent/tasks/transmission.yml +++ b/roles/bittorrent/tasks/transmission.yml @@ -1,25 +1,25 @@ --- -- name: install transmission - package: +- name: Install transmission + ansible.builtin.package: name: "{{ item }}" state: present loop: - transmission-daemon - transmission-cli -- name: transmission config file - template: +- name: Transmission config file + ansible.builtin.template: src: settings.json.j2 dest: /etc/transmission-daemon/settings.json owner: debian-transmission group: debian-transmission mode: "a-rwx,u+rw" notify: - - reload transmission + - Reload transmission - name: Add cachedir file - copy: + ansible.builtin.copy: src: files/CACHEDIR.TAG dest: /var/lib/transmission-daemon/downloads/CACHEDIR.TAG owner: debian-transmission diff --git a/roles/borg_client/tasks/main.yml b/roles/borg_client/tasks/main.yml index 47824ca..3ff18cc 100644 --- a/roles/borg_client/tasks/main.yml +++ b/roles/borg_client/tasks/main.yml @@ -1,28 +1,30 @@ --- -- name: create SSH key - openssh_keypair: +- name: Create SSH key + community.crypto.openssh_keypair: path: ~/.ssh/id_rsa -- name: get SSH pub key - command: cat ~/.ssh/id_rsa.pub +- name: Get SSH pub key + ansible.builtin.command: + cmd: cat ~/.ssh/id_rsa.pub + changed_when: true register: ssh_keys -- name: put backup script - template: +- name: Put backup script + ansible.builtin.template: src: borgbackup.sh.j2 dest: /usr/local/bin/borgbackup.sh owner: root group: root mode: '0750' -- name: cron the backup script - cron: +- name: Cron the backup script + ansible.builtin.cron: name: "borg backup script" hour: "{{ borg_backup_hour }}" minute: "{{ borg_backup_minute }}" job: /usr/local/bin/borgbackup.sh -- name: warns about borg init - debug: +- name: Warns about borg init + ansible.builtin.debug: msg: "Borg has been installed. Don’t forget to init with: \nborg init --encryption=repokey-blake2 backup@{{ hostvars[groups['borg_server'][0]]['ansible_fqdn'] }}:home" diff --git a/roles/borg_server/tasks/main.yml b/roles/borg_server/tasks/main.yml index 40320dc..0b3d8f2 100644 --- a/roles/borg_server/tasks/main.yml +++ b/roles/borg_server/tasks/main.yml @@ -1,15 +1,15 @@ --- -- name: mount backup disk - mount: +- name: Mount backup disk + ansible.posix.mount: path: /backup src: LABEL=BACKUP fstype: ext4 opts: noatime,nofail state: mounted -- name: create backup user - user: +- name: Create backup user + ansible.builtin.user: name: backup comment: Backup create_home: true @@ -18,8 +18,8 @@ system: true state: present -- name: "create directory for borg clients" - file: +- name: Create directory for borg clients + ansible.builtin.file: path: "/backup/repos/{{ hostvars[item]['ansible_fqdn'] }}" state: directory mode: '0750' @@ -27,8 +27,8 @@ group: backup loop: "{{ groups['borg_client'] }}" -- name: "set authorized_keys for borg clients" - authorized_key: +- name: Set authorized_keys for borg clients + ansible.posix.authorized_key: user: backup key: "{{ hostvars[item]['ssh_keys']['stdout'] }}" key_options: "command=\"cd /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}; borg serve --restrict-to-path /backup/repos/{{ hostvars[item]['ansible_fqdn'] }}\"" diff --git a/roles/borgbackup/tasks/main.yml b/roles/borgbackup/tasks/main.yml index 0dc7a3d..2bbac4e 100644 --- a/roles/borgbackup/tasks/main.yml +++ b/roles/borgbackup/tasks/main.yml @@ -1,12 +1,16 @@ --- -- set_fact: +- name: Set borg fact + ansible.builtin.set_fact: borgbackup: borg when: ansible_facts['distribution'] == "Archlinux" -- set_fact: + +- name: Set borgbackup fact + ansible.builtin.set_fact: borgbackup: borgbackup when: ansible_facts['distribution'] == "Debian" -- name: install borg package - package: + +- name: Install borg package + ansible.builtin.package: name: "{{ borgbackup }}" state: present