Browse Source

Only install Tarsnap when version is missing

Checks if the exact version of Tarsnap is already installed and, if so,
skips the download and build steps.
Alex Dunae 10 years ago
parent
commit
b44972ab87
1 changed files with 16 additions and 0 deletions
  1. 16
    0
      roles/tarsnap/tasks/tarsnap.yml

+ 16
- 0
roles/tarsnap/tasks/tarsnap.yml View File

1
+- name: Check if tarsnap {{ tarsnap_version }} is installed
2
+  shell: tarsnap --version | grep {{ tarsnap_version }} --color=never
3
+  register: tarnsap_installed
4
+  changed_when: "tarnsap_installed.stderr != ''"
5
+  ignore_errors: yes
6
+
1
 - name: Install dependencies for Tarsnap
7
 - name: Install dependencies for Tarsnap
8
+  when: tarnsap_installed|failed
2
   apt: pkg={{ item }} state=installed
9
   apt: pkg={{ item }} state=installed
3
   with_items:
10
   with_items:
4
     - libssl-dev
11
     - libssl-dev
6
     - e2fslibs-dev
13
     - e2fslibs-dev
7
 
14
 
8
 - name: Download the current tarsnap code signing key
15
 - name: Download the current tarsnap code signing key
16
+  when: tarnsap_installed|failed
9
   get_url:
17
   get_url:
10
     url=https://www.tarsnap.com/tarsnap-signing-key.asc
18
     url=https://www.tarsnap.com/tarsnap-signing-key.asc
11
     dest=/root/tarsnap-signing-key.asc
19
     dest=/root/tarsnap-signing-key.asc
12
 
20
 
13
 - name: Add the tarsnap code signing key to your list of keys
21
 - name: Add the tarsnap code signing key to your list of keys
22
+  when: tarnsap_installed|failed
14
   command:
23
   command:
15
     gpg --import tarsnap-signing-key.asc
24
     gpg --import tarsnap-signing-key.asc
16
     chdir=/root/
25
     chdir=/root/
17
 
26
 
18
 - name: Download tarsnap SHA file
27
 - name: Download tarsnap SHA file
28
+  when: tarnsap_installed|failed
19
   get_url:
29
   get_url:
20
     url="https://www.tarsnap.com/download/tarsnap-sigs-{{ tarsnap_version }}.asc"
30
     url="https://www.tarsnap.com/download/tarsnap-sigs-{{ tarsnap_version }}.asc"
21
     dest="/root/tarsnap-sigs-{{ tarsnap_version }}.asc"
31
     dest="/root/tarsnap-sigs-{{ tarsnap_version }}.asc"
22
 
32
 
23
 - name: Make the command that gets the current sha
33
 - name: Make the command that gets the current sha
34
+  when: tarnsap_installed|failed
24
   template:
35
   template:
25
     src=getSha.sh
36
     src=getSha.sh
26
     dest=/root/getSha.sh
37
     dest=/root/getSha.sh
27
     mode=0755
38
     mode=0755
28
 
39
 
29
 - name: get the SHA256sum for this tarsnap release
40
 - name: get the SHA256sum for this tarsnap release
41
+  when: tarnsap_installed|failed
30
   command:
42
   command:
31
     ./getSha.sh
43
     ./getSha.sh
32
     chdir=/root
44
     chdir=/root
33
   register: tarsnap_sha
45
   register: tarsnap_sha
34
 
46
 
35
 - name: Download Tarsnap source
47
 - name: Download Tarsnap source
48
+  when: tarnsap_installed|failed
36
   get_url:
49
   get_url:
37
     url="https://www.tarsnap.com/download/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
50
     url="https://www.tarsnap.com/download/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
38
     dest="/root/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
51
     dest="/root/tarsnap-autoconf-{{ tarsnap_version }}.tgz"
39
     sha256sum={{ tarsnap_sha.stdout_lines[0] }}
52
     sha256sum={{ tarsnap_sha.stdout_lines[0] }}
40
 
53
 
41
 - name: Decompress Tarsnap source
54
 - name: Decompress Tarsnap source
55
+  when: tarnsap_installed|failed
42
   command: tar xzf /root/tarsnap-autoconf-{{ tarsnap_version }}.tgz chdir=/root creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/COPYING
56
   command: tar xzf /root/tarsnap-autoconf-{{ tarsnap_version }}.tgz chdir=/root creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/COPYING
43
 
57
 
44
 - name: Configure Tarsnap for local build
58
 - name: Configure Tarsnap for local build
59
+  when: tarnsap_installed|failed
45
   command: ./configure chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/Makefile
60
   command: ./configure chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/root/tarsnap-autoconf-{{ tarsnap_version }}/Makefile
46
 
61
 
47
 - name: Build and install Tarsnap
62
 - name: Build and install Tarsnap
63
+  when: tarnsap_installed|failed
48
   command: make all install clean chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/usr/local/bin/tarsnap
64
   command: make all install clean chdir=/root/tarsnap-autoconf-{{ tarsnap_version }} creates=/usr/local/bin/tarsnap
49
 
65
 
50
 - name: Copy Tarsnap key file into place
66
 - name: Copy Tarsnap key file into place

Loading…
Cancel
Save