소스 검색

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 년 전
부모
커밋
b44972ab87
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 16
    0
      roles/tarsnap/tasks/tarsnap.yml

+ 16
- 0
roles/tarsnap/tasks/tarsnap.yml 파일 보기

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

Loading…
취소
저장