Skip to content

Commit

Permalink
Simplify download archive logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Mar 14, 2021
1 parent 63a4dbb commit 16c2322
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Major Changes

- Simplify download archive logic

## 4.7.0 - 2021-03-13

### Major Changes
Expand Down
14 changes: 0 additions & 14 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: etcd | download archive
vars:
ansible_python_interpreter: "python3"
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
checksum: "{{ item.checksum }}"
mode: "{{ item.mode | default('0644') }}"
timeout: 300
loop:
- "{{ etcd_download }}"
register: result
until: result is succeeded

- name: etcd | systemctl daemon-reload
systemd:
daemon_reload: true
Expand Down
23 changes: 18 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,30 @@
- { dest: "/usr/local/bin" }
- { dest: "/var/lib/etcd" }
- { dest: "{{ etcd_cert_file | dirname }}" }
- { dest: "{{ etcd_download.dest | dirname }}" }
- { dest: "{{ etcd_key_file | dirname }}" }
- { dest: "{{ etcd_peer_cert_file | dirname }}" }
- { dest: "{{ etcd_peer_key_file | dirname }}" }
- { dest: "{{ etcd_peer_trusted_ca_file | dirname }}" }
- { dest: "{{ etcd_trusted_ca_file | dirname }}" }
notify:
- etcd | download archive

- name: flush handlers
meta: flush_handlers
- name: download archive
shell: |
set -euo pipefail
TMP_DIR="$(mktemp -d)" \
&& cd $TMP_DIR \
&& mkdir -p ./{{ item.dest | dirname }} \
&& curl -skL -m 300 {{ item.url }} > ./{{ item.dest }} \
&& echo -n "{{ item.sha256sum }} ./{{ item.dest }}" | sha256sum -c - \
&& mkdir -p {{ item.dest | dirname }} \
&& mv ./{{ item.dest }} {{ item.dest }} \
&& rm -rf $TMP_DIR
args:
executable: "/bin/bash"
creates: "{{ item.dest | dirname }}"
loop:
- "{{ etcd_download }}"
register: result
until: result is succeeded

- name: unarchive package
shell: |
Expand Down
12 changes: 6 additions & 6 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ _etcd_download:
"v3.4.14":
url: "http://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz"
dest: "/var/cache/ansible/f57141d45ceb727a84e2f0bcd0b98934ea2ad2b59009be90d901710861601651/etcd-v3.4.14-linux-amd64.tar.gz"
checksum: "sha256:f57141d45ceb727a84e2f0bcd0b98934ea2ad2b59009be90d901710861601651"
sha256sum: "f57141d45ceb727a84e2f0bcd0b98934ea2ad2b59009be90d901710861601651"
"v3.4.13":
url: "http://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz"
dest: "/var/cache/ansible/2ac029e47bab752dacdb7b30032f230f49e2f457cbc32e8f555c2210bb5ff107/etcd-v3.4.13-linux-amd64.tar.gz"
checksum: "sha256:2ac029e47bab752dacdb7b30032f230f49e2f457cbc32e8f555c2210bb5ff107"
sha256sum: "2ac029e47bab752dacdb7b30032f230f49e2f457cbc32e8f555c2210bb5ff107"
"v3.4.12":
url: "http://github.com/etcd-io/etcd/releases/download/v3.4.12/etcd-v3.4.12-linux-amd64.tar.gz"
dest: "/var/cache/ansible/d920c2d704979f377d152f8d6d4dc9e3a17b1a5a609c7549bbbf3901f43755a8/etcd-v3.4.12-linux-amd64.tar.gz"
checksum: "sha256:d920c2d704979f377d152f8d6d4dc9e3a17b1a5a609c7549bbbf3901f43755a8"
sha256sum: "d920c2d704979f377d152f8d6d4dc9e3a17b1a5a609c7549bbbf3901f43755a8"
"v3.3.25":
url: "http://github.com/etcd-io/etcd/releases/download/v3.3.25/etcd-v3.3.25-linux-amd64.tar.gz"
dest: "/var/cache/ansible/aabbb6b657ca69686f5867f3a29db41dd25ed946ff47dec77e6675292fba473a/etcd-v3.3.25-linux-amd64.tar.gz"
checksum: "sha256:aabbb6b657ca69686f5867f3a29db41dd25ed946ff47dec77e6675292fba473a"
sha256sum: "aabbb6b657ca69686f5867f3a29db41dd25ed946ff47dec77e6675292fba473a"
"v3.3.24":
url: "http://github.com/etcd-io/etcd/releases/download/v3.3.24/etcd-v3.3.24-linux-amd64.tar.gz"
dest: "/var/cache/ansible/ebd06eeefc205f15b16c2cb18c28b94408944c4d0fd86b8ca92c2d8456385f6c/etcd-v3.3.24-linux-amd64.tar.gz"
checksum: "sha256:ebd06eeefc205f15b16c2cb18c28b94408944c4d0fd86b8ca92c2d8456385f6c"
sha256sum: "ebd06eeefc205f15b16c2cb18c28b94408944c4d0fd86b8ca92c2d8456385f6c"
"v3.3.23":
url: "http://github.com/etcd-io/etcd/releases/download/v3.3.23/etcd-v3.3.23-linux-amd64.tar.gz"
dest: "/var/cache/ansible/73c18d61cb053a1c62abddf8ad36598da7e130caef6dc7dd22e40d72ad3fbd50/etcd-v3.3.23-linux-amd64.tar.gz"
checksum: "sha256:73c18d61cb053a1c62abddf8ad36598da7e130caef6dc7dd22e40d72ad3fbd50"
sha256sum: "73c18d61cb053a1c62abddf8ad36598da7e130caef6dc7dd22e40d72ad3fbd50"

0 comments on commit 16c2322

Please sign in to comment.