-
Notifications
You must be signed in to change notification settings - Fork 31
/
main.yaml
38 lines (33 loc) · 914 Bytes
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
- name: Install sqlite3
apt:
force_apt_get: yes
name: sqlite3
become: yes
- name: Generate ssh keypair
community.crypto.openssh_keypair:
comment: pihole-sync-{{ inventory_hostname }}
path: .ssh/id_rsa_sync
register: ssh_key
- name: Add key to authorized_keys on all other nodes
ansible.posix.authorized_key:
key: "{{ ssh_key.public_key }}"
user: "{{ ansible_user }}"
delegate_to: "{{ item }}"
loop: "{{ groups['all']|difference([inventory_hostname]) }}"
- name: Create sync folder
file:
path: pihole_sync
state: directory
mode: 0755
register: sync_dir
- name: Copy sync script
template:
dest: "{{ sync_dir.path }}/pihole_sync.sh"
src: pihole_sync.j2
mode: 0755
- name: Schedule sync with cron
ansible.builtin.cron:
hour: "2,14"
minute: "0"
job: "{{ ansible_user_dir }}/{{ sync_dir.path }}/pihole_sync.sh"
name: pihole-sync