686080a493
- inventory: add proxmox host, lxc and vms groups, critical_services per host - retarget bootstrap and time-region to ubuntu:rocky so the Proxmox host is untouched - add ansible.cfg, collections/requirements.yml, .gitignore, .yamllint, .ansible-lint - remove stale root new_lxc.yml duplicate and the Nextcloud upgrade playbook Claude-Session: https://claude.ai/code/session_01JEczyvRjfakkiDNkbZA7PR
116 lines
2.7 KiB
YAML
116 lines
2.7 KiB
YAML
---
|
|
- name: Configure timezone on all hosts
|
|
hosts: ubuntu:rocky
|
|
become: true
|
|
gather_facts: true
|
|
|
|
vars:
|
|
timezone_region: "America/New_York"
|
|
|
|
tasks:
|
|
- name: Copy timezone file
|
|
ansible.builtin.copy:
|
|
src: "/usr/share/zoneinfo/{{ timezone_region }}"
|
|
dest: /etc/localtime
|
|
remote_src: true
|
|
|
|
- name: Write /etc/timezone
|
|
ansible.builtin.copy:
|
|
dest: /etc/timezone
|
|
content: "{{ timezone_region }}\n"
|
|
|
|
- name: Disable NTP on Ubuntu LXC containers
|
|
hosts: ubuntu
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Stop and mask timesyncd on LXC
|
|
ansible.builtin.systemd:
|
|
name: systemd-timesyncd
|
|
state: stopped
|
|
enabled: false
|
|
masked: true
|
|
when: ansible_virtualization_type == "lxc"
|
|
|
|
- name: Disable NTP on Rocky Linux LXC containers
|
|
hosts: rocky
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Stop and mask chronyd on LXC
|
|
ansible.builtin.systemd:
|
|
name: chronyd
|
|
state: stopped
|
|
enabled: false
|
|
masked: true
|
|
when: ansible_virtualization_type == "lxc"
|
|
|
|
- name: Configure NTP on Ubuntu VMs
|
|
hosts: ubuntu
|
|
become: true
|
|
|
|
vars:
|
|
ntp_server: "time.google.com"
|
|
|
|
tasks:
|
|
- name: Configure timesyncd
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/systemd/timesyncd.conf
|
|
regexp: '^#?NTP='
|
|
line: "NTP={{ ntp_server }}"
|
|
state: present
|
|
when: ansible_virtualization_type != "lxc"
|
|
notify: Restart timesyncd
|
|
|
|
handlers:
|
|
- name: Restart timesyncd
|
|
ansible.builtin.systemd:
|
|
name: systemd-timesyncd
|
|
state: restarted
|
|
enabled: true
|
|
|
|
- name: Configure NTP on Rocky Linux VMs
|
|
hosts: rocky
|
|
become: true
|
|
|
|
vars:
|
|
ntp_server: "time.google.com"
|
|
|
|
tasks:
|
|
- name: Disable default chrony pools
|
|
ansible.builtin.replace:
|
|
path: /etc/chrony.conf
|
|
regexp: '^(pool|server) .*'
|
|
replace: '# \1 removed by Ansible'
|
|
when: ansible_virtualization_type != "lxc"
|
|
|
|
- name: Configure chrony NTP server
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/chrony.conf
|
|
line: "server {{ ntp_server }} iburst"
|
|
insertafter: EOF
|
|
state: present
|
|
when: ansible_virtualization_type != "lxc"
|
|
notify: Restart chronyd
|
|
|
|
handlers:
|
|
- name: Restart chronyd
|
|
ansible.builtin.systemd:
|
|
name: chronyd
|
|
state: restarted
|
|
enabled: true
|
|
|
|
- name: Verify time configuration
|
|
hosts: ubuntu:rocky
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Check current system time
|
|
ansible.builtin.command: date
|
|
register: check_time
|
|
changed_when: false
|
|
|
|
- name: Summary
|
|
ansible.builtin.debug:
|
|
msg: "{{ inventory_hostname }} ({{ ansible_virtualization_type | default('unknown') }}) - {{ check_time.stdout }}"
|