mirror of
https://codeberg.org/hyperreal/ansible-homelab
synced 2024-11-01 16:43:09 +01:00
Simplify. Emphasis on the 'simp'.
This commit is contained in:
parent
0554c227f5
commit
017364b496
66
setup.yml
66
setup.yml
@ -1,17 +1,13 @@
|
|||||||
---
|
---
|
||||||
- name: Setup homelab basics for DietPi systems
|
- name: Setup homelab basics for Debian/Ubuntu systems
|
||||||
hosts: homelab
|
hosts: homelab
|
||||||
become: true
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Update apt cache
|
|
||||||
ansible.builtin.apt:
|
|
||||||
cache_valid_time: 1200
|
|
||||||
|
|
||||||
- name: Update cache and all packages
|
- name: Update cache and all packages
|
||||||
register: updatesys
|
register: updatesys
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Display the last line of the previous task to check the stats
|
- name: Display the last line of the previous task to check the stats
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
@ -56,40 +52,33 @@
|
|||||||
- wget
|
- wget
|
||||||
- zsh
|
- zsh
|
||||||
state: present
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Unmask systemd-logind
|
- name: Unmask systemd-logind
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: systemd-logind
|
name: systemd-logind
|
||||||
enabled: true
|
enabled: true
|
||||||
masked: no
|
masked: no
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Ensure systemd-networkd is enabled
|
- name: Ensure systemd-networkd is enabled
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: systemd-networkd
|
name: systemd-networkd
|
||||||
enabled: true
|
enabled: true
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Ensure NetworkManager is disabled
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: NetworkManager
|
||||||
|
enabled: false
|
||||||
|
state: stopped
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Ensure man-db.timer is enabled
|
- name: Ensure man-db.timer is enabled
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: man-db.timer
|
name: man-db.timer
|
||||||
enabled: true
|
enabled: true
|
||||||
|
become: true
|
||||||
- name: Configure unattended-upgrades mail user
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/apt/apt.conf.d/50unattended-upgrades
|
|
||||||
search_string: "//Unattended-Upgrade::Mail"
|
|
||||||
line: 'Unattended-Upgrade::Mail "jas";'
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
|
|
||||||
- name: Configure unattended-upgrades automatic reboot
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/apt/apt.conf.d/50unattended-upgrades
|
|
||||||
search_string: "//Unattended-Upgrade::Automatic-Reboot"
|
|
||||||
line: 'Unattended-Upgrade::Automatic-Reboot "true";'
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: "0644"
|
|
||||||
|
|
||||||
- name: Disable apt downloading translations
|
- name: Disable apt downloading translations
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
@ -99,16 +88,40 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Set the shell to zsh for dietpi user
|
- name: Set the shell to zsh for user
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: jas
|
name: "{{ ansible_user }}"
|
||||||
shell: /usr/bin/zsh
|
shell: /usr/bin/zsh
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Ensure glances systemd unit is in place for user
|
||||||
|
ansible.builtin.blockinfile:
|
||||||
|
path: "{{ ansible_user_dir }}/.config/systemd/user/glances.service"
|
||||||
|
create: true
|
||||||
|
state: present
|
||||||
|
block: |
|
||||||
|
[Unit]
|
||||||
|
Description=Glances
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart={{ ansible_user_dir }}/.local/bin/glances -s
|
||||||
|
Restart=always
|
||||||
|
RemainAfterExit=no
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
|
owner: "{{ ansible_user }}"
|
||||||
|
group: "{{ ansible_user }}"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: Check if reboot is required
|
- name: Check if reboot is required
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: /var/run/reboot-required
|
path: /var/run/reboot-required
|
||||||
register: reboot_required
|
register: reboot_required
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Set is_reboot_required fact
|
- name: Set is_reboot_required fact
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
@ -118,6 +131,7 @@
|
|||||||
ansible.builtin.reboot:
|
ansible.builtin.reboot:
|
||||||
reboot_timeout: 120
|
reboot_timeout: 120
|
||||||
when: is_reboot_required | bool
|
when: is_reboot_required | bool
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Post-reboot confirmation
|
- name: Post-reboot confirmation
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
Loading…
Reference in New Issue
Block a user