main.yml 2.11 KB
Newer Older
Robin Sonnabend's avatar
Robin Sonnabend committed
1
2
3
4
---
# file: roles/lvm-snapshots/tasks/main.yml

- name: ensure we have the target folder
Lars Beckers's avatar
Lars Beckers committed
5
  file:
6
    path: "{{ program_dir }}"
Lars Beckers's avatar
Lars Beckers committed
7
8
9
10
    state: directory
    owner: root
    group: root
    mode: '0755'
Robin Sonnabend's avatar
Robin Sonnabend committed
11
12
13

- name: ensure our deploy key is present
  copy:
14
    src: "{{ inventory_dir }}/files/deploy-keys/lvm-snapshots"
Robin Sonnabend's avatar
Robin Sonnabend committed
15
16
17
    dest: /root/.ssh/lvm-snapshots.key
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
18
19
    mode: '0600'
  no_log: true
Robin Sonnabend's avatar
Robin Sonnabend committed
20
21
22

- name: ensure our public deploy key is present
  copy:
23
    src: "{{ inventory_dir }}/files/deploy-keys/lvm-snapshots.pub"
Robin Sonnabend's avatar
Robin Sonnabend committed
24
25
26
    dest: /root/.ssh/lvm-snapshots.pub
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
27
28
    mode: '0644'
  no_log: true
Robin Sonnabend's avatar
Robin Sonnabend committed
29
30
31
32
33
34
35

- name: ensure we have our lvm-snapshots ssh config
  copy:
    src: ssh-config.lvm-snapshots
    dest: /root/.ssh/config.lvm-snapshots
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
36
    mode: '0644'
Robin Sonnabend's avatar
Robin Sonnabend committed
37
38
39
40
41

- name: ensure our lvm-snapshots ssh config is included
  lineinfile:
    dest: /root/.ssh/config
    line: "Include config.lvm-snapshots"
Lars Beckers's avatar
Lars Beckers committed
42
    create: true
Robin Sonnabend's avatar
Robin Sonnabend committed
43
44
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
45
    mode: '0644'
Robin Sonnabend's avatar
Robin Sonnabend committed
46
47
48
49

- name: ensure we have the program
  git:
    repo: git@git.fsmpi.rwth-aachen.de:infra/lvm-snapshots.git
50
    dest: "{{ program_dir }}"
51
52
  environment:
    TMPDIR: /root/.ansible/tmp
Robin Sonnabend's avatar
Robin Sonnabend committed
53
54

- name: ensure the necessary programs are installed
Robin Sonnabend's avatar
Robin Sonnabend committed
55
56
57
58
59
  apt:
    name:
      - python3
      - virtualenv
    state: present
Robin Sonnabend's avatar
Robin Sonnabend committed
60
61
62

- name: ensure we have a virtualenv
  pip:
63
64
    requirements: "{{ program_dir }}/requirements.txt"
    virtualenv: "{{ program_dir }}"
Robin Sonnabend's avatar
Robin Sonnabend committed
65
66
67
68
69
70
71
72
    virtualenv_python: python3

- name: ensure we have a frontend script
  template:
    src: script.sh
    dest: /usr/local/sbin/lvm-snapshots
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
73
    mode: '0755'
Robin Sonnabend's avatar
Robin Sonnabend committed
74
75
76
77
78
79
80

- name: ensure we have our config
  template:
    src: config.toml
    dest: /etc/lvm-snapshots.toml
    owner: root
    group: root
Lars Beckers's avatar
Lars Beckers committed
81
    mode: '0644'
Robin Sonnabend's avatar
Robin Sonnabend committed
82
83
84
85

- name: ensure we have a cron job
  cron:
    name: "lvm-snapshots"
86
    minute: "*/{{ snapshot_cron_minutes }}"
Robin Sonnabend's avatar
Robin Sonnabend committed
87
    job: "/usr/local/sbin/lvm-snapshots update"
88
89
90
91
92
93
94

- name: ensure /etc/lvm/archive does not overflow
  cron:
    name: "lvm archive cleanup"
    hour: "0"
    minute: "0"
    job: 'find /etc/lvm/archive -name "*.vg" -mtime +7 -delete'