-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcron.yaml
51 lines (45 loc) · 1.62 KB
/
cron.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
39
40
41
42
43
44
45
46
47
48
49
50
51
- hosts: localhost
become: false
gather_facts: no
vars:
crons:
day: { minute: '0', hour: '8', weekday: '*', disabled: 'no', tag: 'base-config', brightness: '70', color: 'green' }
night: { minute: '0', hour: '21', weekday: '*', disabled: 'no', tag: 'base-config', brightness: '20', color: 'cyan' }
rave: { minute: '0', hour: '17', weekday: 'FRI', disabled: 'no', tag: 'rave', brightness: '80', color: 'cyan' }
tasks:
- name: aliases
include_role:
name: aliases
run_once: true
- name: current user - fetch
shell: whoami
register: user
- name: current user - output
debug:
var: user.stdout_lines
- name: current directory
shell: pwd
become: false
register: dir
delegate_to: localhost
run_once: true
- name: execute
vars:
ANSIBLE_CONFIG: "{{ dir.stdout }}/ansible.cfg"
BLINK_PATH: "{{ dir.stdout }}"
cron:
name: "{{ item }}"
minute: "{{ crons[item]['minute'] }}"
hour: "{{ crons[item]['hour'] }}"
weekday: "{{ crons[item]['weekday'] }}"
job: "ansible-playbook {{ BLINK_PATH }}/main.yaml -i {{ BLINK_PATH }}/inventory/all.yaml -t {{ crons[item]['tag'] }} -e brightness={{ crons[item]['brightness'] }} -e color={{ crons[item]['color'] }}"
user: "{{ user.stdout }}"
disabled: "{{ crons[item]['disabled'] }}"
with_items: "{{ crons.keys() | list }}"
register: output
- name: verify
shell: crontab -l
register: output
- name: output
debug:
var: output.stdout_lines