main.yml 2.3 KB
Newer Older
Robin Sonnabend's avatar
Robin Sonnabend committed
1
2
3
4
5
6
7
8
9
10
11
---
# file: roles/lvm-snapshots/tasks/main.yml

- name: ensure we have the target folder
  file: path="{{program_dir}}" state=directory owner=root group=root mode=0755
  tags:
    - lvm-snapshots
    - directory

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

- name: ensure our public deploy key is present
  copy:
24
    src: "{{ inventory_dir }}/files/deploy-keys/lvm-snapshots.pub"
Robin Sonnabend's avatar
Robin Sonnabend committed
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
    dest: /root/.ssh/lvm-snapshots.pub
    owner: root
    group: root
    mode: 0644
  no_log: True
  tags:
    - lvm-snapshots
    - ssh

- 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
    mode: 0644
  tags:
    - lvm-snapshots
    - ssh
    - config

- name: ensure our lvm-snapshots ssh config is included
  lineinfile:
    dest: /root/.ssh/config
    line: "Include config.lvm-snapshots"
    create: yes
    owner: root
    group: root
    mode: 0644
  tags:
    - lvm-snapshots
    - ssh
    - config

- name: ensure we have the program
  git:
    repo: git@git.fsmpi.rwth-aachen.de:infra/lvm-snapshots.git
    dest: "{{program_dir}}"
  tags:
    - git
    - lvm-snapshots

- name: ensure the necessary programs are installed
Robin Sonnabend's avatar
Robin Sonnabend committed
68
69
70
71
72
  apt:
    name:
      - python3
      - virtualenv
    state: present
Robin Sonnabend's avatar
Robin Sonnabend committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  tags:
    - packages
    - lvm-snapshots

- name: ensure we have a virtualenv
  pip:
    requirements: "{{program_dir}}/requirements.txt"
    virtualenv: "{{program_dir}}"
    virtualenv_python: python3
  tags:
    - pip
    - python
    - lvm-snapshots

- name: ensure we have a frontend script
  template:
    src: script.sh
    dest: /usr/local/sbin/lvm-snapshots
    owner: root
    group: root
    mode: 0755
  tags:
    - lvm-snapshots
    - config

- name: ensure we have our config
  template:
    src: config.toml
    dest: /etc/lvm-snapshots.toml
    owner: root
    group: root
    mode: 0644
  tags:
    - lvm-snapshots
    - config

- name: ensure we have a cron job
  cron:
    name: "lvm-snapshots"
    minute: "*/{{snapshot_cron_minutes}}"
    job: "/usr/local/sbin/lvm-snapshots update"
  tags:
    - lvm-snapshots
    - cron