src.nth.io/

summaryrefslogtreecommitdiff
path: root/mattertimectl/controller/tasks/main.yaml
blob: a77145cc25ff0ed5e70df3e302de7e28aa41568b (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---

- name: add mattertimectl user
  become: yes
  user:
    name: "{{mattertimectl_user}}"
    system: "yes"
    shell: "/usr/sbin/nologin"
    home: "{{mattertimectl_storage_path}}"
    create_home: "no"

- name: create mattertimectl directories
  become: yes
  file:
    path: "{{item.path}}"
    state: "directory"
    owner: "{{item.owner}}"
    group: "{{item.owner}}"
    mode: "{{item.mode}}"
  loop:
    - { path: "{{mattertimectl_install_dir}}", owner: "root", mode: "0755" }
    - { path: "{{mattertimectl_config_dir}}", owner: "root", mode: "0755" }
    - { path: "{{mattertimectl_storage_path}}", owner: "{{mattertimectl_user}}", mode: "0700" }

- name: check installed mattertimectl version
  become: yes
  stat:
    path: "{{mattertimectl_install_dir}}/.installed-{{mattertimectl_version}}"
  register: mattertimectl_installed

- name: install mattertimectl bundle
  become: yes
  unarchive:
    remote_src: yes
    src: "{{mattertimectl_bin_url}}"
    dest: "{{mattertimectl_install_dir}}/"
    owner: "root"
    group: "root"
  when: not mattertimectl_installed.stat.exists

- name: stamp installed mattertimectl version
  become: yes
  copy:
    dest: "{{mattertimectl_install_dir}}/.installed-{{mattertimectl_version}}"
    content: "{{mattertimectl_version}}\n"
    mode: "0644"
  when: not mattertimectl_installed.stat.exists

- name: configure mattertimectl
  become: yes
  template:
    src: "config.json.j2"
    dest: "{{mattertimectl_config_dir}}/config.json"
    owner: "root"
    group: "{{mattertimectl_user}}"
    mode: "0640"

- name: install mattertimectl systemd service
  become: yes
  template:
    src: "mattertimectl.service.j2"
    dest: "/etc/systemd/system/mattertimectl.service"
    mode: "0644"
  notify: reload systemd

- name: install mattertimectl systemd timer
  become: yes
  template:
    src: "mattertimectl.timer.j2"
    dest: "/etc/systemd/system/mattertimectl.timer"
    mode: "0644"
  notify: reload systemd

- name: enable mattertimectl timer
  become: yes
  systemd:
    name: "mattertimectl.timer"
    enabled: "yes"
    state: "started"
    daemon_reload: "yes"