|
27 | 27 | when: not nomad_cni_checksum.stat.exists
|
28 | 28 | delegate_to: 127.0.0.1
|
29 | 29 |
|
| 30 | +- name: Re-check CNI package checksum file |
| 31 | + ansible.builtin.stat: |
| 32 | + path: "{{ role_path }}/files/{{ nomad_cni_checksum_file }}" |
| 33 | + become: false |
| 34 | + tags: installation |
| 35 | + register: nomad_cni_checksum |
| 36 | + delegate_to: 127.0.0.1 |
| 37 | + |
| 38 | +- name: Read previously installed checksum |
| 39 | + ansible.builtin.stat: |
| 40 | + path: "{{ nomad_cni_dir }}/{{ nomad_cni_checksum_file }}" |
| 41 | + tags: installation |
| 42 | + register: nomad_cni_remote_checksum |
| 43 | + |
| 44 | +- name: Check if new CNI should be installed |
| 45 | + ansible.builtin.set_fact: |
| 46 | + nomad_should_install_cni: "{{ not nomad_cni_remote_checksum.stat.exists or nomad_cni_remote_checksum.stat.checksum != nomad_cni_checksum.stat.checksum }}" |
| 47 | + |
30 | 48 | - name: Get Nomad CNI package checksum # noqa no-changed-when
|
31 | 49 | ansible.builtin.shell: |
|
32 | 50 | set -o pipefail
|
|
37 | 55 | register: nomad_cni_sha256
|
38 | 56 | tags: installation
|
39 | 57 | delegate_to: 127.0.0.1
|
| 58 | + when: nomad_should_install_cni |
40 | 59 |
|
41 | 60 | - name: Check Nomad CNI package file
|
42 | 61 | ansible.builtin.stat:
|
43 | 62 | path: "{{ role_path }}/files/{{ nomad_cni_pkg }}"
|
44 | 63 | become: false
|
45 | 64 | register: nomad_cni_package
|
46 | 65 | delegate_to: 127.0.0.1
|
| 66 | + when: nomad_should_install_cni |
47 | 67 |
|
48 | 68 | - name: Download Nomad CNI
|
49 | 69 | ansible.builtin.get_url:
|
|
55 | 75 | become: false
|
56 | 76 | tags: installation
|
57 | 77 | delegate_to: 127.0.0.1
|
58 |
| - when: not nomad_cni_package.stat.exists |
| 78 | + when: |
| 79 | + - nomad_should_install_cni |
| 80 | + - not nomad_cni_package.stat.exists |
59 | 81 |
|
60 | 82 | - name: Create Temporary Directory for Extraction
|
61 | 83 | ansible.builtin.tempfile:
|
|
65 | 87 | register: install_temp
|
66 | 88 | tags: installation
|
67 | 89 | delegate_to: 127.0.0.1
|
| 90 | + when: nomad_should_install_cni |
68 | 91 |
|
69 | 92 | - name: Unarchive Nomad CNI
|
70 | 93 | ansible.builtin.unarchive:
|
|
74 | 97 | become: false
|
75 | 98 | tags: installation
|
76 | 99 | delegate_to: 127.0.0.1
|
| 100 | + when: nomad_should_install_cni |
77 | 101 |
|
78 | 102 | - name: Install Nomad CNI
|
79 | 103 | ansible.builtin.copy:
|
|
86 | 110 | - "{{ install_temp.path }}/*"
|
87 | 111 | tags: installation
|
88 | 112 | notify: Restart nomad
|
| 113 | + when: nomad_should_install_cni |
| 114 | + |
| 115 | +- name: Save install checksum record |
| 116 | + copy: |
| 117 | + src: "{{ role_path }}/files/{{ nomad_cni_checksum_file }}" |
| 118 | + dest: "{{ nomad_cni_dir }}" |
| 119 | + tags: installation |
| 120 | + when: nomad_should_install_cni |
89 | 121 |
|
90 | 122 | - name: Cleanup
|
91 | 123 | ansible.builtin.file:
|
|
94 | 126 | become: false
|
95 | 127 | tags: installation
|
96 | 128 | delegate_to: 127.0.0.1
|
| 129 | + when: nomad_should_install_cni |
0 commit comments