Files
ansible-pull/local.yml
2021-02-23 14:56:56 +01:00

78 lines
1.7 KiB
YAML

---
- hosts: all
connection: local
become: true
pre_tasks:
- name: pre-run | update apt repository (debian, ubuntu, etc.)
apt: update_cache=yes
changed_when: False
when: ansible_distribution in ["Debian", "Ubuntu"]
- name: pre-run | update pacman repository (arch)
pacman: update_cache=yes
changed_when: False
when: ansible_distribution == 'Archlinux'
- name: pre-run |update portage repository (gentoo)
portage:
sync: yes
when: ansible_distribution == 'Gentoo'
# run roles
- hosts: all
tags: base
become: true
roles:
- base
- hosts: workstation
tags: workstation
become: true
roles:
- workstation
- hosts: server
tags: server
become: true
roles:
- server
# end of roles; cleanup and reporting
- hosts: all
become: true
tasks:
- name: cleanup package cache (debian and ubuntu)
tags: always
apt:
autoclean: yes
changed_when: false
when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
- name: autoremove orphan packages (debian and ubuntu)
tags: always
apt:
autoremove: yes
purge: yes
when: ansible_distribution in ["Debian", "Pop!_OS", "Ubuntu"]
- name: cleanup package cache (arch)
tags: always
pacman:
autoclean: yes
changed_when: false
when: ansible_distribution == "Archlinux"
- name: send completion alert
include_tasks: playbooks/send_completion_alert.yml
tags: always
when:
- task_failed is not defined
- name: send failure alert
include_tasks: playbooks/send_failure_alert.yml
tags: always
when:
- task_failed is defined
- task_failed == true
# vim: ts=2 sw=2 fdm=indent